Reverse Entry for Smart Contracts
You can set up a reverse entry in a contract to easily find contact information if there are any problems.
Example use cases are:
- For instance, if someone mistakenly sends VET to your contract, they can use the address to find a .vet-name and reach out to the person in charge.
- Allows explorers to clearly display associated contracts.
- Enables verification when your .vet-name points to the contracts too.
You can manually set the primary name for contracts by using the Ownable (opens in a new tab) module, either by yourself or when you have been delegated management permissions, through a simple web tool at:
New Contracts
If you are developing a new contract, and you want to be able to easily set the Primary Name for it, then you can include this module: ReverseClaimer.sol (opens in a new tab)
Also include the interface for the core registry: ENS.sol (opens in a new tab)
Make sure your contract inherits ReverseClaimer:
contract MyContract is ReverseClaimer {
// Then call it in your constructor:
constructor (
ENS ens,
...
) ReverseClaimer(ens, msg.sender) {
...
}
}
ens
is the Registry, you can check the contract addresses on the Contracts page.
When you deploy that contract, it will automatically claim the reverse node for that contract address and assign ownership to you.
From Contract-Owner
If your contract has already been deployed without any built-in methods to set its own primary name, you still have the option to set it.
Should your contract inherit the Ownable (opens in a new tab) module and you are the owner, you can utilize the setNameForAddr()
function to assign yourself as the owner and modify the name.
This function must be invoked on the Reverse Registrar by the contract owner.
function setNameForAddr(address addr, address owner, address resolver, string memory name) external returns (bytes32)
- addr: The contract address you are setting the primary name for.
- owner: The owner of the reverse node in the Registry. Enter your address.
- resolver: The resolver to use for the reverse node. Enter the default Public Resolver:
0xabac49445584C8b6c1472b030B1076Ac3901D7cf
- name: The primary name to set for the contract. This must be a name that already forward-resolves to the contract address, otherwise Primary Name resolution will not work.
Built-In-Functionality
Here's how to do it:
- A contract that's already up and running assigns a name to its address.
- The person managing the name links an address on vet.domains to the contract.
Example Snippet
This code snippet uses setName()
to assign a fixed name during the setup process.
The name's owner should confirm the name points correctly to ensure it's set up right.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
// from https://docs.vet.domains/Developers/Contracts/
address constant VET_DOMAINS_REVERSE_REGISTRAR = 0x5c970901a587BA3932C835D4ae5FAE2BEa7e78Bc;
interface IReverseRegistrar {
function setName(string memory name) external returns (bytes32);
}
contract VetDomainsReverseExample {
function setReverseName(string calldata name) public {
IReverseRegistrar(VET_DOMAINS_REVERSE_REGISTRAR).setName(name);
}
}
VET_DOMAINS_REVERSE_REGISTRAR
is the Reverse Registrar, you can check the contract addresses on the Contracts page.
Misc.
Example Display
Here's a screenshot showing a contract linked to test.vet
. The the contract's address was also configured in test.vet
to prove ownerships: