Skip to main content

Set Your Contract's Primary ENS Name

Display a human-readable name instead of your contract's 0x address

Updated today

Good to Know

  • For most regular wallet accounts, you can use the ENS App to set the Primary Name directly. See How to Set a Primary Name.

  • Even if your address is technically a contract account, you may still be able to use the ENS App if the contract allows arbitrary transactions (e.g. Gnosis Safe).

  • Before setting a Primary Name, make sure that name's ETH Address record already points to your contract address.


For the latest technical information see: docs.ens.domains/web/naming-contracts#naming-contracts, including some links to 3rd party tools.


Setting a Primary Name for Existing Contracts

You can set a Primary Name for deployed contracts without built-in naming methods if:

  • Your contract inherits the Ownable module and you are the owner.

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

Method A: Using the Set Primary Tool (Recommended)

This tool handles contracts that the ENS App doesn't support.

  1. Visit the Set Primary Tool.

  2. Connect your wallet.

  3. Enter your name.

  4. Click Set Primary Name.

Method B: Using the Contract Directly

Call the Reverse Registrar contract directly on Etherscan.

  1. Go to the Reverse Registrar contract: 0xa58e81fe9b61b5c3fe2afd33cf304c454abfc7cb
    ​https://Etherscan.io/address/0xa58e81fe9b61b5c3fe2afd33cf304c454abfc7cb#writeContract#F8

  2. Click Connect to Web3 to connect your wallet.

  3. Scroll down and expand the setNameForAddr method.

  4. Enter the following fields:

    • addr: The contract address you are setting the Primary Name for.

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

    • Resolver: The Resolver to use for the reverse node. Enter the default Public Resolver: 0xF29100983E058B709F3D539b0c765937B804AC15

    • name: The Primary Name to set for the contract. This must be a name that already forward-resolves to the contract address.

  5. Click Write to send the transaction to your wallet.


Setting a Primary Name for New Contracts

Include the ReverseClaimer module in your contract to set its Primary Name in one transaction during deployment.

Step 1: Add the Required Files

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

Step 2: Inherit ReverseClaimer

Make sure your contract inherits ReverseClaimer:

contract MyContract is ReverseClaimer {
...
}

Step 3: Call It in Your Constructor

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

When you deploy the contract, it will automatically claim the reverse node for that contract address.

Step 4: Set the Primary Name

Use the Set Primary Tool -in Method A above- to set the Primary Name.


Updating the Primary Name When You Own the Reverse Node

Update your Primary Name anytime once you own the reverse node.

Method A: Using the Set Primary Tool (Recommended)

Use the same Set Primary Tool as above. This tool checks for a Resolver sets on the node, then sets your Primary Name.

Method B: Using the Contract Directly

If you prefer to call the contracts directly:

Understanding the Reverse Node

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

Example for address 0x481f50a5BdcCC0bc4322C4dca04301433dED50f0:

  • Input: 481f50a5bdccc0bc4322c4dca04301433ded50f0.addr.reverse

  • Namehash: 0x58354ffdde6ac279f3a058aafbeeb14059bcb323a248fb338ee41f95fa544c86

Step 1: Check the Resolver

Check whether your reverse node has a Resolver using the ENS Registry contract: 0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e (Read Contract, function Resolver).

Step 2: Set the Resolver (If Needed)

If no Resolver is set, set it to the default Public Resolver (0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63) using the ENS Registry contract (Write Contract, function setResolver).

Step 3: Set the Name

Call setName on the Resolver contract to set the Primary Name.


Common Questions

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

Yes, if your contract allows arbitrary transactions (like Gnosis Safe). For other contracts, use the Set Primary Tool or call the contracts directly on Etherscan.

Why isn't my Primary Name resolving?

First set the name's ETH Address record to point to your contract. Primary Names only work when the name already resolves to the address.

What is a reverse node?

A reverse node maps your address to a name, letting apps show 'vitalik.eth' instead of '0x123...'.
​

Did this answer your question?