You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/web/naming-contracts.mdx
+30-9Lines changed: 30 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,23 @@ contract ReverseClaimer {
62
62
}
63
63
```
64
64
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";
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).
66
83
67
84
## Existing Contracts
@@ -85,16 +102,20 @@ From your contract you can execute `setName` function on the [Reverse Registrar]
85
102
86
103
## L2 Contracts
87
104
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
89
106
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.
| 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)
99
110
100
111
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.
0 commit comments