Skip to content

Commit 05e6732

Browse files
Adding notes on setName
1 parent cc19328 commit 05e6732

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

docs/web/naming-contracts.mdx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ contract ReverseClaimer {
6262
}
6363
```
6464

65+
You can also call the ReverseRegistrar's `setName` function directly. However note that if you do this, you will not be able to change the primary name for that contract ever again. Also remember to set the ETH address on your ENS name to the address at which your contract was deployed.
66+
67+
```solidity
68+
import {ENS} from "../registry/ENS.sol";
69+
import {IReverseRegistrar} from "../reverseRegistrar/IReverseRegistrar.sol";
70+
71+
contract ReverseClaimer {
72+
bytes32 constant ADDR_REVERSE_NODE =
73+
0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;
74+
75+
constructor(ENS ens, string primaryName) {
76+
IReverseRegistrar reverseRegistrar = IReverseRegistrar(ens.owner(ADDR_REVERSE_NODE));
77+
reverseRegistrar.setName(primaryName);
78+
}
79+
}
80+
```
81+
6582
You can read more about setting a primary name for a contract in on the [support page](https://support.ens.domains/en/articles/7902626-set-primary-name-for-contract).
6683

6784
## Existing Contracts
@@ -85,16 +102,20 @@ From your contract you can execute `setName` function on the [Reverse Registrar]
85102

86103
## L2 Contracts
87104

88-
If you want to set a primary name for a contract you are deploying on an L2 chain, you need to make sure your contract implements the [Ownable](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable) interface from OpenZeppelin, and has an account you own set as the owner.
105+
### L2 - Ownable
89106

90-
You will also need to locate the canonical Reverse Resolver for that L2 chain. We currently do not have a way to discover those contracts, but for now, selected deployments are listed here:
107+
If you want to set a primary name for a contract you are deploying on an L2 chain, you need to make sure your contract implements the [Ownable](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable) interface from OpenZeppelin, and has an account you own set as the owner.
91108

92-
| Network | L2ReverseResolver deployment |
93-
| ---------------- | ------------------------------------------ |
94-
| Base Sepolia | 0xa12159e5131b1eEf6B4857EEE3e1954744b5033A |
95-
| OP Sepolia | 0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376 |
96-
| Arbitrum Sepolia | 0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376 |
97-
| Scroll Sepolia | 0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62 |
98-
| Linea Sepolia | 0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376 |
109+
You will also need to locate the canonical Reverse Registry for that L2 chain. We currently do not have a way to discover those contracts, but for now, selected deployments are listed here: [Primary Names](/web/reverse#set)
99110

100111
Then, after you've deployed your contract, call `setNameForAddr(address addr, string name)` on the L2 Reverse Resolver from your authorized owner account. The `addr` is the address of your contract, and `name` is the ENS name to set it to.
112+
113+
### L2 - Manually
114+
115+
Another option is to call the L2ReverseRegistry's `setName(string name)` function directly, in the constructor of your contract. However note that if you do this, you will not be able to change the primary name for that contract ever again.
116+
117+
<Note>
118+
Make sure that the ENS name also resolves to your contract address for the appropriate cointype.
119+
120+
For example, if you are deploying a contract on Base, make sure you set the Base address on your ENS name to your contract address.
121+
</Note>

0 commit comments

Comments
 (0)