This repository contains smart contracts and a Node.js Gateway server that allow storing ENS names on Linea using EIP 3668 and ENSIP 10. They have been adapted from ENS's EVM gateway and ENS crosschain resolver
It also contains a frontend adapted from ENS's frontend to interact with the deployed contract, to create and manage domains on Linea.
Thanks to ccip-read the domains created on Linea can also be resolved on Ethereum.
This schema describes how a client application can resolve a domain name stored on Linea L2 from Ethereum L1 using CCIP Read.
This repository focuses on the ENS use case but the gateway and Verifier contracts are generic, this means that they can be reused for any other use cases that need to fetch data stored on Linea from Ethereum in a trustless way.
The same Fetcher, Verifier contracts and gateway can be used without redeploying them.
To implement your own contract you simply need to:
- Have your own contract extend
EVMFetcher
(In the Linea ENS case this is the L1Resolver contract). - In a view/pure context, use
EVMFetcher
to fetch the value of slots from another contract stored on Linea. CallingEVMFetcher.fetch()
terminates execution and generates a callback to the same contract on a function you specify. - In the callback function, use the information from the relevant slots as you see fit.
The example below fetches another contract's storage value testUint
.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { EVMFetcher } from 'linea-state-verifier/EVMFetcher.sol';
import { EVMFetchTarget } from 'linea-state-verifier/EVMFetchTarget.sol';
import { IEVMVerifier } from 'linea-state-verifier/IEVMVerifier.sol';
contract TestL2 {
uint256 testUint; // Slot 0
constructor() {
testUint = 42;
}
}
contract TestL1 is EVMFetchTarget {
using EVMFetcher for EVMFetcher.EVMFetchRequest;
IEVMVerifier verifier;
address target;
uint256 constant ACCEPTED_L2_BLOCK_RANGE_LENGTH = 86400; // Can be changed to your accepted block range
constructor(IEVMVerifier _verifier, address _target) {
verifier = _verifier;
target = _target;
}
/**
* @dev inherits from EVMFetchTarget
*/
function getAcceptedL2BlockRangeLength()
public
pure
override
returns (uint256)
{
return ACCEPTED_L2_BLOCK_RANGE_LENGTH;
}
function getTestUint() public view returns(uint256) {
EVMFetcher.newFetchRequest(verifier, target)
.getStatic(0)
.fetch(this.getSingleStorageSlotCallback.selector, "");
}
function getSingleStorageSlotCallback(bytes[] memory values, bytes memory) public pure returns(uint256) {
return uint256(bytes32(values[0]));
}
}
- Node.js v18.x.
- pnpm v9.x
- Yarn
- Docker
- docker-compose
See Install in the linea-ens-app README.
The linea-ens-resolver contract intented to be deployed on L1 that is built on top of linea-state-verifier and verifies Linea ENS data (domain names, metadata etc).
More documentation available in linea-ens-resolver/README.md
The linea-ens-contracts contracts intented to be deployed on L2 (Linea) stores and returns the data necessary to resolve a domain name and more data related to ENS.
More documentation available in linea-ens-contracts/README.md
A node-based gateway server that answers queries from L1 Gateway function calls relating to Linea-based L2 contracts.
The Linea ENS frontend adapted from ens-app-v3
The Linea ENS subgraph consumed by the frontend, adapted from ens-subgraph
The linea state verifier contracts are responsible for checking values using sparse merkle proofs returned by the linea-ccip-gateway for specific slots values stored on Linea, adapted from evm-verifier
A NestJS API responsible for signing a message acknowledging an address has passed the POH process, the signature created is then checked by the PohVerifier contract in the linea-ens-contracts.
More information about POH in the package's readme.
Check the deployment folders in ./packages/linea-ens-resolver/deployments and ./packages/linea-ens-contracts/deployments
For detailed information about each package, please check their own Readme file.
An audit has been conducted by Consensys Diligence: https://consensys.io/diligence/audits/2024/06/linea-ens/