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.

This article examines ENSIP-9, which proposes a common mechanism for registering and retrieving addresses on multiple blockchains through ENS, rather than supporting Ethereum alone.

This article translates, summarizes, and expands on the following specification.

I have also written about other EIPs, BIPs, SLIPs, CAIPs, and ENSIPs.

Overview

ENSIP-9 extends the addr field in Ethereum Name Service (ENS) resolvers by introducing an overloaded function (a function with the same name but a different signature). ENS can therefore resolve not only Ethereum addresses but also addresses on other blockchains—that is, retrieve an address from a name. This functionality was originally proposed as ERC-2304.

See the following article for more on ERC-2304.

[ERC2304] Multichain support in ENS

The goal is to let clients look up an address by name through ENS using a consistent method, even for chains other than Ethereum, such as Bitcoin or Litecoin.

Motivation

ENS has been widely used within the Ethereum ecosystem, but multicoin wallets (wallets that can manage assets across several chains) have become increasingly common. Developers of these wallets wanted ENS to resolve addresses on chains other than Ethereum as well.

ENSIP-9 was created in response to that demand. It aims to make ENS more useful for users and developers by standardizing multichain address management so that any client, whether a wallet or another application, can use the same method.

Specification

ENSIP-9 defines new functions and an event for Ethereum Name Service (ENS) resolvers, enabling address resolution for blockchains other than Ethereum. Handling addresses from multiple chains consistently through ENS improves interoperability between wallets and applications.

New function

The following function is added to ENS resolvers.

javascript
function addr(bytes32 node, uint coinType) external view returns(bytes memory);

The function returns the cryptocurrency (token or coin) address associated with the specified node (a name represented by its namehash) and coin type. If there is no address for that coin type, it returns an empty byte sequence. Coin types (coinType) follow the SLIP-44 standard. For example, Ethereum is assigned 60 and Bitcoin is assigned 0. The return value is stored in the chain's native binary format, so textual formatting such as checksums and hyphens is not included.

See the following article for more on SLIP-44.

[SLIP0044] Managing different currencies in HD wallets

The EIP-165 interface ID for this function is 0xf1cb7e06.

New event

The resolver emits the following event whenever address information changes.

javascript
event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);

Applications can detect address updates in ENS, making synchronization easier for wallets and other clients.

The following function is the recommended interface for registering or updating addresses.

javascript
function setAddr(bytes32 node, uint coinType, bytes calldata addr);

The function adds or replaces the address for the specified node and coin type. Every change must emit an AddressChanged event. Implementations may use a different interface, although this one is recommended.

Address encoding

Addresses stored in ENS use each chain's native binary format. In other words, the textual addresses users normally see are decoded before storage. Common formats include the following.

  • P2PKH (Pay to Public Key Hash) This is a classic Bitcoin address format. The Base58Check-encoded address is decoded, and the version byte plus the public key hash are stored. The script format is OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG.

  • P2SH (Pay to Script Hash) This format uses a script hash. After decoding, the version byte plus the script hash are stored. The script format is OP_HASH160 <scriptHash> OP_EQUAL.

  • SegWit (Bech32) This format includes a human-readable part such as bc (Bitcoin mainnet) and is converted into a witness version and a witness program. Incorrect conversion can make funds inaccessible, so care is required.

  • ChecksummedHex (Ethereum and similar chains) Ethereum and Ethereum Classic, among others, use the checksummed hexadecimal format defined by EIP-55. ENS stores the hexadecimal byte sequence without 0x; on retrieval, the address is returned with its checksum applied.

See the following article for more on EIP-55.

[EIP55] Ethereum address checksums

  • Ripple Ripple addresses use a distinct Base58Check encoding, and the decoded byte sequence is stored. There are ordinary r- addresses and tagged X- addresses.

  • CashAddr (Bitcoin Cash) This format uses a variant of Bech32. Addresses with the bitcoincash: prefix are decoded before storage.

  • Bech32 (Binance and similar chains) This format includes a chain-specific human-readable part, such as bnb for Binance addresses. The decoded byte sequence is stored.

