From e31dae63b4cb0361050ca6d711e322201aefc4a7 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Mon, 12 Mar 2018 12:33:17 +0000 Subject: [PATCH 1/2] Create EIP-X-metadata-nickjohnson.md --- EIPS/EIP-X-metadata-nickjohnson.md | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 EIPS/EIP-X-metadata-nickjohnson.md diff --git a/EIPS/EIP-X-metadata-nickjohnson.md b/EIPS/EIP-X-metadata-nickjohnson.md new file mode 100644 index 0000000000000..364d3f472f37a --- /dev/null +++ b/EIPS/EIP-X-metadata-nickjohnson.md @@ -0,0 +1,72 @@ +## Preamble + + EIP: + Title: Address metadata registry + Author: Nick Johnson + Type: Standard track + Category: ERC + Status: Draft + Created: 2018-03-12 + +## Abstract +This EIP specifies a registry for address metadata, permitting both contracts and external accounts to supply metadata about themselves to onchain and offchain callers. This permits use-cases such as generalised authorisations, providing token acceptance settings, and claims registries. + +## Motivation +An increasing set of use cases require storage of metadata associated with an address; see for instance EIP 777 and EIP 780, and the ENS reverse registry in EIP 181. Presently each use-case defines its own specialised registry. To prevent a proliferation of special-purpose registry contracts, we instead propose a single standardised registry using an extendable architecture that allows future standards to implement their own metadata standards. + +## Specification +The metadata registry has the following interface: +``` +interface AddressMetadataRegistry { + function provider(address target) view returns(address); + function setProvider(address _provider); +} +``` + +`setProvider` specifies the metadata registry to be associated with the caller's address, while `provider` returns the address of the metadata registry for the supplied address. + +The metadata registry will be compiled with an agreed-upon version of Solidity and deployed using the trustless deployment mechanism to a fixed address that can be replicated across all chains. + +## Provider specification + +Providers may implement any subset of the metadata record types specified here. Where a record types specification requires a provider to provide multiple functions, the provider MUST implement either all or none of them. Providers MUST throw if called with an unsupported function ID. + +Providers have one mandatory function: + +``` +function supportsInterface(bytes4 interfaceID) constant returns (bool) +``` + +The `supportsInterface` function is documented in [EIP 165](https://github.com/ethereum/EIPs/issues/165), and returns true if the provider implements the interface specified by the provided 4 byte identifier. An interface identifier consists of the XOR of the function signature hashes of the functions provided by that interface; in the degenerate case of single-function interfaces, it is simply equal to the signature hash of that function. If a provider returns `true` for `supportsInterface()`, it must implement the functions specified in that interface. + +`supportsInterface` must always return true for `0x01ffc9a7`, which is the interface ID of `supportsInterface` itself. + +The first argument to all provider functions MUST be the address being queried; this facilitates the creation of multi-user provider contracts. + +Currently standardised provider interfaces are specified in the table below. + +| Interface name | Interface hash | Specification | +| --- | --- | --- | + +EIPs may define new interfaces to be added to this registry. + +## Rationale +There are two obvious approaches for a generic metadata registry: the indirection approach employed here, or a generalised key/value store. While indirection incurs the cost of an additional contract call, and requires providers to change over time, it also provides for significantly enhanced flexibility over a key/value store; for that reason we selected this approach. + +## Backwards Compatibility +There are no backwards compatibility concerns. + +## Implementation +The canonical implementation of the metadata registry is as follows: +``` +contract AddressMetadataRegistry { + mapping(address=>address) public provider; + + function setProvider(address _provider) { + provider[msg.sender] = _provider; + } +} +``` + +## Copyright +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From de3a3bcc248a44ffa0149feefca86c9e0e74ccc5 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Mon, 12 Mar 2018 14:40:33 +0000 Subject: [PATCH 2/2] Update EIP-X-metadata-nickjohnson.md --- EIPS/EIP-X-metadata-nickjohnson.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EIPS/EIP-X-metadata-nickjohnson.md b/EIPS/EIP-X-metadata-nickjohnson.md index 364d3f472f37a..b0752808f2225 100644 --- a/EIPS/EIP-X-metadata-nickjohnson.md +++ b/EIPS/EIP-X-metadata-nickjohnson.md @@ -7,6 +7,7 @@ Category: ERC Status: Draft Created: 2018-03-12 + Dependencies: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md ## Abstract This EIP specifies a registry for address metadata, permitting both contracts and external accounts to supply metadata about themselves to onchain and offchain callers. This permits use-cases such as generalised authorisations, providing token acceptance settings, and claims registries. @@ -37,7 +38,7 @@ Providers have one mandatory function: function supportsInterface(bytes4 interfaceID) constant returns (bool) ``` -The `supportsInterface` function is documented in [EIP 165](https://github.com/ethereum/EIPs/issues/165), and returns true if the provider implements the interface specified by the provided 4 byte identifier. An interface identifier consists of the XOR of the function signature hashes of the functions provided by that interface; in the degenerate case of single-function interfaces, it is simply equal to the signature hash of that function. If a provider returns `true` for `supportsInterface()`, it must implement the functions specified in that interface. +The `supportsInterface` function is documented in [EIP 165](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md), and returns true if the provider implements the interface specified by the provided 4 byte identifier. An interface identifier consists of the XOR of the function signature hashes of the functions provided by that interface; in the degenerate case of single-function interfaces, it is simply equal to the signature hash of that function. If a provider returns `true` for `supportsInterface()`, it must implement the functions specified in that interface. `supportsInterface` must always return true for `0x01ffc9a7`, which is the interface ID of `supportsInterface` itself.