44
55# Description
66
7- Smartcoin is a token that aims to be used by whitelisted entities.
7+ The SmartCoin contract is basically an ERC20 with a few specifics
88
9- The Registrar is responsible for whitelisting elegible entities.
9+ The Registrar is responsible for managing elegible entities.
1010
11- The Registrar is also responsible for mint, burn, recall.
12-
13- A modified version of ERC-20 transfers is used, which requires the approval of the Registrar.
11+ The Registrar is also responsible for freeze addresses, unfreeze addresses, mint, burn and wipe frozen addresses.
12+
13+ ## Transfer to the Special Entities
14+
15+ A modified version of ERC-20 transfers is used, transfers to the specials entities (i.e. registrar and operations) are restricted.
16+ Only direct transfer can be made, they cannot be the destination of an approve or a transferFrom.
17+ When the transfer function is called with thoses entities as destination a transfer request is emited.
18+ Tokens will not be transfer until the registrar validate that transfer request.
19+ Until the registrar validate or reject the request, tokens are "engaged".
20+ While engaged, tokens cannot be moved from the holder balance.
21+
22+ ## Contract and Operator Upgrades
23+
24+ The implementation upgrade and operator upgrade are tied.
25+ For the operator to be well regulated, token transaction to/from them are restricted.
26+ This mean that for each transaction (transfer/approve/transferFrom) checks are to be performed.
27+ The goal of this is to lower gas cost of those checks, by storing the operator in the bytecode, while keeping a secure way to update the Operators.
28+
29+ The main step to perform an upgrade are :
30+
31+ - Registrar name the next Operators
32+ - Each operator accept the role
33+ - The actual Technical deploy a new contract
34+ - The actual Registrar authorize the update to the new contract
35+ - The actual Technical launch the UpgradeTo fonction
36+ - The upgrade to function check each operator is Ok, then upgrade is performed
37+
38+ ### Sequence Diagram
39+ ``` mermaid
40+ sequenceDiagram
41+ autonumber
42+ actor OldRegistrar
43+ actor NewOperators
44+ actor OldTechnicalOperator
45+ box gray SmartCoin
46+ participant Proxy
47+ participant OldImpl
48+ participant NewImpl
49+ end
50+ OldRegistrar ->> Proxy : NameNewOperator
51+ Proxy ->> OldImpl : Fw:NameNewOperator
52+ NewOperators ->> Proxy : n*AcceptRole
53+ Proxy ->> OldImpl : Fw:n*AcceptRole
54+ OldTechnicalOperator ->> NewImpl : Deploy With New Operators as Immutable field
55+ critical AuthorizeUpgrade
56+ OldRegistrar ->> Proxy : AuthorizeUpgradeTo(newImplAddress)
57+ Proxy ->> OldImpl : Fw:AuthorizeUpgradeTo(newImplAddress)
58+ OldImpl ->> NewImpl : getOperators
59+ OldImpl ->> OldImpl : validateOperatorsMatchAndHaveAccepted
60+ end
61+ critical UpgradeTo Transaction
62+ OldTechnicalOperator ->> Proxy : UpgradeTo
63+ Proxy ->> OldImpl : Fw: UpgradeTo
64+ OldImpl ->> OldImpl: onlyAuthorizedImplementation
65+ OldImpl ->> OldImpl : _authorizeUpgrade
66+ OldImpl ->> OldImpl : SetImpl
67+ OldImpl ->> OldImpl : Reset Upgrade Operators and Authorization (storage)
68+ end
69+ ```
1470
1571# Pre-requisites
1672
@@ -23,7 +79,7 @@ Configure an environment file `.env` using the example seen in `env.sample`
2379Install the package dependencies via ` npm install `
2480Compile the project via ` npm run build `
2581
26- Deployment is done via truffle by supplying a network to the ` deploy ` command as follows: ` npm run deploy -- --network sepolia `
82+ Deployment is done via hardhat by supplying a network to the ` deploy ` command as follows: ` npm run deploy -- --network sepolia `
2783
2884Unit tests can be run via ` npm run test ` , and code linting can be performed via ` npm run lint `
2985
0 commit comments