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-2304 extends the Ethereum Name Service (ENS) to resolve addresses on blockchains other than Ethereum.
This article translates, summarizes, and expands on the following specification.
More EIP explainers:
Overview
ERC-2304 adds a new argument format to the ENS resolver's addr interface so that ENS can resolve addresses for different blockchains, rather than Ethereum alone.
Motivation
As multicurrency wallets have become more common, ENS needs to accommodate addresses on other chains. Wallet developers have requested a consistent way to resolve these addresses using ENS.
ERC-2304 standardizes how clients register and retrieve non-Ethereum addresses.
Specification
Functions
ERC-2304 introduces the following resolver functions.
addr
function addr(bytes32 node, uint coinType) public view returns (bytes memory) {
return _addresses[node][coinType];
}Retrieves an address for an arbitrary coin type. Given an ENS node (node) and a cryptocurrency identifier (coinType), the function returns the corresponding address in binary form.
The coin type identifier follows SLIP-0044. An unset address is represented by an empty byte string.
The EIP-165 interface ID is 0xf1cb7e06.
For EIP-165, see the following article.
ERC-165: Detecting whether a contract supports an interface
Parameters
node- The ENS node to query.
coinType- The cryptocurrency identifier defined by SLIP-0044.
Return value
bytes- The corresponding binary address.
setAddr
function setAddr(bytes32 node, uint coinType, bytes memory a) public authorised(node) {
emit AddressChanged(node, coinType, a);
if (coinType == COIN_TYPE_ETH) {
emit AddrChanged(node, bytesToAddress(a));
}
_addresses[node][coinType] = a;
}Registers or updates the address associated with a given ENS node and coin type. For Ethereum (60), the function also emits the legacy AddrChanged event.
Parameters
node- The ENS node whose address is being set.
coinType- The SLIP-0044 coin type.
a- The binary address to register.
Events
The following event is introduced.
AddressChanged
event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);Emitted when an address associated with a specific coin type changes. It records changes to cryptocurrency addresses linked to an ENS node using the new multichain format.
Parameters
node- The namehash of the ENS name.
coinType- The SLIP-0044 coin type.
newAddress- The newly configured binary address.
Binary address formats and encoding
Addresses stored in ENS must use the relevant blockchain's native binary representation rather than the usual human-readable checksummed text.
The following table summarizes representative coin types and their textual encodings.
| Cryptocurrency | Coin Type | Encoding |
|---|---|---|
| Bitcoin | 0 | P2PKH (0x00), P2SH (0x05), SegWit (Bech32 with bc) |
| Ethereum | 60 | ChecksummedHex (EIP-55) |
| Litecoin | 2 | P2PKH (0x30), P2SH (0x32, 0x05), SegWit (ltc) |
| Dogecoin | 3 | P2PKH (0x1e), P2SH (0x16) |
| Ethereum Classic | 61 | ChecksummedHex |
| Rootstock | 137 | ChecksummedHex (RSKIP-60) |
| Ripple | 144 | Base58Check or X-address (with tag) |
| Bitcoin Cash | 145 | CashAddr (Bech32-derived) |
| Binance Chain | 714 | Bech32 (prefix bnb) |
Address formats in detail
-
P2PKH / P2SH
Used by Bitcoin and similar cryptocurrencies. The Base58Check address representation contains a version byte and a 20-byte hash, excluding the checksum.
-
SegWit (Bech32)
Based on a witness version and witness program. The textual representation contains a human-readable prefix such as
bcand a machine-readable data part. -
ChecksummedHex
Used by Ethereum-family chains. Removing the
0xprefix and decoding the hexadecimal string produces 20 bytes. Clients can warn or reject addresses that do not meet the relevant checksum conventions (EIP-55 or RSKIP-60). -
Ripple
Uses a chain-specific Base58Check encoding, including formats such as the r-address and X-address.
-
CashAddr (Bitcoin Cash)
A Bech32-derived format for Bitcoin Cash that represents address types such as P2PKH and P2SH.
-
Bech32 (Binance and others)
Uses a human-readable prefix such as
bnband an encoded binary payload.
Note that textual address decoding and the binary representation stored by the ENS resolver are not necessarily identical. For example, Bitcoin-family addresses use the corresponding output script representation under ERC-2304. Implementations should follow the coin-specific encoding rules in the specification.
Example implementation
pragma solidity ^0.5.8;
contract AddrResolver is ResolverBase {
bytes4 constant private ADDR_INTERFACE_ID = 0x3b3b57de;
bytes4 constant private ADDRESS_INTERFACE_ID = 0xf1cb7e06;
uint constant private COIN_TYPE_ETH = 60;
event AddrChanged(bytes32 indexed node, address a);
event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);
mapping(bytes32=>mapping(uint=>bytes)) _addresses;
/**
* Sets the address associated with an ENS node.
* May only be called by the owner of that node in the ENS registry.
* @param node The node to update.
* @param a The address to set.
*/
function setAddr(bytes32 node, address a) external authorised(node) {
setAddr(node, COIN_TYPE_ETH, addressToBytes(a));
}
/**
* Returns the address associated with an ENS node.
* @param node The ENS node to query.
* @return The associated address.
*/
function addr(bytes32 node) public view returns (address) {
bytes memory a = addr(node, COIN_TYPE_ETH);
if(a.length == 0) {
return address(0);
}
return bytesToAddress(a);
}
function setAddr(bytes32 node, uint coinType, bytes memory a) public authorised(node) {
emit AddressChanged(node, coinType, a);
if(coinType == COIN_TYPE_ETH) {
emit AddrChanged(node, bytesToAddress(a));
}
_addresses[node][coinType] = a;
}
function addr(bytes32 node, uint coinType) public view returns(bytes memory) {
return _addresses[node][coinType];
}
function supportsInterface(bytes4 interfaceID) public pure returns(bool) {
return interfaceID == ADDR_INTERFACE_ID || interfaceID == ADDRESS_INTERFACE_ID || super.supportsInterface(interfaceID);
}
}- Retains
addr(bytes32)as a shortcut for Ethereum addresses (coinType = 60). - Uses
mapping(bytes32 => mapping(uint => bytes))to store addresses by node and coin type. - Emits
AddressChangedwheneversetAddrregisters an address. - Implements EIP-165 interface detection through
supportsInterface.
ADDR_INTERFACE_ID
bytes4 constant private ADDR_INTERFACE_ID = 0x3b3b57de;The interface ID of the legacy ENS addr(bytes32) function. EIP-165-compatible supportsInterface implementations use this identifier to indicate support for retrieving Ethereum addresses.
ADDRESS_INTERFACE_ID
bytes4 constant private ADDRESS_INTERFACE_ID = 0xf1cb7e06;The interface ID of the multicurrency addr(bytes32,uint) function. It identifies resolvers supporting multichain addresses through EIP-165.
COIN_TYPE_ETH
uint constant private COIN_TYPE_ETH = 60;The constant identifying Ethereum's coin type. SLIP-0044 assigns Ethereum coin type 60.
AddrChanged
event AddrChanged(bytes32 indexed node, address a);Emitted when an Ethereum address changes. This event supports the legacy addr(bytes32) interface defined by ERC-137.
For ERC-137, see the following article.
ERC-137: Understanding the Ethereum Name Service
Parameters
node- The namehash of the ENS name.
a- The Ethereum address.
_addresses
mapping(bytes32 => mapping(uint => bytes)) _addresses;A mapping that stores addresses by ENS node and coin type. Accessing _addresses[node][coinType] allows the resolver to retrieve or store the binary address for a given currency.
addr
function addr(bytes32 node) public view returns (address) {
bytes memory a = addr(node, COIN_TYPE_ETH);
if (a.length == 0) {
return address(0);
}
return bytesToAddress(a);
}Retrieves the Ethereum address associated with an ENS node. The legacy addr(bytes32) function retrieves the binary address for coin type 60 and decodes it into an Ethereum address.
Parameters
node- The ENS node whose Ethereum address is requested.
Return value
address- The associated Ethereum address, or
address(0)if no address is registered.
- The associated Ethereum address, or
setAddr
function setAddr(bytes32 node, address a) external authorised(node) {
setAddr(node, COIN_TYPE_ETH, addressToBytes(a));
}Sets an Ethereum address for a given ENS node using coin type 60. It converts the address to bytes and calls the multicurrency setAddr function.
Parameters
node- The ENS node to update.
a- The Ethereum address to register.
supportsInterface
function supportsInterface(bytes4 interfaceID) public pure returns (bool) {
return interfaceID == ADDR_INTERFACE_ID || interfaceID == ADDRESS_INTERFACE_ID || super.supportsInterface(interfaceID);
}Determines whether the contract supports a particular interface. Following EIP-165, it checks support for both the original addr(bytes32) and the ERC-2304 addr(bytes32,uint) interface.
Parameters
interfaceID- A four-byte interface identifier.
Return value
booltrueif the interface is supported; otherwisefalse.
Compatibility
ERC-2304 maintains compatibility with the addr(bytes32) interface defined by EIP-137. Existing resolvers implementing the new specification must satisfy the following conditions:
addr(bytes32 node)must return the same Ethereum address as the decoded result ofaddr(bytes32 node, uint coinType)withcoinType = 60, accounting for the representation of unset addresses.- An operation emitting the EIP-137
AddrChangedevent must also emit the ERC-2304AddressChangedevent with coin type 60. - Conversely, an
AddressChangedevent for coin type 60 must be accompanied byAddrChanged.
This design allows existing ENS users and tools to adopt multicurrency resolution without losing compatibility with Ethereum address resolution.
Citation
Nick Johnson nick@ens.domains, "ERC-2304: Multichain address resolution for ENS [DRAFT]," Ethereum Improvement Proposals, no. 2304, September 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2304.
Conclusion
ERC-2304 allows ENS to resolve addresses from blockchains beyond Ethereum while retaining the existing Ethereum address interface.
Questions are welcome via Twitter @cardene777.
Other publications:



