Skip to main content

Set a primary name for your smart contract

Set yourname.eth as the primary name for a smart contract — three paths depending on the contract type.

Pick the path that matches your contract. Most contracts work with one of these three:

  • Safe (multisig) or any contract that can send arbitrary transactions: use the ENS App at app.ens.domains, just like a regular wallet. See Set your primary name.

  • Existing contract you own: use the Set Primary Tool at tools.ens.xyz, then select Set ENS primary name.

  • New contract you're deploying: add the ReverseClaimer module so the contract claims its reverse node at deploy time, then set the primary name with the Set Primary Tool.

Before setting a primary name, make sure the name's ETH Address already points at your contract address; otherwise the primary name has nothing to resolve back to.

A stack of subname labels, with root.ens.eth highlighted

Good to know

  • Setting a primary name on a contract sets the contract's reverse node: <addr>.addr.reverse. The reverse node tells apps which name to show for a given address.

  • You need ETH on Ethereum Mainnet for gas; there's no other cost.

Set Primary Tool (the recommended path for most contracts)

The Set Primary Tool handles contracts the ENS App doesn't support. It works for both setting a primary name and updating one later.

You can use it if either:

  • The contract inherits the Ownable module and you control the owner address, or

  • You're an approved operator for the contract in the ENS Registry.

  1. Connect the contract owner wallet.

  2. Enter the name.

  3. Select Set primary name and approve in your wallet.

The Set ENS Primary Name tool, with a name entered

If you're using the tool to update an existing primary name, the tool checks for a resolver on the reverse node and sets it if needed, so there are no extra steps for you.


Direct contract calls (for advanced cases or no-tool environments)

Setting the name for the first time: call the Reverse Registrar

Use the Reverse Registrar's setNameForAddr:

  1. Open the Reverse Registrar on Etherscan: 0xa58e81fe9b61b5c3fe2afd33cf304c454abfc7cb
    Reverse Registrar on Etherscan

  2. Select Connect to Web3 and connect your wallet.

  3. Fill in setNameForAddr:

    • addr: the contract address you're naming.

    • owner: the owner of the reverse node in the ENS Registry (your address).

    • resolver: the default Public Resolver: 0xF29100983E058B709F3D539b0c765937B804AC15

    • name: the primary name to set. Must already point at the contract via the ETH Address record.

  4. Select Write and approve in your wallet.

Etherscan's Write Contract tab, with Connect to Web3
The setNameForAddr form on Etherscan, with its Write button

Updating once you already own the reverse node: three calls

The reverse node, in plain terms

The reverse node is the namehash of <addr>.addr.reverse, where <addr> is the contract's address in lowercase with the 0x prefix removed.

Example for 0x481f50a5BdcCC0bc4322C4dca04301433dED50f0:

  • Input: 481f50a5bdccc0bc4322c4dca04301433ded50f0.addr.reverse

  • Namehash: 0x58354ffdde6ac279f3a058aafbeeb14059bcb323a248fb338ee41f95fa544c86

Step 1: Check the resolver. On the ENS Registry contract (0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e), read resolver for your reverse node: Etherscan link.

Step 2: Set the resolver if needed. If no resolver is set, set it to the default Public Resolver (0xF29100983E058B709F3D539b0c765937B804AC15) using setResolver on the same Registry contract: Etherscan link.

Step 3: Set the name. Call setName on the resolver contract.

The setResolver form, with node and resolver filled in
The setName form, with the new name filled in

For new contracts you're deploying

The cleanest pattern is to inherit the ReverseClaimer module so the contract claims its reverse node at deploy time. See the developer docs for the current code samples.

Then set the primary name with the Set Primary Tool at tools.ens.xyz, then select Set ENS primary name.


Common questions

Why isn't my primary name resolving?

The most common cause is the name's ETH Address record. The primary name only works once the name itself points at your contract address — set that on the name's profile in the ENS App, then come back and set the primary name.

Did this answer your question?