mirror of
https://github.com/status-im/EIPs.git
synced 2025-02-04 19:13:48 +00:00
Automatically merged updates to draft EIP(s) 820
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
This commit is contained in:
parent
63e0929de7
commit
7b3104cb47
@ -13,15 +13,15 @@ created: 2018-01-05
|
||||
|
||||
This standard defines a universal registry smart contract where any address (contract or regular account) can register which interface it supports and which smart contract is responsible for its implementation.
|
||||
|
||||
This standard keeps backwards compatibility with [ERC165].
|
||||
This standard keeps backward compatibility with [ERC165].
|
||||
|
||||
## Abstract
|
||||
|
||||
This standard attempts to define a registry where smart contracts and regular accounts can publish which functionalities they implement—either directly or through a proxy contract .
|
||||
This standard defines a registry where smart contracts and regular accounts can publish which functionalities they implement—either directly or through a proxy contract.
|
||||
|
||||
The rest of the world can query this registry to ask if a specific address implements a given interface and which smart contract handles its implementation.
|
||||
Anyone can query this registry to ask if a specific address implements a given interface and which smart contract handles its implementation.
|
||||
|
||||
This registry MAY be deployed on any chain and will share the exact same address.
|
||||
This registry MAY be deployed on any chain and shares the same address on all chains.
|
||||
|
||||
Interfaces with zeroes (`0`) as the last 28 bytes are considered [ERC165] interfaces, and this registry SHALL forward the call to the contract to see if it implements the interface.
|
||||
|
||||
@ -29,11 +29,11 @@ This contract also acts as an [ERC165] cache to reduce gas consumption.
|
||||
|
||||
## Motivation
|
||||
|
||||
There has been different approaches to define pseudo-introspection in Ethereum. The first is [ERC165] which has the limitation that it cannot be used by regular accounts. The second attempt is [ERC672] which uses reverseENS. Using reverseENS has two issues. First, it is unnecessarily complex, and second, ENS is still a centralized contract controlled by a multisig. This multisig, theoretically would be able to modify the system.
|
||||
There have been different approaches to define pseudo-introspection in Ethereum. The first is [ERC165] which has the limitation that it cannot be used by regular accounts. The second attempt is [ERC672] which uses reverse [ENS]. Using reverse [ENS] has two issues. First, it is unnecessarily complicated, and second, [ENS] is still a centralized contract controlled by a multisig. This multisig theoretically would be able to modify the system.
|
||||
|
||||
This standard is much simpler than [ERC672] and it is fully decentralized.
|
||||
This standard is much simpler than [ERC672], and it is *fully* decentralized.
|
||||
|
||||
This standard also provides a unique address for all chains. Thus solving the problem of resolving the correct registry address for different chains.
|
||||
This standard also provides a *unique* address for all chains. Thus solving the problem of resolving the correct registry address for different chains.
|
||||
|
||||
## Specification
|
||||
|
||||
@ -281,20 +281,22 @@ This contract is going to be deployed using the keyless deployment method—
|
||||
s: 0x0820820820820820820820820820820820820820820820820820820820820820
|
||||
```
|
||||
|
||||
This nice `s` value---made of a repetion of `820`---is a predicatable "random number" generated deterministically by a human.
|
||||
This `s` value---made of a repeating pattern of `820`'s---is a predictable "random number" generated deterministically by a human.
|
||||
|
||||
3. We recover the sender of this transaction, i.e. the deployment account.
|
||||
> The value of `s` must be 64 bytes long. Since `820` is 3 bytes long and 3 is not a divisor of 64, but it is a divisor of 63, the `s` value is prefixed with a single zero (`0`). The `0` prefix also guarantees that `s < secp256k1n ÷ 2 + 1`.
|
||||
|
||||
3. We recover the sender of this transaction, i.e., the single-use deployment account.
|
||||
|
||||
> Thus we obtain an account that can broadcast that transaction, but we also have the warranty that nobody knows the private key of that account.
|
||||
|
||||
4. Send Ether to this deployment account.
|
||||
4. Send exactly 0.08 ethers to this single-use deployment account.
|
||||
|
||||
5. Broadcast the transaction.
|
||||
5. Broadcast the deployment transaction.
|
||||
|
||||
This operation can be done on any chain, guaranteeing that the contract address is going to always be the same and nobody will be able to mess up that address with a different contract.
|
||||
This operation can be done on any chain, guaranteeing that the contract address is always the same and nobody can use that address with a different contract.
|
||||
|
||||
|
||||
### Special Registry Deployment Account
|
||||
### Single-use Registry Deployment Account
|
||||
|
||||
```
|
||||
0xC3AdeE9B2E23837DF6259A984Af7a437dE4E2ab6
|
||||
@ -302,13 +304,16 @@ This operation can be done on any chain, guaranteeing that the contract address
|
||||
|
||||
This account is generated by reverse engineering it from its signature for the transaction. This way no one knows the private key, but it is known that it is the valid signer of the deployment transaction.
|
||||
|
||||
### Deployed contract
|
||||
> To deploy the registry, 0.08 ethers MUST be sent to this account *first*.
|
||||
|
||||
### Registry Contract Address
|
||||
|
||||
```
|
||||
0x820d0Bc4d0AD9E0E7dc19BD8cF9C566FC86054ce
|
||||
```
|
||||
|
||||
The contract has the address above for every chain it is deployed to.
|
||||
The contract has the address above for every chain on which it is deployed.
|
||||
|
||||
<details>
|
||||
<summary>Raw metadata of <code>./contracts/ERC820Registry.sol</code></summary>
|
||||
<pre>
|
||||
@ -640,6 +645,19 @@ Any interface name is hashed using `keccak256` and sent to `getInterfaceImplemen
|
||||
|
||||
If the interface is part of a standard, it is best practice to explicitly state the interface name and link to this published [ERC820] such that other people don't have to come here to look up these rules.
|
||||
|
||||
For convenience the registry provides a function to compute the hash on-chain:
|
||||
|
||||
``` solidity
|
||||
function interfaceHash(string _interfaceName) public pure returns(bytes32)
|
||||
```
|
||||
|
||||
Compute the keccak256 hash of an interface given its name.
|
||||
|
||||
> <small>**identifier:** `65ba36c1`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_interfaceName`: Name of the interface.</small>
|
||||
> <small>**returns:** The `keccak256` hash of an interface name.
|
||||
|
||||
#### **Approved ERCs**
|
||||
|
||||
If the interface is part of an approved ERC, it MUST be named `ERC###XXXXX` where `###` is the number of the ERC and XXXXX should be the name of the interface in CamelCase. The meaning of this interface SHOULD be defined in the specified ERC.
|
||||
@ -655,6 +673,38 @@ Examples:
|
||||
|
||||
Any interface where the last 28 bytes are zeroes (`0`) SHALL be considered an [ERC165] interface.
|
||||
|
||||
**[ERC165] Lookup**
|
||||
|
||||
Anyone can explicitly check if a contract implements an [ERC165] interface using the registry by calling one of the two functions below:
|
||||
|
||||
``` solidity
|
||||
function implementsERC165Interface(address _contract, bytes4 _interfaceId) public view returns (bool)
|
||||
```
|
||||
|
||||
Checks whether a contract implements an [ERC165] interface or not.
|
||||
|
||||
The result is cached. If the cache is out of date, it must be updated by calling `updateERC165Cache`.
|
||||
|
||||
*NOTE*: This function may modify the state when updating the cache. However, this function must have the `view` modifier since `getInterfaceImplementer` also calls it. If called from within a transaction, the [ERC165] cache is updated.
|
||||
|
||||
> <small>**identifier:** `f712f3e8`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_contract`: Address of the contract to check.</small>
|
||||
> <small>`_interfaceId`: [ERC165] interface to check.</small>
|
||||
> <small>**returns:** `true` if `_contract` implements `_interfaceId`, false otherwise.
|
||||
|
||||
``` solidity
|
||||
function implementsERC165InterfaceNoCache(address _contract, bytes4 _interfaceId) public view returns (bool)
|
||||
```
|
||||
|
||||
Checks whether a contract implements an [ERC165] interface or not without using nor updating the cache.
|
||||
|
||||
> <small>**identifier:** `b7056765`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_contract`: Address of the contract to check.</small>
|
||||
> <small>`_interfaceId`: [ERC165] interface to check.</small>
|
||||
> <small>**returns:** `true` if `_contract` implements `_interfaceId`, false otherwise.
|
||||
|
||||
**[ERC165] Cache**
|
||||
|
||||
Whether a contract implements an [ERC165] interface or not is automatically cached during [lookup] if the lookup is part of a transaction.
|
||||
@ -665,9 +715,10 @@ If a contract dynamically changes its interface, that contract SHOULD update the
|
||||
function updateERC165Cache(address _contract, bytes4 _interfaceId) public
|
||||
```
|
||||
|
||||
> <small>**identifier:** `a41e7d51`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_contract`: Address of the contract for which to update the cache.</small>
|
||||
> <small>`_interfaceHash`: ERC165 interface for which to update the cache.</small>
|
||||
> <small>`_interfaceHash`: [ERC165] interface for which to update the cache.</small>
|
||||
|
||||
#### **Private User-defined Interfaces**
|
||||
|
||||
@ -681,7 +732,7 @@ For any address to set a contract as the interface implementation, it must call
|
||||
function setInterfaceImplementer(address _addr, bytes32 _interfaceHash, address _implementer) public
|
||||
```
|
||||
|
||||
Sets the contract that will handle a specific interface.
|
||||
Sets the contract which implements a specific interface for an address.
|
||||
|
||||
Only the `manager` defined for that address can set it. (Each address is the manager for itself, see the [manager] section for more details.)
|
||||
|
||||
@ -692,6 +743,7 @@ Only the `manager` defined for that address can set it. (Each address is the man
|
||||
|
||||
*NOTE*: The `_interfaceHash` MUST NOT be an [ERC165] interface—it MUST NOT end with 28 zeroes (`0`).
|
||||
|
||||
> <small>**identifier:** `29965a1d`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_addr`: Address to define the interface for (if `_addr == 0` them `msg.sender`: is assumed)</small>
|
||||
> <small>`_interfaceHash`: `keccak256` hash of the name of the interface as a string, for example `web3.utils.keccak256('ERC777TokensRecipient')` for the ERC777TokensRecipient interface.</small>
|
||||
@ -708,6 +760,7 @@ Query if an address implements an interface and through which contract.
|
||||
|
||||
*NOTE*: If the last 28 bytes of the `_interfaceHash` are zeroes (`0`), then the first 4 bytes are considered an [ERC165] interface and the registry SHALL forward the call to the contract at `_addr` to see if it implements the [ERC165] interface (the first 4 bytes of `_interfaceHash`). The registry SHALL also cache [ERC165] queries to reduce gas consumption. Anyone MAY call the `erc165UpdateCache` function to update whether a contract implements an interface or not.
|
||||
|
||||
> <small>**identifier:** `aabbb8ca`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_addr`: Address being queried for the implementer of an interface. (If `_addr == 0` them `msg.sender` is assumed.)</small>
|
||||
> <small>`_interfaceHash`: keccak256 hash of the name of the interface as a string. E.g. `web3.utils.keccak256('ERC777Token')`</small>
|
||||
@ -736,9 +789,11 @@ Indicates whether a contract implements an interface (`interfaceHash`) for a giv
|
||||
|
||||
If a contract implements the interface (`interfaceHash`) for a given address (`addr`), it MUST return `ERC820_ACCEPT_MAGIC` when called with the `addr` and the `interfaceHash`. If it does not implement the `interfaceHash` for a given address (`addr`), it MUST NOT return `ERC820_ACCEPT_MAGIC`.
|
||||
|
||||
> <small>**identifier:** `f0083250`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`addr`: Address for which the interface is implemented</small>
|
||||
> <small>`interfaceHash`: Hash of the interface which is implemented</small>
|
||||
> <small>`interfaceHash`: Hash of the interface which is implemented</small>
|
||||
> <small>**returns:** `ERC820_ACCEPT_MAGIC` only if the contract implements `ìnterfaceHash` for the address `addr`.
|
||||
|
||||
The special value `ERC820_ACCEPT_MAGIC` is defined as the `keccka256` hash of the string `"ERC820_ACCEPT_MAGIC"`.
|
||||
|
||||
@ -752,7 +807,7 @@ bytes32 constant ERC820_ACCEPT_MAGIC = keccak256("ERC820_ACCEPT_MAGIC");
|
||||
|
||||
The manager of an address (regular account or a contract) is the only entity allowed to register implementations of interfaces for the address. By default, any address is its own manager.
|
||||
|
||||
The manager can transfer its role to another address by calling `setManager` with the address for which to transfer the manager and the address of the new manager.
|
||||
The manager can transfer its role to another address by calling `setManager` on the registry contract with the address for which to transfer the manager and the address of the new manager.
|
||||
|
||||
**`setManager` function**
|
||||
|
||||
@ -767,6 +822,7 @@ The new manager will be able to call `setInterfaceImplementer` for `_addr`.
|
||||
If `_addr` is `0x0`, `msg.sender` is assumed for `_addr`.
|
||||
If `_newManager` is `0x0`, the manager is reset to `_addr` itself as the manager.
|
||||
|
||||
> <small>**identifier:** `5df8122f`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_addr`: Address for which to set the new manager. (Pass `0x0` to use `msg.sender` as the address.)</small>
|
||||
> <small>`_newManager`: The address of the new manager for `_addr`. (Pass `0x0` to reset the manager to `_addr`.)</small>
|
||||
@ -779,6 +835,7 @@ function getManager(address _addr) public view returns(address)
|
||||
|
||||
Get the manager of an address.
|
||||
|
||||
> <small>**identifier:** `3d584063`</small>
|
||||
> <small>**parameters**</small>
|
||||
> <small>`_addr`: Address for which to return the manager.</small>
|
||||
> <small>**returns:** Address of the manager for a given address.</small>
|
||||
@ -809,3 +866,4 @@ Copyright and related rights waived via [CC0].
|
||||
[jbaylina/eip820]: https://github.com/jbaylina/eip820
|
||||
[CC0]: https://creativecommons.org/publicdomain/zero/1.0/
|
||||
[Nick]: https://github.com/Arachnid/
|
||||
[ENS]: https://ens.domains/
|
||||
|
Loading…
x
Reference in New Issue
Block a user