ERC-5269 · Review · ERC · 2022-07-15
ERC-5269: ERC Detection and Discovery
Lets a contract answer "do you support ERC-N (and optional feature X) for this caller?" by ERC number instead of an ERC-165 selector hash, and announce support through events.
What problem does it solve?
ERC-165 detects support by an interface ID: the XOR of function selectors. That works, but has gaps:
- Some standards have no functions to hash, e.g. a data format, a signature scheme or soulbound behavior that just reverts transfers.
- The answer cannot depend on who is asking. With proxy patterns (for example the transparent proxy, see ERC-1967), an admin and a normal user may see different behavior.
0x80ac58cdis not human-readable; "721" is.
ERC-5269 is a competing detection scheme keyed by ERC number.
How it works
One view function:
function supportERC(
address caller,
uint256 majorERCIdentifier, // the ERC number, e.g. 721
bytes32 minorERCIdentifier, // 0 = whole ERC; else e.g. keccak256("ERC721Metadata")
bytes calldata extraData // for ERC-5750 extensions
) external view returns (bytes32 ercStatus);
and one event:
event OnSupportERC(address indexed caller, uint256 indexed majorERCIdentifier,
bytes32 indexed minorERCIdentifier, bytes32 ercStatus, bytes extraData);
Rules:
ercStatusiskeccak256("FINAL")for Final ERCs. For non-Final ERCs it must not beFINAL;keccak256("DRAFT")or an author-defined value such askeccak256("DRAFTv1")is used.0means "not supported".- A contract must answer for 5269 itself, returning
keccak256("DRAFTv1")at the current version. - Contracts should emit
OnSupportERC(address(0), 5269, 0, ...)at deployment or upgrade, and may emit more events so indexers can discover support without calls.caller = address(0)means all callers. minorERCIdentifierlets each ERC's authors name optional features or versions.
Sample code
Querying support (ethers v6):
import { Contract, JsonRpcProvider, ZeroHash, id } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const c = new Contract(process.env.CONTRACT!, [
"function supportERC(address caller, uint256 major, bytes32 minor, bytes extraData) view returns (bytes32)",
], provider);
const me = "0xYourAddress";
const status = await c.supportERC(me, 721n, id("ERC721Metadata"), "0x");
if (status === id("FINAL")) console.log("supports ERC721Metadata (Final)");
else if (status === ZeroHash) console.log("not supported");
else console.log("supported, non-final status:", status);
Things to know
- Status is Review; the in-spec status value
DRAFTv1reflects that. - It requires ERC-5750 for the
extraDataparameter. - As with ERC-165, a contract claiming support may not implement it correctly; verify behavior rather than trusting the answer.
- ERC-165 remains the widely deployed mechanism; tooling and wallets are unlikely to query
supportERCunless you integrate it yourself.