Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-4834 proposes a naming system for Ethereum addresses with a goal similar to ENS: replacing addresses with simpler, human-readable names.
This article translates, summarizes, and expands on the following specification.
For other ERCs, see:
Overview
This standard allows contracts to be identified by human-readable names. Its purpose is similar to that of ERC-137, the Ethereum Name Service (ENS). ENS is a system that maps complex Ethereum addresses to simple names.
For more information about ERC-137, see the following article.
[ERC137] Understanding ENS: Mapping Names to Addresses
Under this EIP, certain contracts called domains can be identified by simple names. Users can access contracts through memorable names rather than difficult-to-read addresses or code.
The system also provides sophisticated access control and name resolution. This enables interactions with contracts based on users' roles, permissions, or other conditions. For example, access controls could allow only users with a certain role to call a function such as mint.
The EIP aims to make Ethereum easier to use and more secure through a system for name resolution and access control.
Motivation
The proposal offers several advantages over existing Ethereum standards.
Its principal benefits are a minimal interface for name resolution, standardized access control, and a simple architecture. ENS is useful, but its architecture is more complex, and it does not provide standardized access control of this kind.
In addition, all domains under this EIP, including subdomains, top-level domains (TLDs), and the root itself, are implemented as domains. Name resolution can therefore use a simple iterative algorithm similar to DNS (the Domain Name System).
The proposal offers a simpler and more efficient way to resolve contract names on Ethereum. It makes contracts easier to manage and use, while standardized access control helps improve security and operational management.
Specification
Contract Interface
interface IDomain {
/// @notice Query if a domain has a subdomain with a given name
/// @param name The subdomain to query, in right to left order
/// @return `true` if the domain has a subdomain with the given name, `false` otherwise
function hasDomain(string[] memory name) external view returns (bool);
/// @notice Fetch the subdomain with a given name
/// @dev This should revert if `hasDomain(name)` is `false`
/// @param name The subdomain to fetch, in right to left order
/// @return The subdomain with the given name
function getDomain(string[] memory name) external view returns (address);
}Functions
hasDomain
function hasDomain(string[] memory name) external view returns (bool);Overview
Checks whether the domain has a subdomain with a specified name.
Details
The function determines whether the named subdomain exists within the domain. Subdomain names are specified in right-to-left order.
Parameters
name- The name of the subdomain to query, in right-to-left order.
Return Value
booltrueif the domain has the named subdomain, orfalseotherwise.
getDomain
function getDomain(string[] memory name) external view returns (address);Overview
Retrieves a subdomain with a specified name.
Details
The function should fail if hasDomain(name) returns false. Subdomain names are specified in right-to-left order.
Parameters
name- The name of the subdomain to retrieve, in right-to-left order.
Return Value
address- The address of the named subdomain.
Name Resolution
Name resolution in Ethereum smart contracts maps a domain name such as a.b.c to a particular address.
First, split the name to resolve at each period (.). For example, a.b.c becomes the array ["a", "b", "c"]. Set the current domain to the root domain and initialize an empty path, which records the progress of resolution.
Take the last element of the array, c in this example, and add it to the path. Use domain.hasDomain(path) to check whether the current domain has that subdomain. If not, resolution fails. Otherwise, use domain.getDomain(path) to retrieve the new domain and make it the current domain.
Repeat this process until the array is empty. At each step, take an element, check whether it represents a valid subdomain, and continue to the next subdomain. The result is the address corresponding to the complete domain name.
The example resolve function implements this resolution process in Solidity. It accepts an array containing the split name and a root domain, resolves the name using the procedure above, and returns the corresponding address. This mechanism allows names to be resolved efficiently on Ethereum.
function resolve(string[] calldata splitName, IDomain root) public view returns (address) {
IDomain current = root;
string[] memory path = [];
for (uint i = splitName.length - 1; i >= 0; i--) {
// Append to back of list
path.push(splitName[i]);
// Require that the current domain has a domain
require(current.hasDomain(path), "Name resolution failed");
// Resolve subdomain
current = current.getDomain(path);
}
return current;
}Registration (Optional Extension)
interface IDomainRegisterable is IDomain {
//// Events
/// @notice Must be emitted when a new subdomain is created (e.g. through `createDomain`)
/// @param sender msg.sender for createDomain
/// @param name name for createDomain
/// @param subdomain subdomain in createDomain
event SubdomainCreate(address indexed sender, string name, address subdomain);
/// @notice Must be emitted when the resolved address for a domain is changed (e.g. with `setDomain`)
/// @param sender msg.sender for setDomain
/// @param name name for setDomain
/// @param subdomain subdomain in setDomain
/// @param oldSubdomain the old subdomain
event SubdomainUpdate(address indexed sender, string name, address subdomain, address oldSubdomain);
/// @notice Must be emitted when a domain is unmapped (e.g. with `deleteDomain`)
/// @param sender msg.sender for deleteDomain
/// @param name name for deleteDomain
/// @param subdomain the old subdomain
event SubdomainDelete(address indexed sender, string name, address subdomain);
//// CRUD
/// @notice Create a subdomain with a given name
/// @dev This should revert if `canCreateDomain(msg.sender, name, pointer)` is `false` or if the domain exists
/// @param name The subdomain name to be created
/// @param subdomain The subdomain to create
function createDomain(string memory name, address subdomain) external payable;
/// @notice Update a subdomain with a given name
/// @dev This should revert if `canSetDomain(msg.sender, name, pointer)` is `false` of if the domain doesn't exist
/// @param name The subdomain name to be updated
/// @param subdomain The subdomain to set
function setDomain(string memory name, address subdomain) external;
/// @notice Delete the subdomain with a given name
/// @dev This should revert if the domain doesn't exist or if `canDeleteDomain(msg.sender, name)` is `false`
/// @param name The subdomain to delete
function deleteDomain(string memory name) external;
//// Parent Domain Access Control
/// @notice Get if an account can create a subdomain with a given name
/// @dev This must return `false` if `hasDomain(name)` is `true`.
/// @param updater The account that may or may not be able to create/update a subdomain
/// @param name The subdomain name that would be created/updated
/// @param subdomain The subdomain that would be set
/// @return Whether an account can update or create the subdomain
function canCreateDomain(address updater, string memory name, address subdomain) external view returns (bool);
/// @notice Get if an account can update or create a subdomain with a given name
/// @dev This must return `false` if `hasDomain(name)` is `false`.
/// If `getDomain(name)` is also a domain implementing the subdomain access control extension, this should return `false` if `getDomain(name).canMoveSubdomain(msg.sender, this, subdomain)` is `false`.
/// @param updater The account that may or may not be able to create/update a subdomain
/// @param name The subdomain name that would be created/updated
/// @param subdomain The subdomain that would be set
/// @return Whether an account can update or create the subdomain
function canSetDomain(address updater, string memory name, address subdomain) external view returns (bool);
/// @notice Get if an account can delete the subdomain with a given name
/// @dev This must return `false` if `hasDomain(name)` is `false`.
/// If `getDomain(name)` is a domain implementing the subdomain access control extension, this should return `false` if `getDomain(name).canDeleteSubdomain(msg.sender, this, subdomain)` is `false`.
/// @param updater The account that may or may not be able to delete a subdomain
/// @param name The subdomain to delete
/// @return Whether an account can delete the subdomain
function canDeleteDomain(address updater, string memory name) external view returns (bool);
}Events
SubdomainCreate
event SubdomainCreate(address indexed sender, string name, address subdomain);Overview
An event emitted when a new subdomain is created.
Details
This event is emitted, for example, when a new subdomain is created through createDomain.
Parameters
sender- Address of the sender that called
createDomain.
- Address of the sender that called
name- Name used in
createDomain.
- Name used in
subdomain- Address of the subdomain created by
createDomain.
- Address of the subdomain created by
SubdomainUpdate
event SubdomainUpdate(address indexed sender, string name, address subdomain, address oldSubdomain);Overview
An event emitted when the address to which a domain resolves changes.
Details
This event is emitted, for example, when setDomain changes the resolved address.
Parameters
sender- Address of the sender that called
setDomain.
- Address of the sender that called
name- Name used in
setDomain.
- Name used in
subdomain- Address of the new subdomain specified in
setDomain.
- Address of the new subdomain specified in
oldSubdomain- Address of the previous subdomain.
SubdomainDelete
event SubdomainDelete(address indexed sender, string name, address subdomain);Overview
An event emitted when a domain is unmapped (deleted).
Details
This event is emitted, for example, when a domain is unmapped using deleteDomain.
Parameters
sender- Address of the sender that called
deleteDomain.
- Address of the sender that called
name- Name used in
deleteDomain.
- Name used in
subdomain- Address of the deleted subdomain.
Functions
createDomain
function createDomain(string memory name, address subdomain) external payable;Overview
Creates a subdomain with a specified name.
Details
The function fails if canCreateDomain(msg.sender, name, pointer) returns false or the domain already exists.
Parameters
name- Name of the subdomain to create.
subdomain- Subdomain to create.
setDomain
function setDomain(string memory name, address subdomain) external;Overview
Updates the subdomain associated with a specified name.
Details
The function fails if canSetDomain(msg.sender, name, pointer) returns false or the domain does not exist.
Parameters
name- Name of the subdomain to update.
subdomain- Subdomain to set.
deleteDomain
function deleteDomain(string memory name) external;Overview
Deletes the subdomain associated with a specified name.
Details
The function fails if the domain does not exist or canDeleteDomain(msg.sender, name) returns false.
Parameters
name- Name of the subdomain to delete.
canCreateDomain
function canCreateDomain(address updater, string memory name, address subdomain) external view returns (bool);Overview
Checks whether an account can create a subdomain with a specified name.
Details
The function must return false if hasDomain(name) returns true.
Parameters
updater- Account that may create or update the subdomain.
name- Name of the subdomain to create or update.
subdomain- Subdomain to set.
Return Value
bool- Whether the account can update or create the subdomain.
canSetDomain
function canSetDomain(address updater, string memory name, address subdomain) external view returns (bool);Overview
Checks whether an account can update or create a subdomain with a specified name.
Details
The function must return false if hasDomain(name) returns false.
If getDomain(name) is a domain that implements the subdomain access control extension, the function also returns false when getDomain(name).canMoveSubdomain(msg.sender, this, subdomain) returns false.
Parameters
updater- Account that may create or update the subdomain.
name- Name of the subdomain to create or update.
subdomain- Subdomain to set.
Return Value
bool- Whether the account can update or create the subdomain.
canDeleteDomain
function canDeleteDomain(address updater, string memory name) external view returns (bool);Overview
Checks whether an account can delete a subdomain with a specified name.
Details
The function must return false if hasDomain(name) returns false.
If getDomain(name) is a domain implementing the subdomain access control extension, the function also returns false when getDomain(name).canDeleteSubdomain(msg.sender, this, subdomain) returns false.
Parameters
updater- Account that may delete the subdomain.
name- Name of the subdomain to delete.
Return Value
bool- Whether the account can delete the subdomain.
Enumeration (Optional Extension)
interface IDomainEnumerable is IDomain {
/// @notice Query all subdomains. Must revert if the number of domains is unknown or infinite.
/// @return The subdomain with the given index.
function subdomainByIndex(uint256 index) external view returns (string memory);
/// @notice Get the total number of subdomains. Must revert if the number of domains is unknown or infinite.
/// @return The total number of subdomains.
function totalSubdomains() external view returns (uint256);
}subdomainByIndex
function subdomainByIndex(uint256 index) external view returns (string memory);Overview
Queries the subdomain at a specified index.
Details
Returns the subdomain corresponding to the index. The function must fail if the number of domains is unknown or infinite.
Parameters
index- Index of the subdomain to query.
Return Value
string memory- Subdomain name at the specified index.
totalSubdomains
function totalSubdomains() external view returns (uint256);Overview
Retrieves the total number of subdomains.
Details
Returns the total number of subdomains. The function must fail if the number of domains is unknown or infinite.
Return Value
uint256- Total number of subdomains.
Access Control (Optional Extension)
interface IDomainAccessControl is IDomain {
/// @notice Get if an account can move the subdomain away from the current domain
/// @dev May be called by `canSetDomain` of the parent domain - implement access control here!!!
/// @param updater The account that may be moving the subdomain
/// @param name The subdomain name
/// @param parent The parent domain
/// @param newSubdomain The domain that will be set next
/// @return Whether an account can update the subdomain
function canMoveSubdomain(address updater, string memory name, IDomain parent, address newSubdomain) external view returns (bool);
/// @notice Get if an account can unset this domain as a subdomain
/// @dev May be called by `canDeleteDomain` of the parent domain - implement access control here!!!
/// @param updater The account that may or may not be able to delete a subdomain
/// @param name The subdomain to delete
/// @param parent The parent domain
/// @return Whether an account can delete the subdomain
function canDeleteSubdomain(address updater, string memory name, IDomain parent) external view returns (bool);
}canMoveSubdomain
function canMoveSubdomain(address updater, string memory name, IDomain parent, address newSubdomain) external view returns (bool);Overview
Checks whether an account can move a subdomain from its current domain.
Details
Determines whether an account can move a particular subdomain to a new domain. The parent domain may call this function from canSetDomain, and access control must be implemented here.
Parameters
updater- Account that may move the subdomain.
name- Name of the subdomain.
parent- Parent domain.
newSubdomain- Domain to be set next.
Return Value
bool- Whether the account can update the subdomain.
canDeleteSubdomain
function canDeleteSubdomain(address updater, string memory name, IDomain parent) external view returns (bool);Overview
Checks whether an account can unmap this domain as a subdomain.
Details
Determines whether an account can delete or unmap a particular subdomain. The parent domain may call this function from canDeleteDomain, and access control must be implemented here.
Parameters
updater- Account that may delete the subdomain.
name- Name of the subdomain to delete.
parent- Parent domain.
Return Value
bool- Whether the account can delete the subdomain.
Rationale
The main goal of this EIP is to provide a simple, easy-to-use interface for name resolution.
Characteristics of the Name Resolution Algorithm
Unlike ENS (Ethereum Name Service), name resolution in this proposal is controlled entirely by the contracts involved in the resolution process. This makes the process easier for users to understand and permits flexible designs, such as changing the resolved address according to the time of day.
Parent Domain Access Control
Instead of using a general ownable interface, the proposal adopts a more generic design. A specific ownable implementation can be added separately when needed.
The parent domain can call the access control methods of its subdomains, and subdomains are free to choose their own access control mechanisms.
Subdomain Access Control
Subdomains need not necessarily follow the parent domain's access controls, and the proposal provides methods to implement their own rules.
For example, the root domain might be managed by a DAO using non-transferable tokens, while a TLD (top-level domain) might be managed by a DAO using tokens representing shares.
Domains beneath a TLD could be managed by individual owners, and their subdomains could in turn be managed by individual owners linked to NFTs.
The proposed subdomain access controls can also include an owner override, for example to recover a subdomain if a key is lost.
The EIP aims to provide more flexible and intuitive access control and name resolution for domains and subdomains on a blockchain.
Backward Compatibility
The proposal is generic enough to accommodate specific systems such as ENS. ENS, on the other hand, does not provide the full range of functionality and flexibility offered by this EIP.
The proposal is designed to accommodate a wider variety of use cases and features than ENS.
While this EIP can accommodate a wide range of systems and requirements, including ENS, ENS itself does not cover the same breadth of use cases.
Security Considerations
Malicious canMoveSubdomain (Black Hole)
Description
canMoveSubdomain introduces potential risks when moving a subdomain using setDomain.
Depending on the parent domain's implementation, a new subdomain that unexpectedly returns false from canMoveSubdomain can effectively lock domain ownership in place.
Conversely, a contract that returns true contrary to expectations, as through a backdoor, could allow its owner to take control of the domain.
Mitigation
Clients should warn users when the new subdomain's canMoveSubdomain or canDeleteSubdomain changes to return false.
Because the results of these functions may vary according to circumstances, an audit of the new subdomain's source code is recommended before executing setDomain.
Parent Domain Name Resolution
Description
Parent domains have complete control over the resolution of their subdomains.
For example, if a particular domain is linked to a.b.c, the code of b.c can set a.b.c to any domain, and c can set b.c itself to any domain.
Mitigation
Before acquiring an already-linked domain, audit the relevant contracts and their parent domains all the way to the root.
These are important security considerations when working with domains on a blockchain. Users should understand the risks and mitigate them through appropriate audits.
Citation
Gavin John (@Pandapip1), "ERC-4834: Hierarchical Domains," Ethereum Improvement Proposals, no. 4834, February 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-4834.
Conclusion
ERC-4834 proposes a system similar in purpose to ENS for mapping Ethereum addresses to simple, human-readable names.
If you have questions, feel free to send me a direct message on Twitter.
I also publish material on other platforms:


