This repo includes implementation of EIP725 based wallet and an account registry contract (to register wallet for new users).
Consists of 2 contracts - which work together to implement the ERC725Account spec:
Responsible for permissions (ERC725Y substandard).
A manager/owner and entrypoint for the ERC725Account (controls the ERC725Account contract).
Why do we need this?
- allows the
ERC725Accountcontract to be managed by multiple addresses (sinceERC725Accountis only managed by a single address) - enables de-coupling of the permissions logic of the
ERC725Accountcontract - enables upgradability of the permissions logic (
KeyManager)
- ERC165
- ERC1271
Responsible for execution (ERC725X substandard - for calls, contract deployments).
Management of the ERC725Y functionality (data key-value store) is provided by the owner KeyManager contract.
- ERC165
- ERC725Y
- ERC725X
- LSP1-UniversalReceiver
- ERC1271
- LSP14Ownable2Step
- LSP17Extendable
note: This bytes4 interface id is calculated as the XOR of the interfaceId of the following standards: ERC725Y, ERC725X, LSP1-UniversalReceiver, ERC1271, LSP14Ownable2Step and LSP17Extendable.
- Additional docs: https://docs.lukso.tech/standards/universal-profile/lsp0-erc725account/#what-does-this-standard-represent-
- The FuturePassIdentityRegistry is the core contract which is responsible for creating user digital identities/accounts
- It is deployed via TransparentUpgradableProxy pattern - to support future upgrades
- note: We do not use hardhat upgrades lib to deploy the proxy, instead an EOA is simply set as the proxy owner (instead of a contract)
- The FuturePass is a modified version of the LSP0/ERC725Account contract, this is the digital identity contract (responsible for on-chain actions/calls)
- This is deployed as a logic contract (implementation which a beacon proxy would point to)
- The FuturePassKeyManager is modified version of the LSP6 contract, this is responsible for the permissions logic of the FVIdenttity contract
UpgradableBeacon- 2 upgradable beacons are deployed, which point toFuturePassandFuturePassKeyManagerimplementation contracts- The beacon proxy pattern is used here (described here), this allows admin to upgrade all user accounts (FuturePass and FuturePassKeyManager) in case new functionality/fixes are to be introduced. This is a cost-effective approach to support mass-upgrades on all user accounts (with single TX)
- The
register(address)function is used to create new future pass for an address- This creates a
BeaconProxypointing to theFuturePassupgradable beacon; inheriting logic of theFuturePasscontract - This also creates a
BeaconProxypointing to theFuturePassKeyManagerupgradable beacon; inheriting logic of theFuturePassKeyManagercontract - The proxies are setup such that the user's
FuturePassKeyManagerproxy points to theFuturePass(target) and theFuturePassproxy owner is set to be theFuturePassKeyManagerproxy contract- The owner of the
FuturePassKeyManagerproxy is the EOA (address being registered)- The
FuturePassKeyManagerproxy contract is the only entrypoint into theFuturePassproxy contract (user's digital identity)
- The
- The owner of the
- note: The proxies only hold state of the respective contracts, they are upgradable (upgrading beacon upgrades
FuturePasscontract logic)
- This creates a
The deployment script will perform the following actions:
sequenceDiagram
title Contract deployment
participant Admin as Admin EOA
participant TRN as Root Network
Admin ->> TRN: Deploy FuturePass logic contract
Admin ->> TRN: Deploy FuturePassKeyManager logic contract
Admin ->> TRN: Deploy Utils Library
Admin ->> TRN: Deploy FuturePassIdentityRegistry logic contract with linked Utils library
Admin ->> TRN: Deploy TransparentUpgradeableProxy with FuturePassIdentityRegistry, initialize upon deployment
TRN -->> TRN: deploy UpgradableBeacons, point implementations to FuturePass and FuturePassKeyManager contracts
sequenceDiagram
title Account registration
participant User
participant Registry as FuturePassIdentityRegistry
User ->> Registry: Calls register(address)
Registry -->> Registry: Deploy BeaconProxy (pointing to FuturePass beacon impl)
Registry -->> Registry: Deploy BeaconProxy (pointing to FuturePassKeyManager beacon impl)
Registry -->> Registry: Initialize FuturePassKeyManager proxy with FuturePass proxy as target
Registry -->> Registry: Initialize FuturePass proxy with FuturePassKeyManager proxy as owner (all permissions)
Registry -->> Registry: Register FuturePassKeyManager proxy as the user addresses account manager
Registry ->> User: Emit FuturePassRegistered and return FuturePassKeyManager (proxy) address
- foundry must be installed
Retrieve git submodules:
forge installBuild contracts:
forge buildRun tests:
forge testCopy the .env.example file to .env and fill in the required values.
cp .env.example .envNote: Dummy values (private key and public address) for Alice have been provided.
- Start local node (e.g. anvil)
- Run command:
Hardhat:
yarn deploy:localForge:
forge script script/Deployer.s.sol:Deployment --fork-url http://localhost:8545 --broadcastHardhat:
yarn deploy:porciniForge:
source .env
forge script script/Deployer.s.sol:Deployment --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvvNote: The --verify flag will verify the deployed contracts on Etherscan.
Note2: Forge cannot be used to deploy to TRN - due to issue
forge test -vvvforge test --gas-report- Get gas results for unit tests as starting point
- Make changes
- Rerun gas tests
- Compare results