This is an attempt at an implementation of ERC 725 and ERC 735, following the specs as closely as possible. It uses the Truffle framework and Ganache CLI for testing.
The smart contract implements the following features:
- deploy contract using initial set of keys (
Identity.sol
) - add/remove keys to identity (
KeyManager.sol
) - get key data, in multiple ways (
KeyGetters.sol
) - "proxy contract" execution on the blockchain (
MultiSig.sol
) - multi-signature mechanism for MANAGEMENT_KEY and ACTION_KEY (
MultiSig.sol
) - add/remove claims to identity (
ClaimManager.sol
) - get claim data, in multiple ways (
ClaimManager.sol
) - refresh claims in identity (
ClaimManager.sol
) - ability to pause/unpause the contract, potentially with multi-sig (
Pausable.sol
) - ability to destroy the contract and return funds, potentially with multi-sig (
Destructible.sol
)
The implementation tries to make extensive use of Solidity patterns for modular code i.e. libraries, abstract contracts and multiple inheritence. Here's how the class diagram looks:
+--------------+ +------------+
| | | |
| ERC 165 | | KeyStore** |
| | | |
+---+--------+-+ +----+-------+
| | |
+----v-----+ +v---------+ +----v-----+
| | | | | |
+-------------+ ERC 735* | | ERC 725* | | KeyBase* |
| | | | | | |
| +----------+ ++-+----+--+ +--+-------+------+--------------+
| | | | | | |
| | | | | | |
| +-----------------------+ | | +-----+-----+ +-----v-----+ +------v-------+
| | | | | | | | | |
| | +-------|----|-+ Pausable | | KeyGetter | | Destructible |
| | +--------------------|----|-+ | | | | |
| | | | | | +--+--------+ +-+---------+ +--+-----------+
| | | | +----+ | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+v---v----v---+ +------v--v---+ +--v----v--+ | |
| | | | | | | |
|ClaimManager | | KeyManager | | MultiSig | | |
| | | | | | | |
+---+---------+ ++------------+ +--+-------+ | |
| | | | |
| | | | |
| | +---------v------------------v---+ |
| | | <----------+
| +--------> Identity |
| | (ERC 725 + 735) |
+---------------------> |
+--------------------------------+
* = Abstract contract
** = Library
Truffle tests exists for each contract, in separate files in the test/
folder. Each tests tries to count how much gas it's using for setup and during the test. Also, at the end I'm printing out
total gas used for all tests.
$ ganache-cli -l 10000000
...
$ truffle test
...
✓ should be paused/unpaused by management keys (5825603 gas)
Test: 60,502 gas
47 passing (53s)
Currently missing unit tests for events being emitted.
- Can't pass an initial set of claims on contract deploy, seems like
ABIEncodeV2
is needed to havebytes[] signatures, bytes[] data, string[] uris
in the constructor. uri
is not included in the signature and could theoretically be changed without changing a claim signature. Is this intentional or not?- Claim IDs are generated using
keccak256(address issuer + uint256 _topic)
, which doesn't work great for self-claims i.e.issuer
isaddress(this)
and we might want multiple self-claims with the sametopic
- Added an
ExecutionFailed
event inERC725
which isn't part of the standard - For execution requests, I'm using the multi-sig threshold at the time of request, not the one at the time of execution - is that a good idea? (e.g. you request an execution, threshold is
X
, wait for approvals, threshold is increased toY
, initial execution is approval withX
approvals) - Using ERC 165 pseudo-introspection to check if an address implements ERC 725 or 735. Is this the best pattern for that?
- Added a
PROFILE_TOPIC
claim topic which isn't part of the standard. The intended use is to store a plain-text profile URL indata
(social media, blogs, etc.). As a convention,uri
should be equal todata
. - Added a
LABEL_TOPIC
claim topic which isn't part of the standard. The intended use is to store a plain-text label indata
(real name, business name, nick name, brand name, alias, etc.). - The "proxy contract" only supports
.call
, doesn't support.delegateacall
or creating a new contract on behalf of the identity.