Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Oct 30, 2023
1 parent 553696e commit 4443f88
Showing 1 changed file with 2 additions and 83 deletions.
85 changes: 2 additions & 83 deletions crosschain-reverse-resolver/README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,5 @@
# @ensdomains/crosschain-resolver
# @ensdomains/crosschain-reverse-resolver

A resolver contract that is built on top of evm-verifier.
A reverse resolver contract that is built on top of evm-verifier.

For a detailed readme and usage instructions, see the [monorepo readme](https://github.com/ensdomains/evmgateway/tree/main).


## How it is defined

When the resolver has the following storage layout,

```
contract Resolver {
// node => version
mapping(bytes32 => uint64) public recordVersions;
// versionable_addresses[recordVersions[node]][node][coinType]
// version => node => cointype
mapping(uint64 => mapping(bytes32 => mapping(uint256 => bytes))) versionable_addresses;
```

Run `yarn storage` to find out storage slot for each variable

```
// ┌─────────────────────┬──────────────────────────────┬──────────────┬
// │ contract │ state_variable │ storage_slot │
// ├─────────────────────┼──────────────────────────────┼──────────────┼
// | OwnedResolver │ _owner │ 0 │
// │ OwnedResolver │ recordVersions │ 1 │
// │ OwnedResolver │ versionable_abis │ 2 │
// │ OwnedResolver │ versionable_addresses │ 3 │
```

Then define the l1 function

```
function addr(
bytes32 node,
uint256 coinType
) public view returns (bytes memory) {
EVMFetcher.newFetchRequest(verifier, target)
.getStatic(1) // storage_slot of recordVersions
.element(node)
.getDynamic(3) // storage_slot of versionable_addresses
.ref(0) // Referencing the result of `.getStatic(0)`
.element(node)
.element(coinType)
.fetch(this.addrCoinTypeCallback.selector, ''); // recordVersions
```

Storage verificaton can only verify the data of l2. When the function result needs some transformation, transform inside the callback function as follows.

```
function addrCallback(
bytes[] memory values,
bytes memory
) public pure returns (address) {
return bytesToAddress(values[1]);
}
```



## Deploying (Goerli)

Create `.env` and set the following variables


- DEPLOYER_PRIVATE_KEY
- L1_PROVIDER_URL
- L2_PROVIDER_URL
- L1_ETHERSCAN_API_KEY
- L2_ETHERSCAN_API_KEY
- OP_VERIFIER_ADDRESS=0x0c2746F20C9c97DBf718de10c04943cf408230A3

```
bun run hardhat deploy --network optimismGoerli
```

Followed by the L1 contract:

```
bun run hardhat deploy --network goerli
```


## Deployments

0 comments on commit 4443f88

Please sign in to comment.