EIP-725: General key-value store and execution standard
作者 | Fabian Vogelsteller, Tyler Yasaka |
---|---|
讨论-To | https://github.com/ethereum/EIPs/issues/725 |
状态 | Stagnant |
类型 | Standards Track |
分类 | ERC |
创建日期 | 2017-10-02 |
依赖 | 165, 173 |
英文版 | https://eips.ethereum.org/EIPS/eip-725 |
目录
简述
A standard interface for a smart contract based account with attachable key value store.
Abstract
The following describes standard functions for a unique smart contract based account that can be used by humans, groups, organisations, objects and machines.
The standard is divided into two sub standards:
ERC725X
: Can execute arbitrary smart contracts and deploy other smart contracts.
ERC725Y
: Can hold arbitrary data through a generic key/value store.
Motivation
Standardizing a minimal interface for a smart contract based account allows any interface to operate through these account types. Smart contact based accounts following this standard have the following advantages:
- can hold any asset (native token, e.g. ERC20 like tokens)
- can execute any smart contract and deploy smart contracts
- have upgradeable security (through owner change, e.g. to a gnosis safe)
- are basic enough to work for for a long time
- are extensible though additional standardisation of the key/value data.
- can function as an owner/controller or proxy of other smart contracts
Specification
ERC725X
ERC165 identifier: 0x44c028fe
execute
function execute(uint256 operationType, address to, uint256 value, bytes calldata data) public payable returns(bytes memory)
Executes a call on any other smart contracts, transfers the blockchains native token, or deploys a new smart contract. MUST only be called by the current owner of the contract.
Parameters:
operationType
: the operation to execute.to
: the smart contract or address to interact with.to
will be unused if a contract is created (operation 1 and 2).value
: the value of ETH to transfer.data
: the call data, or the contract data to deploy.
Returns: bytes
, the returned data of the called function, or the address of the contract created (operation 1 and 2).
The operationType
can be the following:
0
forcall
1
forcreate
2
forcreate2
3
forstaticcall
4
fordelegatecall
Others may be added in the future.
Triggers Event: ContractCreated, Executed
Events
Executed
event Executed(uint256 indexed _operation, address indexed _to, uint256 indexed _value, bytes _data);
MUST be triggered when execute
creates a new call using the operationType
0
, 3
, 4
.
ContractCreated
event ContractCreated(uint256 indexed _operation, address indexed _contractAddress, uint256 indexed _value);
MUST be triggered when execute
creates a new contract using the operationType
1
, 2
.
ERC725Y
ERC165 identifier: 0x714df77c
setData
function setData(bytes32 key, bytes memory value) public
Sets data as bytes in the storage for a single key. MUST only be called by the current owner of the contract.
Parameters:
key
: the key which value to set.value
: the data to set.
Triggers Event: DataChanged
setData (Array)
function setData(bytes32[] memory keys, bytes[] memory values) public
Sets array of data at multiple keys. MUST only be called by the current owner of the contract.
Parameters:
keys
: the keys which values to set.values
: the array of bytes to set.
Triggers Event: DataChanged
getData
function getData(bytes32 key) public view returns(bytes memory)
Gets the data set for the given key.
Parameters:
key
: the key which value to retrieve.
Returns: bytes
, The data for the requested key.
getData (Array)
function getData(bytes32[] memory keys) public view returns(bytes[] memory)
Gets array of data at multiple given key.
Parameters:
keys
: the keys which values to retrieve.
Returns: bytes[]
, array of the values for the requested keys.
Events
DataChanged
event DataChanged(bytes32 indexed key, bytes value)
MUST be triggered when setData
was successfully called.
Ownership
This contract is controlled by an owner. The owner can be a smart contract or an external account. This standard requires ERC173 and should implement the functions:
owner() view
transferOwnership(address newOwner)
The event:
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Data keys
Data keys, should be the keccak256 hash of a type name. e.g. keccak256('ERCXXXMyNewKeyType')
is 0x6935a24ea384927f250ee0b954ed498cd9203fc5d2bf95c735e52e6ca675e047
The ERC725JSONSchema standard defines how keys should be named and generated. This JSON schema can be used to auto decode ERC725Y values from smart contracts for application and smart contract interactions.
Default key values
ERC725 key standards need to be defined within new standards, we suggest the following defaults:
Name | Description | Key | value |
---|---|---|---|
SupportedStandards:XYZ | Allows to determine standards supported by this contract | 0xeafec4d89fa9619884b6b89135626455000000000000000000000000xxxxxxxx , where xxxxxxxx is the 4 bytes identifier of the standard supported |
Value can be defined by the standard, by default it should be the 4 bytes identifier e.g. 0x7a30e6fc |
ERC725Account
The specification of an ERC725Account can be found in LSP0-ERC725Account.
Rationale
The purpose of an smart contract account is to allow an entity to exist as a first-class citizen with the ability to execute arbitrary contract calls.
Implementation
Solidity Interfaces
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.5.0 <0.7.0;
//ERC165 identifier: `0x44c028fe`
interface IERC725X /* is ERC165, ERC173 */ {
event ContractCreated(uint256 indexed operation, address indexed contractAddress, uint256 indexed value);
event Executed(uint256 indexed operation, address indexed to, uint256 indexed value, bytes data);
function execute(uint256 operationType, address to, uint256 value, bytes calldata data) external payable returns(bytes memory);
}
//ERC165 identifier: `0x714df77c`
interface IERC725Y /* is ERC165, ERC173 */ {
event DataChanged(bytes32 indexed key, bytes value);
function setData(bytes32 key, bytes memory value) external;
function setData(bytes32[] memory keys, bytes[] memory values) external;
function getData(bytes32 key) external view returns(bytes memory);
function getData(bytes32[] memory keys) external view returns(bytes[] memory);
}
interface IERC725 /* is IERC725X, IERC725Y */ {
}
Additional References
- Slides of the ERC Identity presentation
- In-contract claim VS claim registry
- Identity related reports
- W3C Verifiable Claims Use Cases
- Decentralised Identity Foundation
- Sovrin Foundation Self Sovereign Identity
Copyright
Copyright and related rights waived via CC0.
参考文献
Please cite this document as:
Fabian Vogelsteller, Tyler Yasaka, "EIP-725: General key-value store and execution standard [DRAFT]," Ethereum Improvement Proposals, no. 725, October 2017. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-725.