ERC725
ERC725 bundle.
Bundle ERC725X and ERC725Y together into one smart contract.
Public Methods
Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts. When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.
constructor
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol
constructor(address initialOwner);
Deploying an ERC725 smart contract and setting address initialOwner as the contract owner.
Deploy a new ERC725 contract with the provided initialOwner as the contract owner.
Requirements:
initialOwnerCANNOT be the zero address.
Parameters
| Name | Type | Description |
|---|---|---|
initialOwner | address | the owner of the contract. |
execute
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
execute(uint256,address,uint256,bytes) - Function selector:
0x44c028fe
function execute(
uint256 operationType,
address target,
uint256 value,
bytes data
) external payable returns (bytes);
Calling address target using operationType, transferring value wei and data: data.
Generic executor function to:
-
send native tokens to any address.
-
interact with any contract by passing an abi-encoded function call in the
dataparameter. -
deploy a contract by providing its creation bytecode in the
dataparameter.
Requirements:
- SHOULD only be callable by the
ownerof the contract.- if a
valueis provided, the contract MUST have at least this amount to transfer totargetfrom its balance and execute successfully.- if the operation type is
STATICCALL(3) orDELEGATECALL(4),valuetransfer is disallowed and SHOULD be 0.targetSHOULD beaddress(0)when deploying a new contract viaoperationTypeCREATE(1), orCREATE2(2).
Emitted events:
Executedevent when a call is made withoperationType0 (CALL), 3 (STATICCALL) or 4 (DELEGATECALL).ContractCreatedevent when deploying a new contract withoperationType1 (CREATE) or 2 (CREATE2).
Parameters
| Name | Type | Description |
|---|---|---|
operationType | uint256 | The operation type used: CALL = 0; CREATE = 1; CREATE2 = 2; STATICCALL = 3; DELEGATECALL = 4 |
target | address | The address of the EOA or smart contract. (unused if a contract is created via operation type 1 or 2) |
value | uint256 | The amount of native tokens to transfer (in Wei) |
data | bytes | The call data, or the creation bytecode of the contract to deploy if operationType is 1 or 2. |
Returns
| Name | Type | Description |
|---|---|---|
0 | bytes | - |
executeBatch
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
executeBatch(uint256[],address[],uint256[],bytes[]) - Function selector:
0x31858452
- The
msg.valueshould not be trusted for any method called withoperationType:DELEGATECALL(4).
function executeBatch(
uint256[] operationsType,
address[] targets,
uint256[] values,
bytes[] datas
) external payable returns (bytes[]);
Calling multiple addresses targets using operationsType, transferring values wei and data: datas.
Batch executor function that behaves the same as execute but allowing multiple operations in the same transaction.
Requirements:
- All the array parameters provided MUST be equal and have the same length.
- SHOULD only be callable by the
ownerof the contract.- The contract MUST have in its balance at least the sum of all the
valuesto transfer and execute successfully each calldata payloads.
Emitted events:
Executedevent, when a call is made withoperationType0 (CALL), 3 (STATICCALL) or 4 (DELEGATECALL)ContractCreatedevent, when deploying a contract withoperationType1 (CREATE) or 2 (CREATE2)
Parameters
| Name | Type | Description |
|---|---|---|
operationsType | uint256[] | The list of operations type used: CALL = 0; CREATE = 1; CREATE2 = 2; STATICCALL = 3; DELEGATECALL = 4 |
targets | address[] | The list of addresses to call. targets will be unused if a contract is created (operation types 1 and 2). |
values | uint256[] | The list of native token amounts to transfer (in Wei). |
datas | bytes[] | The list of calldata, or the creation bytecode of the contract to deploy if operationType is 1 or 2. |
Returns
| Name | Type | Description |
|---|---|---|
0 | bytes[] | - |
getData
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
getData(bytes32) - Function selector:
0x54f6127f
function getData(bytes32 dataKey) external view returns (bytes dataValue);
Reading the ERC725Y storage for data key dataKey returned the following value: dataValue.
Get in the ERC725Y storage the bytes data stored at a specific data key dataKey.
Parameters
| Name | Type | Description |
|---|---|---|
dataKey | bytes32 | The data key for which to retrieve the value. |
Returns
| Name | Type | Description |
|---|---|---|
dataValue | bytes | The bytes value stored under the specified data key. |
getDataBatch
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
getDataBatch(bytes32[]) - Function selector:
0xdedff9c6
function getDataBatch(
bytes32[] dataKeys
) external view returns (bytes[] dataValues);
Reading the ERC725Y storage for data keys dataKeys returned the following values: dataValues.
Get in the ERC725Y storage the bytes data stored at multiple data keys dataKeys.
Parameters
| Name | Type | Description |
|---|---|---|
dataKeys | bytes32[] | The array of keys which values to retrieve |
Returns
| Name | Type | Description |
|---|---|---|
dataValues | bytes[] | The array of data stored at multiple keys |
owner
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
owner() - Function selector:
0x8da5cb5b
function owner() external view returns (address);
Returns the address of the current owner.
Returns
| Name | Type | Description |
|---|---|---|
0 | address | - |
renounceOwnership
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
renounceOwnership() - Function selector:
0x715018a6
function renounceOwnership() external nonpayable;
Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
setData
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
setData(bytes32,bytes) - Function selector:
0x7f23690c
Note for developers: despite the fact that this function is set as payable, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value sent was equal to 0.
function setData(bytes32 dataKey, bytes dataValue) external payable;
Setting the following data key value pair in the ERC725Y storage. Data key: dataKey, data value: dataValue.
Sets a single bytes value dataValue in the ERC725Y storage for a specific data key dataKey. The function is marked as payable to enable flexibility on child contracts. For instance to implement a fee mechanism for setting specific data.
Requirements:
- SHOULD only be callable by the
owner.
Emitted events:
DataChangedevent.
Parameters
| Name | Type | Description |
|---|---|---|
dataKey | bytes32 | The data key for which to set a new value. |
dataValue | bytes | The new bytes value to set. |
setDataBatch
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
setDataBatch(bytes32[],bytes[]) - Function selector:
0x97902421
Note for developers: despite the fact that this function is set as payable, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value sent was equal to 0.
function setDataBatch(bytes32[] dataKeys, bytes[] dataValues) external payable;
Setting the following data key value pairs in the ERC725Y storage. Data keys: dataKeys, data values: dataValues.
Batch data setting function that behaves the same as setData but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction.
Requirements:
- SHOULD only be callable by the
ownerof the contract.
Emitted events:
DataChangedevent for each data key/value pair set.
Parameters
| Name | Type | Description |
|---|---|---|
dataKeys | bytes32[] | An array of data keys to set bytes values for. |
dataValues | bytes[] | An array of bytes values to set for each dataKeys. |
supportsInterface
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
supportsInterface(bytes4) - Function selector:
0x01ffc9a7
function supportsInterface(bytes4 interfaceId) external view returns (bool);
See IERC165-supportsInterface.
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 | - |
Returns
| Name | Type | Description |
|---|---|---|
0 | bool | - |
transferOwnership
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Function signature:
transferOwnership(address) - Function selector:
0xf2fde38b
function transferOwnership(address newOwner) external nonpayable;
Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.
Parameters
| Name | Type | Description |
|---|---|---|
newOwner | address | - |
Internal Methods
Any method labeled as internal serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.
Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.
_checkOwner
function _checkOwner() internal view;
Throws if the sender is not the owner.
_setOwner
function _setOwner(address newOwner) internal nonpayable;
Changes the owner if newOwner and oldOwner are different
This pattern is useful in inheritance.
_execute
function _execute(
uint256 operationType,
address target,
uint256 value,
bytes data
) internal nonpayable returns (bytes);
check the operationType provided and perform the associated low-level opcode after checking for requirements (see execute).
_executeBatch
function _executeBatch(
uint256[] operationsType,
address[] targets,
uint256[] values,
bytes[] datas
) internal nonpayable returns (bytes[]);
check each operationType provided in the batch and perform the associated low-level opcode after checking for requirements (see executeBatch).
_executeCall
function _executeCall(
address target,
uint256 value,
bytes data
) internal nonpayable returns (bytes result);
Perform low-level call (operation type = 0)
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The address on which call is executed |
value | uint256 | The value to be sent with the call |
data | bytes | The data to be sent with the call |
Returns
| Name | Type | Description |
|---|---|---|
result | bytes | The data from the call |
_executeStaticCall
function _executeStaticCall(
address target,
bytes data
) internal nonpayable returns (bytes result);
Perform low-level staticcall (operation type = 3)
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The address on which staticcall is executed |
data | bytes | The data to be sent with the staticcall |
Returns
| Name | Type | Description |
|---|---|---|
result | bytes | The data returned from the staticcall |
_executeDelegateCall
The msg.value should not be trusted for any method called with operationType: DELEGATECALL (4).
function _executeDelegateCall(
address target,
bytes data
) internal nonpayable returns (bytes result);
Perform low-level delegatecall (operation type = 4)
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The address on which delegatecall is executed |
data | bytes | The data to be sent with the delegatecall |
Returns
| Name | Type | Description |
|---|---|---|
result | bytes | The data returned from the delegatecall |
_deployCreate
function _deployCreate(
uint256 value,
bytes creationCode
) internal nonpayable returns (bytes newContract);
Deploy a contract using the CREATE opcode (operation type = 1)
Parameters
| Name | Type | Description |
|---|---|---|
value | uint256 | The value to be sent to the contract created |
creationCode | bytes | The contract creation bytecode to deploy appended with the constructor argument(s) |
Returns
| Name | Type | Description |
|---|---|---|
newContract | bytes | The address of the contract created as bytes |
_deployCreate2
function _deployCreate2(
uint256 value,
bytes creationCode
) internal nonpayable returns (bytes newContract);
Deploy a contract using the CREATE2 opcode (operation type = 2)
Parameters
| Name | Type | Description |
|---|---|---|
value | uint256 | The value to be sent to the contract created |
creationCode | bytes | The contract creation bytecode to deploy appended with the constructor argument(s) and a bytes32 salt |
Returns
| Name | Type | Description |
|---|---|---|
newContract | bytes | The address of the contract created as bytes |
_getData
function _getData(bytes32 dataKey) internal view returns (bytes dataValue);
Read the value stored under a specific dataKey inside the underlying ERC725Y storage,
represented as a mapping of bytes32 data keys mapped to their bytes data values.
mapping(bytes32 => bytes) _store
Parameters
| Name | Type | Description |
|---|---|---|
dataKey | bytes32 | A bytes32 data key to read the associated bytes value from the store. |
Returns
| Name | Type | Description |
|---|---|---|
dataValue | bytes | The bytes value associated with the given dataKey in the ERC725Y storage. |
_setData
function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable;
Write a dataValue to the underlying ERC725Y storage, represented as a mapping of
bytes32 data keys mapped to their bytes data values.
mapping(bytes32 => bytes) _store
Emitted events:
DataChangedevent emitted after a successfulsetDatacall.
Parameters
| Name | Type | Description |
|---|---|---|
dataKey | bytes32 | A bytes32 data key to write the associated bytes value to the store. |
dataValue | bytes | The bytes value to associate with the given dataKey in the ERC725Y storage. |
Events
ContractCreated
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Event signature:
ContractCreated(uint256,address,uint256,bytes32) - Event topic hash:
0xa1fb700aaee2ae4a2ff6f91ce7eba292f89c2f5488b8ec4c5c5c8150692595c3
event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 value, bytes32 indexed salt);
Deployed new contract at address contractAddress and funded with value wei (deployed using opcode: operationType).
Emitted when a new contract was created and deployed.
Parameters
| Name | Type | Description |
|---|---|---|
operationType indexed | uint256 | The opcode used to deploy the contract (CREATE or CREATE2). |
contractAddress indexed | address | The created contract address. |
value | uint256 | The amount of native tokens (in Wei) sent to fund the created contract on deployment. |
salt indexed | bytes32 | The salt used to deterministically deploy the contract (CREATE2 only). If CREATE opcode is used, the salt value will be bytes32(0). |
DataChanged
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Event signature:
DataChanged(bytes32,bytes) - Event topic hash:
0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2
event DataChanged(bytes32 indexed dataKey, bytes dataValue);
The following data key/value pair has been changed in the ERC725Y storage: Data key: dataKey, data value: dataValue.
Emitted when data at a specific dataKey was changed to a new value dataValue.
Parameters
| Name | Type | Description |
|---|---|---|
dataKey indexed | bytes32 | The data key for which a bytes value is set. |
dataValue | bytes | The value to set for the given data key. |
Executed
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Event signature:
Executed(uint256,address,uint256,bytes4) - Event topic hash:
0x4810874456b8e6487bd861375cf6abd8e1c8bb5858c8ce36a86a04dabfac199e
event Executed(uint256 indexed operationType, address indexed target, uint256 value, bytes4 indexed selector);
Called address target using operationType with value wei and data.
Emitted when calling an address target (EOA or contract) with value.
Parameters
| Name | Type | Description |
|---|---|---|
operationType indexed | uint256 | The low-level call opcode used to call the target address (CALL, STATICALL or DELEGATECALL). |
target indexed | address | The address to call. target will be unused if a contract is created (operation types 1 and 2). |
value | uint256 | The amount of native tokens transferred along the call (in Wei). |
selector indexed | bytes4 | The first 4 bytes (= function selector) of the data sent with the call. |
OwnershipTransferred
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Event signature:
OwnershipTransferred(address,address) - Event topic hash:
0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
Parameters
| Name | Type | Description |
|---|---|---|
previousOwner indexed | address | - |
newOwner indexed | address | - |
Errors
ERC725X_ContractDeploymentFailed
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_ContractDeploymentFailed() - Error hash:
0x0b07489b
error ERC725X_ContractDeploymentFailed();
Reverts when contract deployment failed via execute or executeBatch functions, This error can occur using either operation type 1 (CREATE) or 2 (CREATE2).
ERC725X_CreateOperationsRequireEmptyRecipientAddress
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_CreateOperationsRequireEmptyRecipientAddress() - Error hash:
0x3041824a
error ERC725X_CreateOperationsRequireEmptyRecipientAddress();
Reverts when passing a to address that is not address(0) (= address zero) while deploying a contract via execute or executeBatch functions. This error can occur using either operation type 1 (CREATE) or 2 (CREATE2).
ERC725X_ExecuteParametersEmptyArray
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_ExecuteParametersEmptyArray() - Error hash:
0xe9ad2b5f
error ERC725X_ExecuteParametersEmptyArray();
Reverts when one of the array parameter provided to the executeBatch function is an empty array.
ERC725X_ExecuteParametersLengthMismatch
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_ExecuteParametersLengthMismatch() - Error hash:
0x3ff55f4d
error ERC725X_ExecuteParametersLengthMismatch();
Reverts when there is not the same number of elements in the operationTypes, targets addresses, values, and datas array parameters provided when calling the executeBatch function.
ERC725X_InsufficientBalance
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_InsufficientBalance(uint256,uint256) - Error hash:
0x0df9a8f8
error ERC725X_InsufficientBalance(uint256 balance, uint256 value);
Reverts when trying to send more native tokens value than available in current balance.
Parameters
| Name | Type | Description |
|---|---|---|
balance | uint256 | The balance of native tokens of the ERC725X smart contract. |
value | uint256 | The amount of native tokens sent via ERC725X.execute(...)/ERC725X.executeBatch(...) that is greater than the contract's balance. |
ERC725X_MsgValueDisallowedInDelegateCall
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_MsgValueDisallowedInDelegateCall() - Error hash:
0x5ac83135
error ERC725X_MsgValueDisallowedInDelegateCall();
Reverts when trying to send native tokens (value / values[] parameter of execute or executeBatch functions) while making a delegatecall (operationType == 4). Sending native tokens via staticcall is not allowed because msg.value is persisting.
ERC725X_MsgValueDisallowedInStaticCall
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_MsgValueDisallowedInStaticCall() - Error hash:
0x72f2bc6a
error ERC725X_MsgValueDisallowedInStaticCall();
Reverts when trying to send native tokens (value / values[] parameter of execute or executeBatch functions) while making a staticcall (operationType == 3). Sending native tokens via staticcall is not allowed because it is a state changing operation.
ERC725X_NoContractBytecodeProvided
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_NoContractBytecodeProvided() - Error hash:
0xb81cd8d9
error ERC725X_NoContractBytecodeProvided();
Reverts when no contract bytecode was provided as parameter when trying to deploy a contract via execute or executeBatch. This error can occur using either operation type 1 (CREATE) or 2 (CREATE2).
ERC725X_UnknownOperationType
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725X_UnknownOperationType(uint256) - Error hash:
0x7583b3bc
error ERC725X_UnknownOperationType(uint256 operationTypeProvided);
Reverts when the operationTypeProvided is none of the default operation types available. (CALL = 0; CREATE = 1; CREATE2 = 2; STATICCALL = 3; DELEGATECALL = 4)
Parameters
| Name | Type | Description |
|---|---|---|
operationTypeProvided | uint256 | The unrecognised operation type number provided to ERC725X.execute(...)/ERC725X.executeBatch(...). |
ERC725Y_DataKeysValuesEmptyArray
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725Y_DataKeysValuesEmptyArray() - Error hash:
0x97da5f95
error ERC725Y_DataKeysValuesEmptyArray();
Reverts when one of the array parameter provided to setDataBatch function is an empty array.
ERC725Y_DataKeysValuesLengthMismatch
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725Y_DataKeysValuesLengthMismatch() - Error hash:
0x3bcc8979
error ERC725Y_DataKeysValuesLengthMismatch();
Reverts when there is not the same number of elements in the datakeys and dataValues array parameters provided when calling the setDataBatch function.
ERC725Y_MsgValueDisallowed
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
ERC725Y_MsgValueDisallowed() - Error hash:
0xf36ba737
error ERC725Y_MsgValueDisallowed();
Reverts when sending value to the setData or setDataBatch function.
OwnableCallerNotTheOwner
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
OwnableCallerNotTheOwner(address) - Error hash:
0xbf1169c5
error OwnableCallerNotTheOwner(address callerAddress);
Reverts when only the owner is allowed to call the function.
Parameters
| Name | Type | Description |
|---|---|---|
callerAddress | address | The address that tried to make the call. |
OwnableCannotSetZeroAddressAsOwner
- Specification details: ERC-725
- Solidity implementation:
ERC725.sol - Error signature:
OwnableCannotSetZeroAddressAsOwner() - Error hash:
0x1ad8836c
error OwnableCannotSetZeroAddressAsOwner();
Reverts when trying to set address(0) as the contract owner when deploying the contract, initializing it or transferring ownership of the contract.