Minimal L2 Resolver system for ENS. It resolves ENS names to their corresponding EIP-7930-formatted chain identifiers (as bytes) and maps these EIP-7930 chain identifiers back to their primary ENS names. The system is implemented as a single contract that manages storage, authorization, and resolution logic.
- given a domain set a chainID identifier
- given a chainID identifier set a domain
- caller must be owner of the ENS domain or approved by the owner in order to set records
- given a chainID identifier, returns the domain name
- returns the domain for a given chainID identifier
- returns the chainID identifier for a given domain
- given a domain, returns the chainID identifier
- implementation of ENSIP-10
- resolves
chainIdandchainNameselectors
- returns true for
IERC165andIExtendedResolver
- node (ENS node, can be calculated using this tool):
0xcd14771f519e64452fe1d5a43016d25c86ef573ec499773443e29751c0dfcebc - key (as a string):
chain.id.eip7930 - value (as bytes, can be calculated in this way):
00010000010A00
Then setRecord() must be called with the parameters mentioned above. More information here
- node (constant, can be retrieved from the contract variable
REVERSE_LOOKUP_NODE):0xa1e7ae8efca73939b8018c7c06321689d70c6362862a1c900eb76c9e581e4ae8 - key (as a string, calculated in this way):
chain.id.eip79300x0a5a087e45046a1443319a227fbdfd0bfc6dfffc23c885a334649dc09b3d88e2 - value (abi encoded domain, in this case
abi.encode('optimism.l2.eth')):0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f6f7074696d69736d2e6c322e6574680000000000000000000000000000000000
Then setRecord() must be called with the parameters mentioned above. More information here
To populate a file with the setRecords calldatas for the available chains in https://github.com/ethereum-lists/chains, run:
cd populate-script
yarn install
yarn populateThe script will populate a file in populate-script/out/batches.json with the following format:
[
{
"chainIds": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"forwardCalldata": "0x57d...",
"reverseCalldata": "0x57dcc7..."
},
//...
]The file is separated in batches of max 10 chains. Each batch contains the setRecords calldata (forward and reverse) for the chains in the chainIds array.
The complete technical specification can be found here.
- Install Foundry by following the instructions from their repository.
- Copy the
.env.examplefile to.envand fill in the variables. - Install rust dependencies with cargo:
cargo install lintspeccargo install bulloak
- Install the dependencies by running:
yarn install. In case there is an error with the commands, runfoundryupand try them again.
The default way to build the code is suboptimal but fast, you can run it via:
yarn buildIn order to build a more optimized code (via IR), run:
yarn build:optimizedUnit tests should be isolated from any externalities, while Integration usually run in a fork of the blockchain. In this boilerplate you will find example of both.
In order to run both unit and integration tests, run:
yarn testIn order to just run unit tests, run:
yarn test:unitIn order to run unit tests and run way more fuzzing than usual (5x), run:
yarn test:unit:deepIn order to just run integration tests, run:
yarn test:integrationIn order to start the Medusa fuzzing campaign (requires Medusa installed), run:
yarn test:fuzzIn order to just run the symbolic execution tests (requires Halmos installed), run:
yarn test:symbolicIn order to check your current code coverage, run:
yarn coverageIn order to create a new .t.sol file from a .tree bulloak file, run:
yarn test:bulloak:scaffoldIn order to fix or add missing tests to a .t.sol file after changing a .tree bulloak file, run:
yarn test:bulloak:fixsource .env$MAINNET_DEPLOYER_NAME and $SEPOLIA_DEPLOYER_NAME are the names of the private keys in the keystore.
$ETHERSCAN_API_KEY is required for the deployment to be verified on Etherscan.
cast wallet import $MAINNET_DEPLOYER_NAME --interactiveor
cast wallet import $SEPOLIA_DEPLOYER_NAME --interactiveyarn deploy:sepoliaor
yarn deploy:mainnetThe deployments are stored in ./broadcast
See the Foundry Book for available options.
The primary license for the L2Resolver is MIT, see LICENSE