Skip to main content

ERC725

Solidity contract

The ERC725 is the contract combining:

  • ERC725X: contract that allow a generic execution using different types of operations.

  • ERC725Y: contract that allow for a generic data storage in a smart contract.

note

ERC725 contract also contains the method from ERC165:

function supportsInterface(bytes4 interfaceId) public view returns (bool)

Functions​

constructor​

constructor(address initialOwner)

Sets the initial owner of the contract.

Parameters:​

NameTypeDescription
initialOwneraddressThe address to set as the owner of the contract.

owner​

function owner() public view returns (address owner)

Returns the address of the current owner of the smart contract.

Return Values:​

NameTypeDescription
owneraddressThe current owner of the contract.

transferOwnership​

function transferOwnership(address newOwner) public {

Transfers the ownership of the contract to the newOwner address.

Triggers the OwnershipTransferred event when ownership is transferred.

Parameters:​

NameTypeDescription
newOwneraddressThe address to set as the owner of the contract.

execute - ERC725X​

function execute(
uint256 operationType,
address target,
uint256 value,
bytes memory data
) public payable returns (bytes memory result)

Executes a call on any other smart contracts, transfers value, or deploys a new smart contract.

The operationType can be the following:

  • 0 for CALL
  • 1 for CREATE
  • 2 for CREATE2
  • 3 for STATICCALL
  • 4 for DELEGATECALL

Triggers the Executed event when a call is successfully executed using CALL/STATICCALL/DELEGATECALL operations.

Triggers the ContractCreated event when a smart contract is created using CREATE/CREATE2 operations.

note

The execute(...) function can only be called by the current owner of the contract.

The operation types staticcall (3) and delegatecall (4) do not allow to transfer value.

Parameters:​

NameTypeDescription
operationTypeuint256The type of operation that needs to be executed.
targetaddressThe address to interact with. The address to will be unused if a contract is created (operations 1 & 2).
valueuint256The amount of native tokens to transfer with the transaction (in Wei).
databytesThe calldata (ABI-encoded payload of a function to run on an other contract), or the bytecode of the contract to deploy.

Return Values:​

NameTypeDescription
resultbytesThe data that was returned by the function called on the external contract, or the address of the contract created (operations 1 & 2).

execute (Array) - ERC725X​

function execute(
uint256[] memory operationsType,
address[] memory targets,
uint256[] memory values,
bytes[] memory datas
) public payable returns (bytes[] memory results)

Executes batch of calls on any other smart contracts, transfers value, or deploys a new smart contract.

Triggers the Executed event on each call iteration when a call is successfully executed using CALL/STATICCALL/DELEGATECALL operations.

Triggers the ContractCreated event on each contract creation iteration when a smart contract is created using CREATE/CREATE2 operations.

note

The execute(...) function can only be called by the current owner of the contract.

Parameters:​

NameTypeDescription
operationsTypeuint256[]The list of operation that needs to be executed.
targetsaddress[]The list of addresses to interact with. The addresses targets will be unused if a contract is created (operations 1 & 2).
valuesuint256[]The list of amount of native tokens to transfer with the transaction (in Wei).
datasbytes[]The list of calldata (ABI-encoded payload of a function to run on an other contract), or the list of bytecodes of the contracts to deploy.

Return Values:​

NameTypeDescription
resultbytes[]The array of data that was returned by the functions called on the external contract, or the addresses of the contracts created (operations 1 & 2).

setData - ERC725Y​

function setData(
bytes32 dataKey,
bytes memory dataValue
) public

Sets a value in the account storage for a particular data key.

Triggers the DataChanged event when successfully setting the data.

note

The setData(...) function can only be called by the current owner of the contract.

Parameters:​

NameTypeDescription
dataKeybytes32The data key for which the data will be set.
dataValuebytesThe data to be set.

getData - ERC725Y​

function getData(bytes32 dataKey) public view returns (bytes memory dataValue)

Retrieves the value set for the given data key.

Parameters:​

NameTypeDescription
dataKeybytes32The data key to retrieve data from.

Return Values:​

NameTypeDescription
dataValuebytesThe data for the requested data key.

setData (Array) - ERC725Y​

function setData(
bytes32[] memory dataKeys,
bytes[] memory dataValues
) public

Sets an array of data at multiple data keys in the account storage.

Triggers the DataChanged event when successfully setting each data key/value pair.

note

The setData(...) function can only be called by the current owner of the contract.

Parameters:​

NameTypeDescription
dataKeysbytes32[]The data keys for which to set data.
dataValuesbytes[]The array of data to set.

getData (Array) - ERC725Y​

function getData(bytes32[] memory dataKeys) public view returns (bytes[] memory dataValues)

Retrieves an array of values for multiple given data keys.

Parameters:​

NameTypeDescription
dataKeysbytes32[]The data keys to retrieve data from.

Return Values:​

NameTypeDescription
dataValuesbytes[]An array of the data for the requested data keys.

Events​

OwnershipTransferred​

event OwnershipTransferred(
address previousOwner,
address newOwner,
)

MUST be fired when transferOwnership(...) function is successfully executed.

Values:​

NameTypeDescription
previousOwneraddressThe previous owner of the contract.
newOwneraddressThe new owner of the contract.

Executed​

event Executed(
uint256 operationType,
address target,
uint256 value,
bytes4 selector
)

MUST be fired when execute(...) function creates a new call using the CALL, STATICCALL, or DELEGATECALL operation.

Values:​

NameTypeDescription
operationTypeuint256Either 0 (for CALL), 3 (for STATICCALL) or 3 (for DELEGATECALL).
targetaddressThe smart contract or address that was called.
valueuint256The value transferred.
selectorbytes4The bytes4 selector of the function called on the target address.

ContractCreated​

event ContractCreated(
uint256 operationType,
address contractAddress,
uint256 value,
bytes32 salt
)

MUST be fired when the execute(...) function creates a new contract using the CREATE or CREATE2 operation.

Values:​

NameTypeDescription
operationTypeuint256Either 1 (for CREATE) or 2 (for CREATE2).
toaddressThe address of the created contract.
valueuint256The value sent to the contract.
saltbytes32The salt used in CREATE2 operation. Will be bytes32(0) in case of CREATE operation.

DataChanged​

event DataChanged(bytes32 dataKey, bytes dataValue)

MUST be fired when the setData(...) function is successfully executed.

Values:​

NameTypeDescription
dataKeybytes32The data key which data value is set.
dataValuebytesThe data value to set.

References​