Reference implementation

js
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);
    }
}

Variables

ADDR_INTERFACE_ID

javascript
bytes4 constant private ADDR_INTERFACE_ID = 0x3b3b57de;

The EIP-165 interface ID for the original addr(bytes32) interface (retrieving an Ethereum address with an EIP-55 checksum).

For more on EIP-165, see the related article.

This constant declares support for addr(bytes32) through the EIP-165 mechanism. Wallets and DApps can call supportsInterface to determine whether this contract supports the original addr(bytes32) interface.

ADDRESS_INTERFACE_ID

javascript
bytes4 constant private ADDRESS_INTERFACE_ID = 0xf1cb7e06;

The EIP-165 interface ID for the extended addr(bytes32,uint) interface (multichain address retrieval). This constant declares support for addr(bytes32,uint) through EIP-165. Clients can call supportsInterface to determine whether the resolver supports addresses on chains other than Ethereum.

COIN_TYPE_ETH

javascript
uint constant private COIN_TYPE_ETH = 60;

This constant represents Ethereum's coin type (60) under SLIP-44. Multichain support allows ENS to handle addresses from several blockchains through the same mechanism. The coin type (coinType) is the numeric identifier used to distinguish the chains. For Ethereum, the constant 60 is used.

Because many clients and wallets already use ENS, the original Ethereum-specific functions remain available, as shown below.

js
function setAddr(bytes32 node, address a) external authorised(node) {
    setAddr(node, COIN_TYPE_ETH, addressToBytes(a));
}

Although this looks like an Ethereum-only function, internally it invokes the new setAddr(node, uint coinType, bytes addr) mechanism with coinType = 60. Applications using the old interface continue to work while the resolver uses the same multichain storage mechanism internally.

Ethereum-specific functions such as setAddr(bytes32,address) and addr(bytes32) therefore remain as compatibility shortcuts and are designed to use COIN_TYPE_ETH internally.

AddrChanged

javascript
event AddrChanged(bytes32 indexed node, address a);

An event emitted when the Ethereum address of the specified node is updated. This event preserves compatibility with the legacy addr(bytes32)/setAddr(bytes32,address) interfaces. When a multichain address update targets Ethereum (coin type 60), this event is also emitted for compatibility with existing clients.

Parameters

  • node
    • The ENS node represented by its namehash.
    • namehash is a fixed-length identifier (a bytes32 value) obtained by recursively hashing an ENS domain name, such as alice.eth.
  • a
    • The new Ethereum address (type address).

AddressChanged

javascript
event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);

An event emitted when an address for a particular coin type is updated on the specified node. It is the standard event for multichain address support. Because addresses are stored and updated in binary form as bytes for each coinType, updates for any chain can be tracked unambiguously. The resolver must emit this event for every update.

Parameters

  • node
    • The ENS node represented by its namehash.
    • namehash is a fixed-length identifier (a bytes32 value) obtained by recursively hashing an ENS domain name, such as alice.eth.
  • coinType
    • The SLIP-44 coin type number (e.g., 60 for ETH).
  • newAddress
    • The native binary representation of the new address (bytes).

_addresses

javascript
mapping(bytes32=>mapping(uint=>bytes)) _addresses;

Storage for binary addresses indexed by node and coin type. The first key is the bytes32 node (namehash), the second key is the SLIP-44 coinType, and the value is the native binary address (bytes) for that chain. Textual formatting such as checksums is removed before storage.

Functions

setAddr

javascript
function setAddr(bytes32 node, address a) external authorised(node) {
    setAddr(node, COIN_TYPE_ETH, addressToBytes(a));
}

Sets an Ethereum address. This function is compatible with the original setAddr(bytes32,address) interface. Internally, it delegates to the multichain setAddr(bytes32,uint,bytes) function, storing the address under coinType=60 (Ethereum). The authorised(node) modifier checks whether the caller is authorized to update the node passed as an argument.

