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 ERC-5269, a proposed interface for discovering whether a contract supports the functions or other behavior specified by an ERC for a given caller.
The explanation translates, summarizes, and expands on the specification linked below.
As of October 25, 2023, the date of the original article's status check, ERC-5269 was in Review. This is a historical status, not a statement of its current status.
I also cover a range of other ERCs.
Overview
This interface introduces a new approach to identifying and discovering Ethereum Requests for Comments, commonly abbreviated as ERCs.
It defines a field called majorERCIdentifier that identifies what is commonly known as an ERC number, such as ERC-721 or ERC-20.
For example, ERC-721 uses majorERCIdentifier = 721.
Similarly, ERC-5269 uses majorERCIdentifier = 5269.
The term majorERCIdentifier leaves room for future identification schemes that do not use ERC numbers and for the inclusion of other kinds of standards.
The proposal also introduces minorERCIdentifier, which authors of individual ERCs can define.
For example, the authors of ERC-721 could define minorERCIdentifier = keccak256("ERC721Metadata").
The proposal also defines an event through which smart contracts can announce the ERCs they support.
This mechanism is intended to accommodate future changes and new standards flexibly, improving ERC identification and interoperability.
Motivation
The proposal was developed as an alternative to ERC-165.
For background on ERC-165, see the following article.
[ERC-165] How to Check Whether a Contract Supports an Interface
The principal differences between this proposal and ERC-165 are as follows.
Declaring the Presence of Methods
ERC-165 uses hashes of method signatures to identify an interface containing one or more methods. This approach requires at least one method to identify the behavior in question. ERC-5269 can also cover standards that need no particular method, such as data formats, signature schemes, or soulbound behavior (SBTs).
Caller-Specific Queries
ERC-165 does not define an explicit caller-specific query interface. A contract conforming to ERC-5269 can instead report whether it supports a particular ERC for a specified caller.
The following considerations motivate the proposal.
ERC numbers are easy for people to understand and simplify work involving named contracts, such as those identified through ENS.
There is growing interest in identifying or specifying ERC numbers rather than ERC-165 identifiers.
For instance, ERC-5267 specifies extensions as a list of ERC numbers.
ERC-600 and ERC-601 specify an ERC number in the path m/purpose'/subpurpose'/ERC'/wallet'.
ERC-5568 requires Instruction_id to be specified as an ERC number.
For background on ERC-5568, see the following article.
[ERC-5568] Notifying Wallets That an Action Is Required
ERC-6120 specifies struct Token { uint eip; ... }, where uint eip is an ERC number identifying the standard.
ERC-867, described as stagnant at the time of writing, proposes an erpId that could be an ERC number associated with an Ethereum Recovery Proposal (ERP), such as ERC-1234.
An ERC or ERC-number discovery interface reduces the need for lookup tables mapping method or interface identifiers from ERC-165's bytes4 values to their respective ERC numbers, and considerably simplifies the way a contract declares standardized behavior.
A contract may also behave differently for different caller accounts. A notable example is the transparent upgradeable proxy pattern, where the proxy can handle calls from the admin differently from calls from non-admin accounts.
Specification
The original specification uses the terms EIP and ERC interchangeably in the discussion that follows. Most of the discussion applies to the ERC category of the standards track, but ERC numbers occupy part of the broader EIP number space. Some EIPs outside the ERC category may therefore define behavior worth querying as well.
A conforming smart contract must implement the following interface.
// DRAFTv1
pragma solidity ^0.8.9;
interface IERC5269 {
event OnSupportERC(
address indexed caller, // when emitted with `address(0x0)` means all callers.
uint256 indexed majorERCIdentifier,
bytes32 indexed minorERCIdentifier, // 0 means the entire ERC
bytes32 ercStatus,
bytes extraData
);
/// @dev The core method of ERC Interface Detection
/// @param caller, a `address` value of the address of a caller being queried whether the given ERC is supported.
/// @param majorERCIdentifier, a `uint256` value and SHOULD BE the ERC number being queried. Unless superseded by future ERC, such ERC number SHOULD BE less or equal to (0, 2^32-1]. For a function call to `supportERC`, any value outside of this range is deemed unspecified and open to implementation's choice or for future ERCs to specify.
/// @param minorERCIdentifier, a `bytes32` value reserved for authors of individual ERC to specify. For example the author of [ERC-721](/ERCS/eip-721) MAY specify `keccak256("ERC721Metadata")` or `keccak256("ERC721Metadata.tokenURI")` as `minorERCIdentifier` to be quired for support. Author could also use this minorERCIdentifier to specify different versions, such as ERC-712 has its V1-V4 with different behavior.
/// @param extraData, a `bytes` for [ERC-5750](/ERCS/eip-5750) for future extensions.
/// @return ercStatus, a `bytes32` indicating the status of ERC the contract supports.
/// - For FINAL ERCs, it MUST return `keccak256("FINAL")`.
/// - For non-FINAL ERCs, it SHOULD return `keccak256("DRAFT")`.
/// During ERC procedure, ERC authors are allowed to specify their own
/// ercStatus other than `FINAL` or `DRAFT` at their discretion such as `keccak256("DRAFTv1")`
/// or `keccak256("DRAFT-option1")`and such value of ercStatus MUST be documented in the ERC body
function supportERC(
address caller,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata extraData)
external view returns (bytes32 ercStatus);
}OnSupportERC
event OnSupportERC(
address indexed caller, // when emitted with `address(0x0)` means all callers.
uint256 indexed majorERCIdentifier,
bytes32 indexed minorERCIdentifier, // 0 means the entire ERC
bytes32 ercStatus,
bytes extraData
);Overview
An event emitted to announce support for an ERC, including the ERC-5269 status represented by ERC_5269_STATUS.
Parameters
caller- The caller address.
- Identifies the caller to which the declared support applies, rather than necessarily the account that emitted the event.
address(0x0)indicates all callers.
majorERCIdentifier- Major ERC identifier.
- Identifies the standard for which support is declared, such as ERC-5269.
minorERCIdentifier- Minor ERC identifier.
- No minor identifiers are used for ERC-5269 itself in this example.
- A value of
0indicates the main behavior of the ERC.
ercStatus- A byte value indicating the ERC's status.
- Represents the status of the ERC supported by the contract.
extraData- Additional data.
- Unused in this example.
In the historical draft described above, ERC_5269_STATUS is set to keccak256("DRAFTv1").
In addition to the behavior specified in the comments of IERC5269, the following requirements apply.
- A
minorERCIdentifierof zero is reserved for the main behavior of the queried ERC. - Authors of conforming ERCs are encouraged to declare optional interfaces, behaviors, and reserved value ranges for future extensions.
- When this ERC reaches FINAL, conforming contracts must return
ERC_5269_STATUSin response tosupportERC(anyCaller, 5269, 0, []). In the draft described here, a call tosupportERC(anyCaller, 5269, 0, [])must also returnERC_5269_STATUS.
The specification also includes the following requirements.
- A conforming contract should emit
OnSupportERC(address(0), 5269, 0, ERC_5269_STATUS, [])when constructed or upgraded. - A conforming contract may make the main or subordinate behavior of any ERC discoverable by emitting
OnSupportERCwith the relevant values. It may also emit the event when it changes whether an ERC or particular behavior is supported for a specific caller or all callers. - A query of the form
supportERC(anyCaller, xxx, anyMinorIdentifier, [])for a non-FINAL ERC-XXX must not returnkeccak256("FINAL"). Returning0is recommended in that case, but other values ofercStatusare permitted. The caller must treat returned values other thankeccak256("FINAL")as non-FINAL and interpret zero strictly as unsupported. - The
supportERCfunction must have view mutability and must not modify global EVM state.
These requirements define how ERC-5269 and related interfaces are implemented and provide a mechanism for contract interactions and discovery queries.
Rationale
When selecting the uint256 type for majorERCIdentifier, several alternative identification schemes were considered.
There are three principal options.
- Use a hash of the ERC number.
- Use the raw number.
- Use the ERC-165 identifier.
The advantage of option 1 is that it could accommodate future changes to ERC numbering or naming conventions. The disadvantage is that it would not preserve the direct readability of existing numbers: given the hash of an ERC number, a person generally cannot infer the original number easily.
For the reasons given in the motivation, the proposal selects option 2, the raw number.
The design uses bytes32 for minorERCIdentifier.
An alternative would be to use numeric identifiers and require every ERC author to assign numbers to subordinate behaviors. Instead, the proposal uses bytes32 and asks authors to hash the string name of each subordinate behavior, since interface and method names are already defined in their specifications.
Other possibilities include returning additional data or an array of every supported ERC, but it is unclear whether the extra complexity would provide enough value to justify the overhead.
Compared with ERC-165, the proposal adds an explicit caller address input to accommodate the growing use of proxy patterns enabled by specifications such as ERC-1967.
Why not simply use msg.sender?
An explicit input permits queries about a particular sender without requiring a transaction from that account or an intermediary proxy contract.
For background on ERC-1967, see the following article.
[ERC-1967] Understanding Contract Upgrades and Proxy Storage Slots
Finally, values of majorERCIdentifier greater than or equal to 2^32 are reserved to accommodate possible future collections of standards beyond EIPs and ERCs.
Tests
describe("ERC5269", function () {
async function deployFixture() {
// ...
}
describe("Deployment", function () {
// ...
it("Should emit proper OnSupportERC events", async function () {
let { txDeployErc721 } = await loadFixture(deployFixture);
let events = txDeployErc721.events?.filter(event => event.event === 'OnSupportERC');
expect(events).to.have.lengthOf(4);
let ev5269 = events!.filter(
(event) => event.args!.majorERCIdentifier.eq(5269));
expect(ev5269).to.have.lengthOf(1);
expect(ev5269[0].args!.caller).to.equal(BigNumber.from(0));
expect(ev5269[0].args!.minorERCIdentifier).to.equal(BigNumber.from(0));
expect(ev5269[0].args!.ercStatus).to.equal(ethers.utils.id("DRAFTv1"));
let ev721 = events!.filter(
(event) => event.args!.majorERCIdentifier.eq(721));
expect(ev721).to.have.lengthOf(3);
expect(ev721[0].args!.caller).to.equal(BigNumber.from(0));
expect(ev721[0].args!.minorERCIdentifier).to.equal(BigNumber.from(0));
expect(ev721[0].args!.ercStatus).to.equal(ethers.utils.id("FINAL"));
expect(ev721[1].args!.caller).to.equal(BigNumber.from(0));
expect(ev721[1].args!.minorERCIdentifier).to.equal(ethers.utils.id("ERC721Metadata"));
expect(ev721[1].args!.ercStatus).to.equal(ethers.utils.id("FINAL"));
// ...
});
it("Should return proper ercStatus value when called supportERC() for declared supported ERC/features", async function () {
let { erc721ForTesting, owner } = await loadFixture(deployFixture);
expect(await erc721ForTesting.supportERC(owner.address, 5269, ethers.utils.hexZeroPad("0x00", 32), [])).to.equal(ethers.utils.id("DRAFTv1"));
expect(await erc721ForTesting.supportERC(owner.address, 721, ethers.utils.hexZeroPad("0x00", 32), [])).to.equal(ethers.utils.id("FINAL"));
expect(await erc721ForTesting.supportERC(owner.address, 721, ethers.utils.id("ERC721Metadata"), [])).to.equal(ethers.utils.id("FINAL"));
// ...
expect(await erc721ForTesting.supportERC(owner.address, 721, ethers.utils.id("WRONG FEATURE"), [])).to.equal(BigNumber.from(0));
expect(await erc721ForTesting.supportERC(owner.address, 9999, ethers.utils.hexZeroPad("0x00", 32), [])).to.equal(BigNumber.from(0));
});
it("Should return zero as ercStatus value when called supportERC() for non declared ERC/features", async function () {
let { erc721ForTesting, owner } = await loadFixture(deployFixture);
expect(await erc721ForTesting.supportERC(owner.address, 721, ethers.utils.id("WRONG FEATURE"), [])).to.equal(BigNumber.from(0));
expect(await erc721ForTesting.supportERC(owner.address, 9999, ethers.utils.hexZeroPad("0x00", 32), [])).to.equal(BigNumber.from(0));
});
});
});See the following source file for details.
https://eips.ethereum.org/assets/eip-5269/test/TestERC5269.ts
Reference Implementation
contract ERC5269 is IERC5269 {
bytes32 constant public ERC_STATUS = keccak256("DRAFTv1");
constructor () {
emit OnSupportERC(address(0x0), 5269, bytes32(0), ERC_STATUS, "");
}
function _supportERC(
address /*caller*/,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata /*extraData*/)
internal virtual view returns (bytes32 ercStatus) {
if (majorERCIdentifier == 5269) {
if (minorERCIdentifier == bytes32(0)) {
return ERC_STATUS;
}
}
return bytes32(0);
}
function supportERC(
address caller,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata extraData)
external virtual view returns (bytes32 ercStatus) {
return _supportERC(caller, majorERCIdentifier, minorERCIdentifier, extraData);
}
}ERC_STATUS
bytes32 constant public ERC_STATUS = keccak256("DRAFTv1");Overview
A constant identifying the ERC-5269 status supported by the contract.
Details
The constant is a fixed byte value obtained by hashing the string DRAFTv1. It identifies the ERC-5269 status declared by the contract in this historical implementation. This value does not change and represents a common status throughout the contract.
_supportERC
function _supportERC(
address /*caller*/,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata /*extraData*/)
internal virtual view returns (bytes32 ercStatus) {
if (majorERCIdentifier == 5269) {
if (minorERCIdentifier == bytes32(0)) {
return ERC_STATUS;
}
}
return bytes32(0);
}Overview
A function that checks whether the contract supports the ERC-5269 status.
Details
The internal function uses the supplied major and minor identifiers to retrieve the ERC status. When the major identifier is 5269 and the minor identifier is zero, the ERC-5269 status is returned. Otherwise, it returns zero.
Parameters
majorERCIdentifier- Major ERC identifier.
- Used to identify the standard whose support is being checked.
minorERCIdentifier- Minor ERC identifier.
- No subordinate ERC-5269 behavior is defined in this example; the function checks whether the identifier is zero.
extraData- Additional data.
- Unused in this implementation.
Return value
ercStatus- Returns the declared ERC-5269 status or zero.
supportERC
function supportERC(
address caller,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata extraData)
external virtual view returns (bytes32 ercStatus) {
return _supportERC(caller, majorERCIdentifier, minorERCIdentifier, extraData);
}Overview
A function that checks whether the contract supports the ERC-5269 status.
Details
It retrieves the ERC status using the supplied major and minor identifiers.
It calls the internal _supportERC function and returns its result.
Parameters
caller- Caller address.
- The account whose support is being queried, which need not be the account making this query.
majorERCIdentifier- Major ERC identifier.
- Used to identify the standard whose support is being checked.
minorERCIdentifier- Minor ERC identifier.
- No subordinate ERC-5269 behavior is defined in this example.
extraData- Additional data.
- Unused in this implementation.
Return value
ercStatus- Returns the declared ERC-5269 status or zero.
See the following source file for details.
https://eips.ethereum.org/assets/eip-5269/contracts/ERC5269.sol
The following example shows an ERC-721 contract implementing this ERC to facilitate detection and discovery.
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "../ERC5269.sol";
contract ERC721ForTesting is ERC721, ERC5269 {
bytes32 constant public ERC_FINAL = keccak256("FINAL");
constructor() ERC721("ERC721ForTesting", "E721FT") ERC5269() {
_mint(msg.sender, 0);
emit OnSupportERC(address(0x0), 721, bytes32(0), ERC_FINAL, "");
emit OnSupportERC(address(0x0), 721, keccak256("ERC721Metadata"), ERC_FINAL, "");
emit OnSupportERC(address(0x0), 721, keccak256("ERC721Enumerable"), ERC_FINAL, "");
}
function supportERC(
address caller,
uint256 majorERCIdentifier,
bytes32 minorERCIdentifier,
bytes calldata extraData)
external
override
view
returns (bytes32 ercStatus) {
if (majorERCIdentifier == 721) {
if (minorERCIdentifier == 0) {
return keccak256("FINAL");
} else if (minorERCIdentifier == keccak256("ERC721Metadata")) {
return keccak256("FINAL");
} else if (minorERCIdentifier == keccak256("ERC721Enumerable")) {
return keccak256("FINAL");
}
}
return super._supportERC(caller, majorERCIdentifier, minorERCIdentifier, extraData);
}
}See the following source file for details.
https://eips.ethereum.org/assets/eip-5269/contracts/testing/ERC721ForTesting.sol
Security Considerations
As with ERC-165, callers of this interface must assume that a smart contract declaring support for a particular ERC does not necessarily implement its behavior correctly.
A contract may declare support for an ERC interface without actually conforming to it. Callers are responsible for assessing the contract's actual support.
References
Zainan Victor Zhou (@xinbenlv), "ERC-5269: ERC Detection and Discovery [DRAFT]," Ethereum Improvement Proposals, no. 5269, July 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5269.
Conclusion
This article examined ERC-5269, which proposes an interface for discovering whether a contract supports ERC-defined functions or other behavior for a specified caller. The interface supports discovery by major and minor identifiers without limiting standards to function signatures.
If you have questions, feel free to contact me through a direct message on Twitter.
I also publish content on the following platforms.


