Skip to main content

How do I set a Primary Name for my 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 How do I set my Primary Name?

  • Existing contract you own (Ownable, or you're an approved operator): use the Set Primary Tool at tools.ens.xyz.

  • New contract you're deploying: add the ReverseClaimer module so the contract claims its reverse node at deploy time, then run the tool above.

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.

Every smart contract needs and deserves a name.

Good to know

  • Safes and other contracts that pass through arbitrary calls behave like regular wallets in the ENS App — start there before trying anything else.

  • 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 — no other cost.

  • The Primary Name only resolves if the name's ETH Address already points at the contract — set that on the name's profile first.

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 — same flow, same checks.

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.

Steps:

  1. Connect the contract owner wallet.

  2. Enter the name.

  3. Click Set Primary Name and approve in your wallet.

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 — no extra steps for you.

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

If you'd rather call the contracts directly, there are two flows depending on whether you already own your reverse node.

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
    https://etherscan.io/address/0xa58e81fe9b61b5c3fe2afd33cf304c454abfc7cb#writeContract#F8

  2. Click 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. Click Write and approve in your wallet.

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 (0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63) using setResolver on the same Registry contract: Etherscan link.

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

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.

Step 1: Add the files

Include the ReverseClaimer module (ReverseClaimer.sol) and the core ENS registry interface (ENS.sol).

Step 2: Inherit ReverseClaimer

contract MyContract is ReverseClaimer {   ...}

Step 3: Call it in your constructor

constructor (   ENS ens,   ... ) ReverseClaimer(ens, msg.sender) {   ... }

When the contract deploys, it claims the reverse node for the contract address automatically.

Step 4: Set the Primary Name

Use the Set Primary Tool from the section above.

Common questions

Can I use the ENS App to set a Primary Name for a contract?

Yes, if your contract allows arbitrary transactions (Safe and similar multisigs do). For contracts that can't pass through arbitrary calls, use the Set Primary Tool at tools.ens.xyz or call the Reverse Registrar on Etherscan.

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.

What is a reverse node?

The reverse node is the onchain entry that maps an address back to a name. It's the namehash of <addr>.addr.reverse. Setting a Primary Name for a contract is really about writing the name into the contract's reverse node.

What's next?

Did this answer your question?