ERC-926 · Stagnant · ERC · 2018-03-12
ERC-926: Address metadata registry
Proposed one shared registry where any address points to a 'provider' contract that serves metadata about it, instead of every standard deploying its own registry; it is Stagnant.
What problem does it solve?
More and more standards needed to attach information to an address: which tokens it accepts (ERC-777), claims about it, or its human-readable name (ERC-181). Each one shipped its own specialised registry contract, and the number kept growing.
ERC-926 proposes a single, generic "address metadata registry". Every address, contract or EOA, can register one provider contract, and that provider answers any metadata question about the address.
How it works
The registry is tiny:
interface AddressMetadataRegistry {
function provider(address target) external view returns (address);
function setProvider(address _provider) external;
}
setProvider records a provider for msg.sender; provider(target) returns it. The plan was to compile it with an agreed Solidity version and deploy it with a trustless deployment mechanism so it has the same address on every chain.
Providers do the real work:
- They must implement ERC-165
supportsInterface, returning true for0x01ffc9a7and for every metadata interface they support. - The first argument of every provider function is the address being queried, so one provider contract can serve many users.
- If a metadata type needs several functions, a provider implements all of them or none, and throws on unknown function IDs.
- New metadata types are defined by future EIPs; the spec's table of standard interfaces is empty.
The design uses indirection instead of a generic key/value store. It costs an extra call, but lets each metadata type define its own functions and logic.
Sample code
Looking up metadata through the registry (Solidity sketch, with a hypothetical metadata interface):
interface IERC165 { function supportsInterface(bytes4 id) external view returns (bool); }
interface IRegistry { function provider(address target) external view returns (address); }
// Hypothetical metadata type defined by some future EIP
interface IAcceptsToken {
function acceptsToken(address target, address token) external view returns (bool);
}
function accepts(IRegistry reg, address target, address token) view returns (bool) {
address p = reg.provider(target);
if (p == address(0)) return false;
if (!IERC165(p).supportsInterface(IAcceptsToken.acceptsToken.selector)) return false;
return IAcceptsToken(p).acceptsToken(target, token);
}
Things to know
- This proposal is Stagnant and was never adopted. No canonical registry address was published, and no metadata interfaces were standardized under it.
- The interface-detection problem it targets was largely solved in practice by ERC-820 and its successor ERC-1820, which map an address plus interface name to an implementer contract.
- Because each address has exactly one provider, adding a new kind of metadata means switching to (or upgrading) a provider that supports both old and new types.
- The reference implementation in the spec is only a
mapping(address => address)with a setter. All the logic lives in providers.