Skip to content

Commit

Permalink
Add ReverseRegistrar deployment details
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Jan 10, 2024
1 parent a95be5b commit 5ab309e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 71 deletions.
48 changes: 26 additions & 22 deletions crosschain-reverse-resolver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ For a detailed readme and usage instructions, see the [monorepo readme](https://

## Deploying (Goerli)

## Deploying (Sepolia)

Before deploying l1 contracts, deploy l2 contracts on https://github.com/ensdomains/ens-contracts

```
git clone https://github.com/ensdomains/ens-contracts
cd ens-contracts
DEPLOYER_KEY=$DEPLOYER_KEY ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY npx hardhat deploy --tags l2 --network optimismSepolia/baseSepolia/arbSepolia
```

Once l2 contracts are deployed, create `.env` and set the following variables

Create `.env` and set the following variables

- DEPLOYER_PRIVATE_KEY
Expand All @@ -16,17 +28,10 @@ Create `.env` and set the following variables
- L2_ETHERSCAN_API_KEY
- VERIFIER_ADDRESS
- REVERSE_NAMESPACE

NOTE: Use https://github.com/ethereum-optimism/evmgateway-starter#op-gateway-and-op-verifier-deployments for VERIFIER_ADDRESS

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

Followed by the L1 contract:
- L2_REVERSE_REGISTRAR_ADDRESS

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

After deployment is complete, set the rersolver of $REVERSE_NAMESPACE to L1ReverseResolver contract address
Expand All @@ -35,25 +40,23 @@ After deployment is complete, set the rersolver of $REVERSE_NAMESPACE to L1Rever

### OP
#### L2
- L2ReverseRegistrar = [0x7D006EFd21eb282C8B0a425BAB546517bfEC2cc2](https://goerli-optimism.etherscan.io/address/0x7D006EFd21eb282C8B0a425BAB546517bfEC2cc2) = REVERSE_NAMESPACE is set to `op.reverse.evmgateway.eth`
- L2ReverseRegistrar = [0x7bB1207A7C23d620Cb22C2DcC96424CCb92272ae](https://sepolia-optimism.etherscan.io/address/0x7bB1207A7C23d620Cb22C2DcC96424CCb92272ae#code) = REVERSE_NAMESPACE is set to `2158639068.reverse.evmgateway.eth`
#### L1
- L1ReverseResolver = [0xeEB5832Ea8732f7EF06d468E40F562c9D7347795](https://goerli.etherscan.io/address/0xeEB5832Ea8732f7EF06d468E40F562c9D7347795)
- L1ReverseResolver = [0x83C058D2139a6eFA32E42BeB415409000C075563](https://sepolia.etherscan.io/address/0x83C058D2139a6eFA32E42BeB415409000C075563#code)

### Base

#### L2
- L2ReverseRegistrar = [0xDC317ef697b3A9903a24abcC325d9C1C80B19D87](https://goerli.basescan.org/address/0xDC317ef697b3A9903a24abcC325d9C1C80B19D87) = REVERSE_NAMESPACE is set to `base.reverse.evmgateway.eth`
- L2ReverseRegistrar = [0x00198c6c94522A81698190ADF411641995Eb180c](https://sepolia.basescan.org/address/0x00198c6c94522A81698190ADF411641995Eb180c#code) = REVERSE_NAMESPACE is set to `2147568180.reverse.evmgateway.eth`
#### L1
- L1ReverseResolver = [0x3c332a23a6052afE947F47656d1fD0f450F4C237](https://goerli.etherscan.io/address/0x3c332a23a6052afE947F47656d1fD0f450F4C237)
- L1ReverseResolver = [0x3d6BBfDCe5C484D9177F3a7d30e3bfe7Add5051E](https://sepolia.etherscan.io/address/0x3d6BBfDCe5C484D9177F3a7d30e3bfe7Add5051E#code)

### Arbitrum

#### L2
- L2ReverseRegistrar = [0x4166B7e70F14C48980Da362256D1Da9Cc8F95e13](https://goerli.arbiscan.io/address/0x4166B7e70F14C48980Da362256D1Da9Cc8F95e13#code) = REVERSE_NAMESPACE is set to `arb.reverse.evmgateway.eth`
- L2ReverseRegistrar = [0x9B3f2e110e27EAe077B581b4880f5BD777121C66](https://sepolia.arbiscan.io/address/0x9B3f2e110e27EAe077B581b4880f5BD777121C66#code) = REVERSE_NAMESPACE is set to `2147905262.reverse.evmgateway.eth`
#### L1
- L1ReverseResolver = [0x2fed4238EfD49d0ECCeEED943BCf4D5C3a299418](Successfully verified contract L1ReverseResolver on the block explorer.
https://goerli.etherscan.io/address/0x2fed4238EfD49d0ECCeEED943BCf4D5C3a299418#code)

- L1ReverseResolver = [0xDC317ef697b3A9903a24abcC325d9C1C80B19D87](https://sepolia.etherscan.io/address/0xDC317ef697b3A9903a24abcC325d9C1C80B19D87#code)

## Usage

Expand All @@ -66,15 +69,16 @@ const registrar = registrar.setName(name)

, try it directly from [etherscan](https://goerli.etherscan.io/address/0xeEB5832Ea8732f7EF06d468E40F562c9D7347795), or run the script
```
DEPLOYER_PRIVATE_KEY=$DEPLOYER_PRIVATE_KEY REVERSE_NAMESPACE=REVERSE_NAMESPACE L2_PROVIDER_URL=$L2_PROVIDER_URL L2_REVERSE_REGISTRAR_ADDRESS=$L2_REVERSE_REGISTRAR_ADDRESS ENS_NAME='foo.op.evmgateway.eth' yarn setname --network optimismGoerli
DEPLOYER_PRIVATE_KEY=$DEPLOYER_PRIVATE_KEY REVERSE_NAMESPACE=$REVERSE_NAMESPACE L2_PROVIDER_URL=$L2_PROVIDER_URL L2_REVERSE_REGISTRAR_ADDRESS=$L2_REVERSE_REGISTRAR_ADDRESS ENS_NAME=$ENS_NAME yarn setname --network optimismSepolia
```

### Query Primary name on L1

The current goerli primary namespace is set at `op.reverse.evmgateway.eth` for Optimism Goerli. Once the ENS DAO approves it, it will be put under `${cointype}.ververse`
The current goerli primary namespace is set at `{cointype}.reverse.evmgateway.eth` for Optimism Goerli. Once the ENS DAO approves it, it will be put under `${cointype}.reverse`

- 2147484068 is the coin type of Optimism Goerli (420)
- 2147568179 is the coin type of Base Goerli (84531)
- 2158639068 is the coin type of Optimism Sepolia (11155420)
- 2147568180 is the coin type of Base Sepolia (84532)
- 2147905262 is the coin type of Arbitrum Sepolia (421614)

```js
import packet from 'dns-packet';
Expand All @@ -94,5 +98,5 @@ console.log(await l1resolver.name(reversenode, {enableCcipRead:true}))
Using the script

```
L1_PROVIDER_URL=$L1_PROVIDER_URL L2_REVERSE_REGISTRAR_ADDRESS=$L2_REVERSE_REGISTRAR_ADDRESS ETH_ADDRESS=$ETH_ADDRESS yarn getname
L1_PROVIDER_URL=$L1_PROVIDER_URL REVERSE_NAMESPACE=$REVERSE_NAMESPACE L2_REVERSE_REGISTRAR_ADDRESS=$L2_REVERSE_REGISTRAR_ADDRESS ETH_ADDRESS=$ETH_ADDRESS yarn getname
```
25 changes: 0 additions & 25 deletions crosschain-reverse-resolver/deploy_l2/01_l2resolver .ts

This file was deleted.

33 changes: 18 additions & 15 deletions crosschain-reverse-resolver/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,42 @@ import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY ?? "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
const L1_PROVIDER_URL = process.env.L1_PROVIDER_URL || '';
const L2_PROVIDER_URL = process.env.L2_PROVIDER_URL || '';
const L1_ETHERSCAN_API_KEY = process.env.L1_ETHERSCAN_API_KEY || '';
const L2_ETHERSCAN_API_KEY = process.env.L2_ETHERSCAN_API_KEY || '';
console.log({L1_PROVIDER_URL,L1_ETHERSCAN_API_KEY,L2_ETHERSCAN_API_KEY})
console.log({L1_PROVIDER_URL,L2_PROVIDER_URL,L1_ETHERSCAN_API_KEY,L2_ETHERSCAN_API_KEY})
const config: HardhatUserConfig = {
solidity: '0.8.19',
networks: {
ganache: {
url: `http://localhost:${parseInt(process.env['RPC_PORT'] || '8545')}`,
},
goerli: {
sepolia: {
url: L1_PROVIDER_URL,
chainId: 11155111,
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: [ "deploy_l1/" ],
},
optimismGoerli: {
url: "https://goerli.optimism.io",
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: [ "deploy_l2/" ],
optimismSepolia: {
url: 'https://sepolia.optimism.io',
chainId: 11155420,
accounts: [DEPLOYER_PRIVATE_KEY]
},
baseGoerli: {
url: "https://goerli.base.org",
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: [ "deploy_l2/" ],
baseSepolia: {
url: 'https://sepolia.base.org',
chainId: 84532,
accounts: [DEPLOYER_PRIVATE_KEY]
},
arbitrumSepolia: {
url: 'https://sepolia-rollup.arbitrum.io/rpc',
chainId: 421614,
accounts: [DEPLOYER_PRIVATE_KEY]
},
arbitrumGoerli: {
url: "https://goerli-rollup.arbitrum.io/rpc",
accounts: [DEPLOYER_PRIVATE_KEY],
deploy: [ "deploy_l2/" ],
}
},
etherscan: {
apiKey: {
goerli: L1_ETHERSCAN_API_KEY,
sepolia: L1_ETHERSCAN_API_KEY,
optimismGoerli: L2_ETHERSCAN_API_KEY,
baseGoerli: L2_ETHERSCAN_API_KEY,
arbitrumGoerli: L2_ETHERSCAN_API_KEY,
Expand Down
2 changes: 1 addition & 1 deletion crosschain-reverse-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "node scripts/test.js",
"storage": "hardhat check",
"setname": "hardhat run scripts/setname.ts",
"getname": "hardhat run scripts/getname.ts --network goerli",
"getname": "hardhat run scripts/getname.ts --network sepolia",
"clean": "rm -fr artifacts cache node_modules typechain-types",
"lint": "exit 0"
},
Expand Down
9 changes: 8 additions & 1 deletion crosschain-reverse-resolver/scripts/getname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ export const main = async () => {

const namespace = process.env.REVERSE_NAMESPACE;
const L1_PROVIDER_URL = process.env.L1_PROVIDER_URL;
const L2_PROVIDER_URL = process.env.L2_PROVIDER_URL;
const L2_REVERSE_REGISTRAR_ADDRESS = process.env.L2_REVERSE_REGISTRAR_ADDRESS
const ETH_ADDRESS = process.env.ETH_ADDRESS;
const provider = new ethers.JsonRpcProvider(L1_PROVIDER_URL);
const l2provider = new ethers.JsonRpcProvider(L2_PROVIDER_URL);
const name = ETH_ADDRESS.substring(2).toLowerCase() + "." + namespace
const encodedname = encodeName(name)
const reversenode = ethers.namehash(name)

console.log({namespace, ETH_ADDRESS, name, encodedname,reversenode})
const reverseresolver = await provider.getResolver(namespace);
console.log({reverseresolver})
if (L2_PROVIDER_URL && L2_REVERSE_REGISTRAR_ADDRESS){
const l2resolver = new ethers.Contract(L2_REVERSE_REGISTRAR_ADDRESS, abi, l2provider);
console.log(`l2: Reverse node for ${name} is set to `, await l2resolver.name(reversenode))
}
const l1resolver = new ethers.Contract(reverseresolver.address, abi, provider);
console.log(`Reverse node is set to `, await l1resolver.name(reversenode, {enableCcipRead:true}))
console.log(`l1: Reverse node for ${name} is set to `, await l1resolver.name(reversenode, {enableCcipRead:true}))
};

main();
19 changes: 12 additions & 7 deletions crosschain-reverse-resolver/scripts/setname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ const ethers = hre.ethers;

export const main = async () => {
const [signer] = await hre.ethers.getSigners();
if (!process.env.REVERSE_NAMESPACE || !process.env.L2_PROVIDER_URL || !process.env.L2_REVERSE_REGISTRAR_ADDRESS || !process.env.ENS_NAME)
throw 'Set REVERSE_NAMESPACE, L2_PROVIDER_URL, L2_REVERSE_REGISTRAR_ADDRESS, and ENS_NAME';
if (!process.env.REVERSE_NAMESPACE)
throw 'Set REVERSE_NAMESPACE';
if (!process.env.L2_PROVIDER_URL)
throw 'Set L2_PROVIDER_URL';
if (!process.env.L2_REVERSE_REGISTRAR_ADDRESS)
throw 'Set L2_REVERSE_REGISTRAR_ADDRESS';
if (!process.env.ENS_NAME)
throw 'Set ENS_NAME';
// if (!process.env.REVERSE_NAMESPACE || !process.env.L2_PROVIDER_URL || !process.env.L2_REVERSE_REGISTRAR_ADDRESS || !process.env.ENS_NAME)
// throw 'Set REVERSE_NAMESPACE, L2_PROVIDER_URL, L2_REVERSE_REGISTRAR_ADDRESS, and ENS_NAME';

const L2_PROVIDER_URL = process.env.L2_PROVIDER_URL;
const L2_REVERSE_REGISTRAR_ADDRESS = process.env.L2_REVERSE_REGISTRAR_ADDRESS;
Expand All @@ -20,13 +28,10 @@ export const main = async () => {
.attach(L2_REVERSE_REGISTRAR_ADDRESS);

console.log({ L2_REVERSE_REGISTRAR_ADDRESS, L2_PROVIDER_URL,ENS_NAME, ETH_ADDRESS, namespace, name, reversenode})
const tx = await l2ReverseRegistrar.setName(ENS_NAME, {
gasPrice: "900000",
gasLimit: 500000,
});
const tx = await l2ReverseRegistrar.setName(ENS_NAME);
const rec = await tx.wait();
console.log({txhash:rec.hash});
console.log(await l2ReverseRegistrar.name(reversenode, {enableCcipRead:true}))
console.log(await l2ReverseRegistrar.name(reversenode))
};

main();

0 comments on commit 5ab309e

Please sign in to comment.