mirror of https://github.com/status-im/EIPs.git
Copyediting review
This commit is contained in:
parent
39285480ca
commit
b97350cb1b
|
@ -31,7 +31,7 @@ For some "standard interfaces" like [the ERC-20 token interface](https://github.
|
|||
|
||||
### How Interfaces are Identified
|
||||
|
||||
For this standard, an *interface* is a set of [function selectors as defined by the Ethereum ABI](http://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector). This a subset of [Solidity's concept of interfaces](http://solidity.readthedocs.io/en/develop/abi-spec.html) and the `interface` keyword definition which also define return types, mutability and events.
|
||||
For this standard, an *interface* is a set of [function selectors as defined by the Ethereum ABI](http://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector). This a subset of [Solidity's concept of interfaces](http://solidity.readthedocs.io/en/develop/abi-spec.html) and the `interface` keyword definition which also defines return types, mutability and events.
|
||||
|
||||
We define the interface identifier as the XOR of all function selectors in the interface. This code example shows how to calculate an interface identifier:
|
||||
|
||||
|
@ -51,7 +51,7 @@ contract Selector {
|
|||
}
|
||||
```
|
||||
|
||||
Note: interfaces do not permit optional functions, therefore, the interface identity will not them.
|
||||
Note: interfaces do not permit optional functions, therefore, the interface identity will not include them.
|
||||
|
||||
### How a Contract will Publish the Interfaces it Implements
|
||||
|
||||
|
@ -64,7 +64,7 @@ interface ERC165 {
|
|||
/// @notice Query if a contract implements an interface
|
||||
/// @param interfaceID The interface identifier, as specified in ERC-165
|
||||
/// @dev Interface identification is specified in ERC-165. This function
|
||||
/// uses less than 30000 gas.
|
||||
/// uses less than 30,000 gas.
|
||||
/// @return `true` if the contract implements `interfaceID` and
|
||||
/// `interfaceID` is not 0xffffffff, `false` otherwise
|
||||
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
|
@ -80,22 +80,22 @@ Therefore the implementing contract will have a `supportsInterface` function tha
|
|||
- `true` for any other `interfaceID` this contract implements
|
||||
- `false` for any other `interfaceID`
|
||||
|
||||
This function must return a bool and use at most 30000 gas.
|
||||
This function must return a bool and use at most 30,000 gas.
|
||||
|
||||
Implementation note, there are several logical ways to implement this function. Please see the example implementations and the discussion on gas usage.
|
||||
|
||||
### How to Detect if a Contract Implements ERC-165
|
||||
|
||||
1. The source contact makes a static `CALL` to the destination address with input data: `0x01ffc9a701ffc9a7` value: 0 and gas 30000. This corresponds to `contract.supportsInterface("0x01ffc9a7")`.
|
||||
1. The source contact makes a `STATICCALL` to the destination address with input data: `0x01ffc9a701ffc9a7` and gas 30,000. This corresponds to `contract.supportsInterface("0x01ffc9a7")`.
|
||||
2. If the call fails or return false, the destination contract does not implement ERC-165.
|
||||
3. If the call returns true, a second call is made with input data `0x01ffc9a7ffffffff`.
|
||||
4. If the second call fails or returns true, the destination contract does not implement ERC-165.
|
||||
5. Otherwise it implements EIP165.
|
||||
5. Otherwise it implements ERC-165.
|
||||
|
||||
### How to Detect if a Contract Implements any Given Interface
|
||||
|
||||
1. If you are not sure if the contract implements ERC-165 Interface, use the previous procedure to confirm.
|
||||
2. If it does not implement ERC-165, then you will have to see what methods it uses the old fashioned way.
|
||||
1. If you are not sure if the contract implements ERC-165, use the above procedure to confirm.
|
||||
2. If it does not implement ERC-165, then you will have to see what methods it uses the old-fashioned way.
|
||||
3. If it implements ERC-165 then just call `supportsInterface(interfaceID)` to determine if it implements an interface you can use.
|
||||
|
||||
## Rationale
|
||||
|
@ -168,7 +168,7 @@ contract ERC165Cache {
|
|||
mstore(add(x, 0x04), _interfaceId) // Place first argument directly next to signature
|
||||
|
||||
success := staticcall(
|
||||
30000, // 5k gas
|
||||
30000, // 30k gas
|
||||
_contract, // To addr
|
||||
x, // Inputs are stored at location x
|
||||
0x8, // Inputs are 8 byes long
|
||||
|
@ -240,7 +240,7 @@ contract Homer is ERC165, Simpson {
|
|||
}
|
||||
```
|
||||
|
||||
With three or more supported interfaces (including ERC165 itself as a required supported interface), the mapping table approach (for any case) costs less gas than the worst case for pure approach.
|
||||
With three or more supported interfaces (including ERC165 itself as a required supported interface), the mapping approach (in every case) costs less gas than the pure approach (at worst case).
|
||||
|
||||
## Copyright
|
||||
|
||||
|
|
Loading…
Reference in New Issue