Arguments

  • node
    • The ENS node represented by its namehash.
  • a
    • The Ethereum address to set (type address).

addr

javascript
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 an Ethereum address. It invokes the multichain addr(bytes32,uint) function with coinType=60 and returns the stored Ethereum address. If no address has been set, it returns the zero address. Although the internal storage format is bytes, the caller receives a value of type address.

Arguments

  • node
    • The ENS node represented by its namehash.

Return value

  • address
    • The configured Ethereum address.
    • address(0) if unset.

setAddr

javascript
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;
}

Sets an address for any coin type. It accepts the SLIP-44 coinType and the native binary address a, then stores the address in the corresponding storage entry. It always emits AddressChanged and, if coinType=60, also emits the legacy AddrChanged event. The authorised(node) modifier checks update permissions.

Arguments

  • node
    • The ENS node represented by its namehash.
  • coinType
    • The SLIP-44 coin type number (e.g., 0 for BTC and 60 for ETH).
  • a
    • The native binary representation of the address (bytes).
    • Textual checksums are not included.

addr

javascript
function addr(bytes32 node, uint coinType) public view returns(bytes memory) {
    return _addresses[node][coinType];
}

Retrieves the binary address for any coin type. It returns the native binary representation (bytes) of the stored address associated with the specified node and coin type. If the address is unset, it returns a zero-length bytes value. The caller can encode the result as a textual address according to the relevant chain's rules when needed.

Arguments

  • node
    • The ENS node represented by its namehash.
  • coinType
    • The SLIP-44 coin type number.

Return value

  • bytes
    • The native binary representation of the stored address.
    • An empty byte sequence if unset.

supportsInterface

javascript
function supportsInterface(bytes4 interfaceID) public pure returns(bool) {
    return interfaceID == ADDR_INTERFACE_ID || interfaceID == ADDRESS_INTERFACE_ID || super.supportsInterface(interfaceID);
}

Checks which EIP-165 interfaces the contract supports. It returns a bool indicating whether the interface is the original addr(bytes32) (ADDR_INTERFACE_ID) or the extended addr(bytes32,uint) (ADDRESS_INTERFACE_ID). For other interface IDs, it calls supportsInterface on the parent contract.

Arguments

  • interfaceID
    • The EIP-165 interface ID (bytes4).

Return value

  • bool
    • true if supported, false otherwise.

Compatibility

Although ENS introduces a new multichain specification, it must preserve compatibility so that applications and wallets using the original mechanism continue to work. In particular, addr(bytes32), defined by ENSIP-1, and addr(bytes32,uint), introduced by ENSIP-9, must behave consistently.

See the following article for more on ENSIP-1.

[ENSIP1] ENS registration and updates

Ethereum addresses

The original addr(bytes32) function was specific to Ethereum addresses. Because Ethereum has coin type 60 under the new specification, the result of addr(node) must agree with that of addr(node, 60). This ensures that old and new implementations return the same Ethereum address.

javascript
// ENSIP1 の呼び出し
addr(node)

// ENSIP9の呼び出し(coinType = 60 は Ethereum)
addr(node, 60)

Both calls must return the same address.

Events

The same principle applies to events. When an Ethereum address changes, both the original AddrChanged event and the new AddressChanged event must be emitted together.

javascript
event AddrChanged(bytes32 indexed node, address a);
event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);

For example, when an Ethereum address is updated, the resolver emits AddrChanged along with AddressChanged with coinType=60. The reverse also applies.

Conclusion

This article covered ENSIP-9, which proposes a common ENS mechanism for registering and retrieving addresses on multiple blockchains, including but not limited to Ethereum. I hope this explanation was useful.

If you have any questions, feel free to contact me by direct message on Twitter.

Twitter @cardene777

You can also find my writing on other platforms.

https://chaldene.net/