diff --git a/docs/contracts/LSP0ERC725Account/LSP0ERC725Account.md b/docs/contracts/LSP0ERC725Account/LSP0ERC725Account.md index 243c842a1..e33cea6a5 100644 --- a/docs/contracts/LSP0ERC725Account/LSP0ERC725Account.md +++ b/docs/contracts/LSP0ERC725Account/LSP0ERC725Account.md @@ -291,21 +291,15 @@ function execute( ) 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 `data` parameter. -- deploy a contract by providing its creation bytecode in the `data` parameter. Requirements: - -- SHOULD only be callable by the owner of the contract set via ERC173. - -- if a `value` is provided, the contract MUST have at least this amount in its balance to execute successfully. - -- if the operation type is STATICCALL or DELEGATECALL, `value` SHOULD be 0. - -- `target` SHOULD be address(0) when deploying a contract. Emits an [`Executed`](#executed) event, when a call is made with `operationType` 0 (CALL), 3 (STATICCALL) or 4 (DELEGATECALL) Emits a [`ContractCreated`](#contractcreated) event, when deploying a contract with `operationType` 1 (CREATE) or 2 (CREATE2) +- deploy a contract by providing its creation bytecode in the `data` parameter.
@@ -322,8 +316,8 @@ Generic executor function to: **Emitted events:** -- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). (each iteration) -- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2) (each iteration) +- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). +- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2). - [`ValueReceived`](#valuereceived) event when receiving native tokens.
@@ -335,7 +329,7 @@ Generic executor function to: | `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 | +| `data` | `bytes` | The call data, or the creation bytecode of the contract to deploy if `operationType` is `1` or `2`. | #### Returns @@ -365,23 +359,9 @@ function executeBatch( ) external payable returns (bytes[]); ``` -Generic batch executor function to: - -- send native tokens to any address. +_Calling multiple addresses `targets` using `operationsType`, transferring `values` wei and data: `datas`. _ -- interact with any contract by passing an abi-encoded function call in the `datas` parameter. - -- deploy a contract by providing its creation bytecode in the `datas` parameter. Requirements: - -- The length of the parameters provided MUST be equal - -- SHOULD only be callable by the owner of the contract set via ERC173. - -- if a `values` is provided, the contract MUST have at least this amount in its balance to execute successfully. - -- if the operation type is STATICCALL or DELEGATECALL, `values` SHOULD be 0. - -- `targets` SHOULD be address(0) when deploying a contract. Emits an [`Executed`](#executed) event, when a call is made with `operationType` 0 (CALL), 3 (STATICCALL) or 4 (DELEGATECALL) Emits a [`ContractCreated`](#contractcreated) event, when deploying a contract with `operationType` 1 (CREATE) or 2 (CREATE2) +Batch executor function that behaves the same as [`execute`](#execute) but allowing multiple operations in the same transaction.
@@ -407,12 +387,12 @@ Generic batch executor function to: #### 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 call data, or the creation bytecode of the contract to deploy | +| 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 @@ -437,19 +417,21 @@ Generic batch executor function to: function getData(bytes32 dataKey) external view returns (bytes dataValue); ``` -_Gets singular data at a given `dataKey`_ +_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 key which value to retrieve | +| Name | Type | Description | +| --------- | :-------: | --------------------------------------------- | +| `dataKey` | `bytes32` | The data key for which to retrieve the value. | #### Returns -| Name | Type | Description | -| ----------- | :-----: | -------------------------- | -| `dataValue` | `bytes` | The data stored at the key | +| Name | Type | Description | +| ----------- | :-----: | ---------------------------------------------------- | +| `dataValue` | `bytes` | The bytes value stored under the specified data key. |
@@ -470,7 +452,9 @@ function getDataBatch( ) external view returns (bytes[] dataValues); ``` -_Gets array of data for multiple given keys_ +_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 @@ -645,7 +629,9 @@ Renounce ownership of the contract in a 2-step process. function setData(bytes32 dataKey, bytes dataValue) external payable; ``` -_Sets singular data for a given `dataKey`_ +_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.
@@ -666,10 +652,10 @@ _Sets singular data for a given `dataKey`_ #### Parameters -| Name | Type | Description | -| ----------- | :-------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `dataKey` | `bytes32` | The key to retrieve stored value | -| `dataValue` | `bytes` | The value to set SHOULD only be callable by the owner of the contract set via ERC173 The function is marked as payable to enable flexibility on child contracts If the function is not intended to receive value, an additional check should be implemented to check that value equal 0. Emits a {DataChanged} event. | +| Name | Type | Description | +| ----------- | :-------: | ------------------------------------------ | +| `dataKey` | `bytes32` | The data key for which to set a new value. | +| `dataValue` | `bytes` | The new bytes value to set. |
@@ -688,9 +674,9 @@ _Sets singular data for a given `dataKey`_ function setDataBatch(bytes32[] dataKeys, bytes[] dataValues) external payable; ``` -Sets array of data for multiple given `dataKeys` SHOULD only be callable by the owner of the contract set via ERC173 The function is marked as payable to enable flexibility on child contracts If the function is not intended to receive value, an additional check should be implemented to check that value equal +_Setting the following data key value pairs in the ERC725Y storage. Data keys: `dataKeys`, data values: `dataValues`. _ -0. Emits a [`DataChanged`](#datachanged) event. +Batch data setting function that behaves the same as [`setData`](#setdata) but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction.
@@ -711,10 +697,10 @@ Sets array of data for multiple given `dataKeys` SHOULD only be callable by the #### Parameters -| Name | Type | Description | -| ------------ | :---------: | ---------------------------------------- | -| `dataKeys` | `bytes32[]` | The array of data keys for values to set | -| `dataValues` | `bytes[]` | The array of values to set | +| 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`. |
@@ -733,7 +719,7 @@ Sets array of data for multiple given `dataKeys` SHOULD only be callable by the function supportsInterface(bytes4 interfaceId) external view returns (bool); ``` -_Checking if this contract supports the interface defined by the bytes4 interface ID `interfaceId`._ +_Checking if this contract supports the interface defined by the `bytes4` interface ID `interfaceId`._ Achieves the goal of [ERC-165] to detect supported interfaces and [LSP-17-ContractExtension] by checking if the interfaceId being queried is supported on another linked extension. If the contract doesn't support the `interfaceId`, it forwards the call to the `supportsInterface` extension according to [LSP-17-ContractExtension], and checks if the extension implements the interface defined by `interfaceId`. @@ -884,8 +870,7 @@ function _execute( ) internal nonpayable returns (bytes); ``` -check the `operationType` provided and perform the associated low-level opcode. -see `IERC725X.execute(uint256,address,uint256,bytes)`. +check the `operationType` provided and perform the associated low-level opcode after checking for requirements (see [`execute`](#execute)).
@@ -900,8 +885,7 @@ function _executeBatch( ) internal nonpayable returns (bytes[]); ``` -same as `_execute` but for batch execution -see `IERC725X,execute(uint256[],address[],uint256[],bytes[])` +check each `operationType` provided in the batch and perform the associated low-level opcode after checking for requirements (see [`executeBatch`](#executebatch)).
@@ -915,7 +899,7 @@ function _executeCall( ) internal nonpayable returns (bytes result); ``` -perform low-level call (operation type = 0) +Perform low-level call (operation type = 0) #### Parameters @@ -942,7 +926,7 @@ function _executeStaticCall( ) internal nonpayable returns (bytes result); ``` -perform low-level staticcall (operation type = 3) +Perform low-level staticcall (operation type = 3) #### Parameters @@ -968,7 +952,7 @@ function _executeDelegateCall( ) internal nonpayable returns (bytes result); ``` -perform low-level delegatecall (operation type = 4) +Perform low-level delegatecall (operation type = 4) #### Parameters @@ -994,7 +978,7 @@ function _deployCreate( ) internal nonpayable returns (bytes newContract); ``` -deploy a contract using the CREATE opcode (operation type = 1) +Deploy a contract using the `CREATE` opcode (operation type = 1) #### Parameters @@ -1020,7 +1004,7 @@ function _deployCreate2( ) internal nonpayable returns (bytes newContract); ``` -deploy a contract using the CREATE2 opcode (operation type = 2) +Deploy a contract using the `CREATE2` opcode (operation type = 2) #### Parameters @@ -1043,6 +1027,25 @@ deploy a contract using the CREATE2 opcode (operation type = 2) 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. + +```solidity +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 @@ -1137,8 +1140,10 @@ function _getExtension(bytes4 functionSelector) internal view returns (address); ``` Returns the extension address stored under the following data key: -{\_LSP17_EXTENSION_PREFIX + } (Check [LSP2-ERC725YJSONSchema] for encoding the data key) -If no extension is stored, returns the address(0) + +- [`_LSP17_EXTENSION_PREFIX`](#_lsp17_extension_prefix) + `` (Check [LSP2-ERC725YJSONSchema] for encoding the data key). + +- If no extension is stored, returns the address(0).
@@ -1151,13 +1156,9 @@ function _fallbackLSP17Extendable( ``` Forwards the call to an extension mapped to a function selector. -Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being -called on the account. If there is no extension, the `address(0)` will be returned. -Reverts if there is no extension for the function being called, except for the bytes4(0) function -selector, which passes even if there is no extension for it. -If there is an extension for the function selector being called, it calls the extension with the -CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and -32 bytes of the `msg.value` +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value`
@@ -1229,16 +1230,18 @@ function _revertWithLSP20DefaultError( event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 indexed value, bytes32 salt); ``` -_Emitted when deploying a contract_ +_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` **`indexed`** | `uint256` | The amount of native tokens (in Wei) sent to fund the created contract address | -| `salt` | `bytes32` | - | +| Name | Type | Description | +| ------------------------------- | :-------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `operationType` **`indexed`** | `uint256` | The opcode used to deploy the contract (`CREATE` or `CREATE2`). | +| `contractAddress` **`indexed`** | `address` | The created contract address. | +| `value` **`indexed`** | `uint256` | The amount of native tokens (in Wei) sent to fund the created contract on deployment. | +| `salt` | `bytes32` | The salt used to deterministically deploy the contract (`CREATE2` only). If `CREATE` opcode is used, the salt value will be `bytes32(0)`. |
@@ -1257,14 +1260,16 @@ _Emitted when deploying a contract_ event DataChanged(bytes32 indexed dataKey, bytes dataValue); ``` -_Emitted when data at a key is changed_ +_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 which data value is set | -| `dataValue` | `bytes` | The data value to set | +| 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. |
@@ -1283,16 +1288,18 @@ _Emitted when data at a key is changed_ event Executed(uint256 indexed operationType, address indexed target, uint256 indexed value, bytes4 selector); ``` -_Emitted when calling an address (EOA or contract)_ +_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 `to` 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` **`indexed`** | `uint256` | The amount of native tokens transferred with the call (in Wei) | -| `selector` | `bytes4` | The first 4 bytes (= function selector) of the data sent with the call | +| 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` **`indexed`** | `uint256` | The amount of native tokens transferred along the call (in Wei). | +| `selector` | `bytes4` | The first 4 bytes (= function selector) of the data sent with the call. |
@@ -1440,12 +1447,14 @@ event ValueReceived(address indexed sender, uint256 indexed value); _`value` native tokens received from `sender`._ +Emitted when receiving native tokens. + #### Parameters -| Name | Type | Description | -| ---------------------- | :-------: | ------------------------------------ | -| `sender` **`indexed`** | `address` | The address of the sender | -| `value` **`indexed`** | `uint256` | The amount of native tokens received | +| Name | Type | Description | +| ---------------------- | :-------: | ---------------------------------------------------------- | +| `sender` **`indexed`** | `address` | The address that sent some native tokens to this contract. | +| `value` **`indexed`** | `uint256` | The amount of native tokens received. |
@@ -1487,7 +1496,7 @@ Reverts when trying to transfer ownership to the `address(this)`. error ERC725X_ContractDeploymentFailed(); ``` -reverts when contract deployment via `ERC725X.execute(...)`/`ERC725X.executeBatch(...)` failed. whether using operation type 1 (CREATE) or 2 (CREATE2). +Reverts when contract deployment failed via [`execute`](#execute) or [`executeBatch`](#executebatch) functions, This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`).
@@ -1506,7 +1515,7 @@ reverts when contract deployment via `ERC725X.execute(...)`/`ERC725X.executeBatc error ERC725X_CreateOperationsRequireEmptyRecipientAddress(); ``` -reverts when passing a `to` address while deploying a contract va `ERC725X.execute(...)`/`ERC725X.executeBatch(...)` whether using operation type 1 (CREATE) or 2 (CREATE2). +Reverts when passing a `to` address that is not `address(0)` (= address zero) while deploying a contract via [`execute`](#execute) or [`executeBatch`](#executebatch) functions. This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`).
@@ -1525,7 +1534,7 @@ reverts when passing a `to` address while deploying a contract va `ERC725X.execu error ERC725X_ExecuteParametersEmptyArray(); ``` -reverts when one of the array parameter provided to `executeBatch(uint256[],address[],uint256[],bytes[]) is an empty array +Reverts when one of the array parameter provided to the [`executeBatch`](#executebatch) function is an empty array.
@@ -1544,7 +1553,7 @@ reverts when one of the array parameter provided to `executeBatch(uint256[],addr error ERC725X_ExecuteParametersLengthMismatch(); ``` -reverts when there is not the same number of operation, to addresses, value, and data. +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`](#executebatch) function.
@@ -1563,14 +1572,14 @@ reverts when there is not the same number of operation, to addresses, value, and error ERC725X_InsufficientBalance(uint256 balance, uint256 value); ``` -reverts when trying to send more native tokens `value` than available in current `balance`. +Reverts when trying to send more native tokens `value` than available in current `balance`. #### Parameters -| Name | Type | Description | -| --------- | :-------: | ---------------------------------------------------------------------------------------- | -| `balance` | `uint256` | the balance of the ERC725X contract. | -| `value` | `uint256` | the amount of native tokens sent via `ERC725X.execute(...)`/`ERC725X.executeBatch(...)`. | +| 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`. |
@@ -1589,7 +1598,7 @@ reverts when trying to send more native tokens `value` than available in current error ERC725X_MsgValueDisallowedInDelegateCall(); ``` -the `value` parameter (= sending native tokens) is not allowed when making a delegatecall via `ERC725X.execute(...)`/`ERC725X.executeBatch(...)` because msg.value is persisting. +Reverts when trying to send native tokens (`value` / `values[]` parameter of [`execute`](#execute) or [`executeBatch`](#executebatch) functions) while making a `delegatecall` (`operationType == 4`). Sending native tokens via `staticcall` is not allowed because `msg.value` is persisting.
@@ -1608,7 +1617,7 @@ the `value` parameter (= sending native tokens) is not allowed when making a del error ERC725X_MsgValueDisallowedInStaticCall(); ``` -the `value` parameter (= sending native tokens) is not allowed when making a staticcall via `ERC725X.execute(...)`/`ERC725X.executeBatch(...)` because sending native tokens is a state changing operation. +Reverts when trying to send native tokens (`value` / `values[]` parameter of [`execute`](#execute) or [`executeBatch`](#executebatch) functions) while making a `staticcall` (`operationType == 3`). Sending native tokens via `staticcall` is not allowed because it is a state changing operation.
@@ -1627,7 +1636,7 @@ the `value` parameter (= sending native tokens) is not allowed when making a sta error ERC725X_NoContractBytecodeProvided(); ``` -reverts when no contract bytecode was provided as parameter when trying to deploy a contract via `ERC725X.execute(...)`/`ERC725X.executeBatch(...)`, whether using operation type 1 (CREATE) or 2 (CREATE2). +Reverts when no contract bytecode was provided as parameter when trying to deploy a contract via [`execute`](#execute) or [`executeBatch`](#executebatch). This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`).
@@ -1646,13 +1655,13 @@ reverts when no contract bytecode was provided as parameter when trying to deplo 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) +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` | - | +| Name | Type | Description | +| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------ | +| `operationTypeProvided` | `uint256` | The unrecognised operation type number provided to `ERC725X.execute(...)`/`ERC725X.executeBatch(...)`. |
@@ -1671,7 +1680,7 @@ reverts when the `operationTypeProvided` is none of the default operation types error ERC725Y_DataKeysValuesLengthMismatch(); ``` -reverts when there is not the same number of elements in the lists of data keys and data values when calling setDataBatch. +Reverts when there is not the same number of elements in the `datakeys` and `dataValues` array parameters provided when calling the [`setDataBatch`](#setdatabatch) function.
diff --git a/docs/contracts/LSP9Vault/LSP9Vault.md b/docs/contracts/LSP9Vault/LSP9Vault.md new file mode 100644 index 000000000..d6ac3ea7a --- /dev/null +++ b/docs/contracts/LSP9Vault/LSP9Vault.md @@ -0,0 +1,1712 @@ + + + +# LSP9Vault + +:::info Standard Specifications + +[`LSP-9-Vault`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md) + +::: +:::info Solidity implementation + +[`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) + +::: + +> Implementation of LSP9Vault built on top of [ERC725], [LSP-1-UniversalReceiver] + +Could be owned by an EOA or by a contract and is able to receive and send assets. Also allows for registering received assets by levereging the key-value storage. + +## 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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#constructor) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) + +::: + +```solidity +constructor(address newOwner); +``` + +_Deploying a LSP9Vault contract with owner set to address `initialOwner`._ + +Sets `initialOwner` as the contract owner and the `SupportedStandards:LSP9Vault` Data Key. The `constructor` also allows funding the contract on deployment. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when funding the contract on deployment. +- [`OwnershipTransferred`](#ownershiptransferred) event when `initialOwner` is set as the contract [`owner`](#owner). +- [`DataChanged`](#datachanged) event when setting the [`_LSP9_SUPPORTED_STANDARDS_KEY`](#_lsp9_supported_standards_key). +- [`UniversalReceiver`](#universalreceiver) event when notifying the `initialOwner`. + +
+ +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ------------------------------ | +| `newOwner` | `address` | The new owner of the contract. | + +
+ +### fallback + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#fallback) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) + +::: + +```solidity +fallback(bytes calldata callData) external payable returns (bytes memory); +``` + +_The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`._ + +Achieves the goal of [LSP-17-ContractExtension] standard by extending the contract to handle calls of functions that do not exist natively, +forwarding the function call to the extension address mapped to the function being called. +This function is executed when: + +- Sending data of length less than 4 bytes to the contract. + +- The first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI. + +- Receiving native tokens with some calldata. + +1. If the data is equal or longer than 4 bytes, the [ERC-725Y] storage is queried with the following data key: [_LSP17_EXTENSION_PREFIX] + `bytes4(msg.sig)` (Check [LSP-2-ERC725YJSONSchema] for encoding the data key) + +- If there is no address stored under the following data key, revert with [`NoExtensionFoundForFunctionSelector(bytes4)`](#noextensionfoundforfunctionselector). The data key relative to `bytes4(0)` is an exception, where no reverts occurs if there is no extension address stored under. This exception is made to allow users to send random data (graffiti) to the account and to be able to react on it. + +- If there is an address, forward the `msg.data` to the extension using the CALL opcode, appending 52 bytes (20 bytes of `msg.sender` and 32 bytes of `msg.value`). Return what the calls returns, or revert if the call failed. + +2. If the data sent to this function is of length less than 4 bytes (not a function selector), return. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when receiving native tokens. + +
+ +
+ +### receive + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#receive) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) + +::: + +```solidity +receive() external payable; +``` + +Executed: + +- When receiving some native tokens without any additional data. + +- On empty calls to the contract. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) when receiving native tokens. + +
+ +
+ +### RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#renounce_ownership_confirmation_delay) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY()` +- Function selector: `0xead3fbdf` + +::: + +```solidity +function RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY() + external + view + returns (uint256); +``` + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `uint256` | - | + +
+ +### RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#renounce_ownership_confirmation_period) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD()` +- Function selector: `0x01bfba61` + +::: + +```solidity +function RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD() + external + view + returns (uint256); +``` + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `uint256` | - | + +
+ +### acceptOwnership + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#acceptownership) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `acceptOwnership()` +- Function selector: `0x79ba5097` + +::: + +```solidity +function acceptOwnership() external nonpayable; +``` + +_`msg.sender` is accepting ownership of contract: `address(this)`._ + +Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: + +- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. + +- The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. + +
+ +**Requirements:** + +- Only the [`pendingOwner`](#pendingowner) can call this function. +- When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification]. +- When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification]. + +
+ +
+ +### batchCalls + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#batchcalls) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `batchCalls(bytes[])` +- Function selector: `0x6963d438` + +::: + +:::info + +It's not possible to send value along the functions call due to the use of `delegatecall`. + +::: + +```solidity +function batchCalls(bytes[] data) external nonpayable returns (bytes[] results); +``` + +_Executing the following batch of abi-encoded function calls on the contract: `data`._ + +Allows a caller to batch different function calls in one call. Perform a `delegatecall` on self, to call different functions with preserving the context. + +#### Parameters + +| Name | Type | Description | +| ------ | :-------: | -------------------------------------------------------------------- | +| `data` | `bytes[]` | An array of ABI encoded function calls to be called on the contract. | + +#### Returns + +| Name | Type | Description | +| --------- | :-------: | ---------------------------------------------------------------- | +| `results` | `bytes[]` | An array of abi-encoded data returned by the functions executed. | + +
+ +### execute + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#execute) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `execute(uint256,address,uint256,bytes)` +- Function selector: `0x44c028fe` + +::: + +:::info + +The `operationType` 4 `DELEGATECALL` is disabled by default in the LSP9 Vault. + +::: + +```solidity +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 `data` parameter. + +- deploy a contract by providing its creation bytecode in the `data` parameter. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- If a `value` is provided, the contract must have at least this amount in its balance to execute successfully. +- If the operation type is `CREATE` (1) or `CREATE2` (2), `target` must be `address(0)`. +- If the operation type is `STATICCALL` (3), `value` transfer is disallowed and must be 0. + +
+ +
+ +**Emitted events:** + +- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0) and `STATICCALL` (3). +- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2). +- [`ValueReceived`](#valuereceived) event when receiving native tokens. + +
+ +#### 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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#executebatch) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `executeBatch(uint256[],address[],uint256[],bytes[])` +- Function selector: `0x31858452` + +::: + +:::info + +The `operationType` 4 `DELEGATECALL` is disabled by default in the LSP9 Vault. + +::: + +```solidity +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`](#execute) but allowing multiple operations in the same transaction. + +
+ +**Requirements:** + +- The length of the parameters provided must be equal. +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- If a `value` is provided, the contract must have at least this amount in its balance to execute successfully. +- If the operation type is `CREATE` (1) or `CREATE2` (2), `target` must be `address(0)`. +- If the operation type is `STATICCALL` (3), `value` transfer is disallowed and must be 0. + +
+ +
+ +**Emitted events:** + +- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0) and `STATICCALL` (3). (each iteration) +- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2). (each iteration) +- [`ValueReceived`](#valuereceived) event when receiving native tokens. + +
+ +#### 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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#getdata) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `getData(bytes32)` +- Function selector: `0x54f6127f` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#getdatabatch) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `getDataBatch(bytes32[])` +- Function selector: `0xdedff9c6` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#owner) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `owner()` +- Function selector: `0x8da5cb5b` + +::: + +```solidity +function owner() external view returns (address); +``` + +Returns the address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `address` | - | + +
+ +### pendingOwner + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#pendingowner) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `pendingOwner()` +- Function selector: `0xe30c3978` + +::: + +:::info + +If no ownership transfer is in progress, the pendingOwner will be `address(0).`. + +::: + +```solidity +function pendingOwner() external view returns (address); +``` + +The address that ownership of the contract is transferred to. This address may use [`acceptOwnership()`](#acceptownership) to gain ownership of the contract. + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `address` | - | + +
+ +### renounceOwnership + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#renounceownership) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `renounceOwnership()` +- Function selector: `0x715018a6` + +::: + +:::danger + +Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. + +::: + +```solidity +function renounceOwnership() external nonpayable; +``` + +_`msg.sender` is renouncing ownership of contract `address(this)`._ + +Renounce ownership of the contract in a 2-step process. + +1. The first call will initiate the process of renouncing ownership. + +2. The second call is used as a confirmation and will leave the contract without an owner. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +### setData + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#setdata) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `setData(bytes32,bytes)` +- Function selector: `0x7f23690c` + +::: + +```solidity +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:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when receiving native tokens. +- [`DataChanged`](#datachanged) event. + +
+ +#### 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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#setdatabatch) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `setDataBatch(bytes32[],bytes[])` +- Function selector: `0x97902421` + +::: + +```solidity +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`](#setdata) but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when receiving native tokens. +- [`DataChanged`](#datachanged) event. (on each iteration of setting data) + +
+ +#### 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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#supportsinterface) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `supportsInterface(bytes4)` +- Function selector: `0x01ffc9a7` + +::: + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool); +``` + +_Checking if this contract supports the interface defined by the `bytes4` interface ID `interfaceId`._ + +Achieves the goal of [ERC-165] to detect supported interfaces and [LSP-17-ContractExtension] by checking if the interfaceId being queried is supported on another linked extension. If the contract doesn't support the `interfaceId`, it forwards the call to the `supportsInterface` extension according to [LSP-17-ContractExtension], and checks if the extension implements the interface defined by `interfaceId`. + +#### Parameters + +| Name | Type | Description | +| ------------- | :------: | ------------------------------------------------------ | +| `interfaceId` | `bytes4` | The interface ID to check if the contract supports it. | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | --------------------------------------------------------------------------------------------- | +| `0` | `bool` | `true` if this contract implements the interface defined by `interfaceId`, `false` otherwise. | + +
+ +### transferOwnership + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#transferownership) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `transferOwnership(address)` +- Function selector: `0xf2fde38b` + +::: + +```solidity +function transferOwnership(address newOwner) external nonpayable; +``` + +_Transfer ownership initiated by `newOwner`._ + +Initiate the process of transferring ownership of the contract by setting the new owner as the pending owner. If the new owner is a contract that supports + implements LSP1, this will also attempt to notify the new owner that ownership has been transferred to them by calling the [`universalReceiver()`](#universalreceiver) function on the `newOwner` contract. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- When notifying the new owner via LSP1, the `typeId` used must be the `keccak256(...)` hash of [LSP0OwnershipTransferStarted]. +- Pending owner cannot accept ownership in the same tx via the LSP1 hook. + +
+ +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ----------------------------- | +| `newOwner` | `address` | The address of the new owner. | + +
+ +### universalReceiver + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#universalreceiver) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Function signature: `universalReceiver(bytes32,bytes)` +- Function selector: `0x6bb56a14` + +::: + +```solidity +function universalReceiver( + bytes32 typeId, + bytes receivedData +) external payable returns (bytes returnedValues); +``` + +_Notifying the contract by calling its `universalReceiver` function with the following informations: typeId: `typeId`; data: `data`._ + +Achieves the goal of [LSP-1-UniversalReceiver] by allowing the account to be notified about incoming/outgoing transactions and enabling reactions to these actions. The reaction is achieved by having two external contracts ([LSP1UniversalReceiverDelegate]) that react on the whole transaction and on the specific typeId, respectively. The function performs the following steps: + +1. Query the [ERC-725Y] storage with the data key [_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY]. + +- If there is an address stored under the data key, check if this address supports the LSP1 interfaceId. + +- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function. + +2. Query the [ERC-725Y] storage with the data key [_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX] + `bytes32(typeId)`. (Check [LSP-2-ERC725YJSONSchema] for encoding the data key) + +- If there is an address stored under the data key, check if this address supports the LSP1 interfaceId. + +- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) when receiving native tokens. +- [`UniversalReceiver`](#universalreceiver) event with the function parameters, call options, and the response of the UniversalReceiverDelegates (URD) contract that was called. + +
+ +#### Parameters + +| Name | Type | Description | +| -------------- | :-------: | -------------------------- | +| `typeId` | `bytes32` | The type of call received. | +| `receivedData` | `bytes` | The data received. | + +#### Returns + +| Name | Type | Description | +| ---------------- | :-----: | ------------------------------------------------------------------------------------------------------- | +| `returnedValues` | `bytes` | The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call. | + +
+ +## 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 + +```solidity +function _checkOwner() internal view; +``` + +Throws if the sender is not the owner. + +
+ +### \_setOwner + +```solidity +function _setOwner(address newOwner) internal nonpayable; +``` + +Changes the owner if `newOwner` and oldOwner are different +This pattern is useful in inheritance. + +
+ +### \_execute + +:::caution Warning + +Providing operation type DELEGATECALL (4) as argument will result in custom error {ERC725X_UnknownOperationType(4)} + +::: + +```solidity +function _execute( + uint256 operationType, + address target, + uint256 value, + bytes data +) internal nonpayable returns (bytes); +``` + +This function overrides the [`ERC725XCore`](#erc725xcore) internal [`_execute`](#_execute) function to disable operation type DELEGATECALL (4). + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------------------------------------------ | +| `operationType` | `uint256` | The operation type used: CALL = 0; CREATE = 1; CREATE2 = 2; STATICCALL = 3. | +| `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`. | + +
+ +### \_executeBatch + +```solidity +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`](#executebatch)). + +
+ +### \_executeCall + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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. + +```solidity +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 + +```solidity +function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; +``` + +This function overrides the [`ERC725YCore`](#erc725ycore) internal [`_setData`](#_setdata) function to optimize gas usage by emitting only the first 256 bytes of the `dataValue`. + +
+ +**Emitted events:** + +- [`DataChanged`](#datachanged) event with only the first 256 bytes of [`dataValue`](#datavalue). + +
+ +#### Parameters + +| Name | Type | Description | +| ----------- | :-------: | -------------------------------------- | +| `dataKey` | `bytes32` | The key to store the data value under. | +| `dataValue` | `bytes` | The data value to be stored. | + +
+ +### \_transferOwnership + +```solidity +function _transferOwnership(address newOwner) internal nonpayable; +``` + +Set the pending owner of the contract and cancel any renounce ownership process that was previously started. + +
+ +**Requirements:** + +- `newOwner` cannot be the address of the contract itself. + +
+ +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ------------------------------------- | +| `newOwner` | `address` | The address of the new pending owner. | + +
+ +### \_acceptOwnership + +```solidity +function _acceptOwnership() internal nonpayable; +``` + +Set the pending owner of the contract as the new owner. + +
+ +### \_renounceOwnership + +```solidity +function _renounceOwnership() internal nonpayable; +``` + +Initiate or confirm the process of renouncing ownership after a specific delay of blocks have passed. + +
+ +### \_supportsInterfaceInERC165Extension + +```solidity +function _supportsInterfaceInERC165Extension( + bytes4 interfaceId +) internal view returns (bool); +``` + +Returns whether the interfaceId being checked is supported in the extension of the +[`supportsInterface`](#supportsinterface) selector. +To be used by extendable contracts wishing to extend the ERC165 interfaceIds originally +supported by reading whether the interfaceId queried is supported in the `supportsInterface` +extension if the extension is set, if not it returns false. + +
+ +### \_getExtension + +```solidity +function _getExtension(bytes4 functionSelector) internal view returns (address); +``` + +Returns the extension address stored under the following data key: + +- [`_LSP17_EXTENSION_PREFIX`](#_lsp17_extension_prefix) + `` (Check [LSP2-ERC725YJSONSchema] for encoding the data key). + +- If no extension is stored, returns the address(0). + +
+ +### \_fallbackLSP17Extendable + +```solidity +function _fallbackLSP17Extendable( + bytes callData +) internal nonpayable returns (bytes); +``` + +Forwards the call to an extension mapped to a function selector. +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value` + +
+ +### \_validateAndIdentifyCaller + +```solidity +function _validateAndIdentifyCaller() internal view returns (bool isURD); +``` + +Modifier restricting the call to the owner of the contract and the UniversalReceiverDelegate + +
+ +## Events + +### ContractCreated + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#contractcreated) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `ContractCreated(uint256,address,uint256,bytes32)` +- Event topic hash: `0xa1fb700aaee2ae4a2ff6f91ce7eba292f89c2f5488b8ec4c5c5c8150692595c3` + +::: + +```solidity +event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 indexed value, bytes32 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` **`indexed`** | `uint256` | The amount of native tokens (in Wei) sent to fund the created contract on deployment. | +| `salt` | `bytes32` | The salt used to deterministically deploy the contract (`CREATE2` only). If `CREATE` opcode is used, the salt value will be `bytes32(0)`. | + +
+ +### DataChanged + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#datachanged) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `DataChanged(bytes32,bytes)` +- Event topic hash: `0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#executed) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `Executed(uint256,address,uint256,bytes4)` +- Event topic hash: `0x4810874456b8e6487bd861375cf6abd8e1c8bb5858c8ce36a86a04dabfac199e` + +::: + +```solidity +event Executed(uint256 indexed operationType, address indexed target, uint256 indexed value, bytes4 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` **`indexed`** | `uint256` | The amount of native tokens transferred along the call (in Wei). | +| `selector` | `bytes4` | The first 4 bytes (= function selector) of the data sent with the call. | + +
+ +### OwnershipRenounced + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#ownershiprenounced) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `OwnershipRenounced()` +- Event topic hash: `0xd1f66c3d2bc1993a86be5e3d33709d98f0442381befcedd29f578b9b2506b1ce` + +::: + +```solidity +event OwnershipRenounced(); +``` + +_Successfully renounced ownership of the contract. This contract is now owned by anyone, it's owner is `address(0)`._ + +Emitted when the ownership of the contract has been renounced. + +
+ +### OwnershipTransferStarted + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#ownershiptransferstarted) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `OwnershipTransferStarted(address,address)` +- Event topic hash: `0x38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700` + +::: + +```solidity +event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); +``` + +_The transfer of ownership of the contract was initiated. Pending new owner set to: `newOwner`._ + +Emitted when [`transferOwnership(..)`](#transferownership) was called and the first step of transferring ownership completed successfully which leads to [`pendingOwner`](#pendingowner) being updated. + +#### Parameters + +| Name | Type | Description | +| ----------------------------- | :-------: | ---------------------------------- | +| `previousOwner` **`indexed`** | `address` | The address of the previous owner. | +| `newOwner` **`indexed`** | `address` | The address of the new owner. | + +
+ +### OwnershipTransferred + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#ownershiptransferred) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `OwnershipTransferred(address,address)` +- Event topic hash: `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0` + +::: + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); +``` + +#### Parameters + +| Name | Type | Description | +| ----------------------------- | :-------: | ----------- | +| `previousOwner` **`indexed`** | `address` | - | +| `newOwner` **`indexed`** | `address` | - | + +
+ +### RenounceOwnershipStarted + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#renounceownershipstarted) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `RenounceOwnershipStarted()` +- Event topic hash: `0x81b7f830f1f0084db6497c486cbe6974c86488dcc4e3738eab94ab6d6b1653e7` + +::: + +```solidity +event RenounceOwnershipStarted(); +``` + +_Ownership renouncement initiated._ + +Emitted when starting the [`renounceOwnership(..)`](#renounceownership) 2-step process. + +
+ +### UniversalReceiver + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#universalreceiver) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` +- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` + +::: + +```solidity +event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); +``` + +\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` + +- Data received: `receivedData`.\* + +Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s + +#### Parameters + +| Name | Type | Description | +| ---------------------- | :-------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` **`indexed`** | `address` | The address of the EOA or smart contract that called the {universalReceiver(...)} function. | +| `value` **`indexed`** | `uint256` | The amount sent to the {universalReceiver(...)} function. | +| `typeId` **`indexed`** | `bytes32` | A `bytes32` unique identifier (= _"hook"_)that describe the type of notification, information or transaction received by the contract. Can be related to a specific standard or a hook. | +| `receivedData` | `bytes` | Any arbitrary data that was sent to the {universalReceiver(...)} function. | +| `returnedValue` | `bytes` | The value returned by the {universalReceiver(...)} function. | + +
+ +### ValueReceived + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#valuereceived) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Event signature: `ValueReceived(address,uint256)` +- Event topic hash: `0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493` + +::: + +```solidity +event ValueReceived(address indexed sender, uint256 indexed value); +``` + +_`value` native tokens received from `sender`._ + +Emitted when receiving native tokens. + +#### Parameters + +| Name | Type | Description | +| ---------------------- | :-------: | ---------------------------------------------------------- | +| `sender` **`indexed`** | `address` | The address that sent some native tokens to this contract. | +| `value` **`indexed`** | `uint256` | The amount of native tokens received. | + +
+ +## Errors + +### CannotTransferOwnershipToSelf + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#cannottransferownershiptoself) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `CannotTransferOwnershipToSelf()` +- Error hash: `0x43b248cd` + +::: + +```solidity +error CannotTransferOwnershipToSelf(); +``` + +_Cannot transfer ownership to the address of the contract itself._ + +Reverts when trying to transfer ownership to the `address(this)`. + +
+ +### ERC725X_ContractDeploymentFailed + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_contractdeploymentfailed) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_ContractDeploymentFailed()` +- Error hash: `0x0b07489b` + +::: + +```solidity +error ERC725X_ContractDeploymentFailed(); +``` + +Reverts when contract deployment failed via [`execute`](#execute) or [`executeBatch`](#executebatch) functions, This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_CreateOperationsRequireEmptyRecipientAddress + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_createoperationsrequireemptyrecipientaddress) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_CreateOperationsRequireEmptyRecipientAddress()` +- Error hash: `0x3041824a` + +::: + +```solidity +error ERC725X_CreateOperationsRequireEmptyRecipientAddress(); +``` + +Reverts when passing a `to` address that is not `address(0)` (= address zero) while deploying a contract via [`execute`](#execute) or [`executeBatch`](#executebatch) functions. This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_ExecuteParametersEmptyArray + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_executeparametersemptyarray) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_ExecuteParametersEmptyArray()` +- Error hash: `0xe9ad2b5f` + +::: + +```solidity +error ERC725X_ExecuteParametersEmptyArray(); +``` + +Reverts when one of the array parameter provided to the [`executeBatch`](#executebatch) function is an empty array. + +
+ +### ERC725X_ExecuteParametersLengthMismatch + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_executeparameterslengthmismatch) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_ExecuteParametersLengthMismatch()` +- Error hash: `0x3ff55f4d` + +::: + +```solidity +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`](#executebatch) function. + +
+ +### ERC725X_InsufficientBalance + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_insufficientbalance) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_InsufficientBalance(uint256,uint256)` +- Error hash: `0x0df9a8f8` + +::: + +```solidity +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_MsgValueDisallowedInStaticCall + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_msgvaluedisallowedinstaticcall) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_MsgValueDisallowedInStaticCall()` +- Error hash: `0x72f2bc6a` + +::: + +```solidity +error ERC725X_MsgValueDisallowedInStaticCall(); +``` + +Reverts when trying to send native tokens (`value` / `values[]` parameter of [`execute`](#execute) or [`executeBatch`](#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 + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_nocontractbytecodeprovided) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_NoContractBytecodeProvided()` +- Error hash: `0xb81cd8d9` + +::: + +```solidity +error ERC725X_NoContractBytecodeProvided(); +``` + +Reverts when no contract bytecode was provided as parameter when trying to deploy a contract via [`execute`](#execute) or [`executeBatch`](#executebatch). This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_UnknownOperationType + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725x_unknownoperationtype) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725X_UnknownOperationType(uint256)` +- Error hash: `0x7583b3bc` + +::: + +```solidity +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_DataKeysValuesLengthMismatch + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725y_datakeysvalueslengthmismatch) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725Y_DataKeysValuesLengthMismatch()` +- Error hash: `0x3bcc8979` + +::: + +```solidity +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`](#setdatabatch) function. + +
+ +### ERC725Y_MsgValueDisallowed + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#erc725y_msgvaluedisallowed) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `ERC725Y_MsgValueDisallowed()` +- Error hash: `0xf36ba737` + +::: + +```solidity +error ERC725Y_MsgValueDisallowed(); +``` + +Reverts when sending value to the [`setData`](#setdata) or [`setDataBatch`](#setdatabatch) function. + +
+ +### LSP14MustAcceptOwnershipInSeparateTransaction + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#lsp14mustacceptownershipinseparatetransaction) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `LSP14MustAcceptOwnershipInSeparateTransaction()` +- Error hash: `0x5758dd07` + +::: + +```solidity +error LSP14MustAcceptOwnershipInSeparateTransaction(); +``` + +_Cannot accept ownership in the same transaction with [`transferOwnership(...)`](#transferownership)._ + +Reverts when pending owner accept ownership in the same transaction of transferring ownership. + +
+ +### LSP1DelegateNotAllowedToSetDataKey + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#lsp1delegatenotallowedtosetdatakey) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `LSP1DelegateNotAllowedToSetDataKey(bytes32)` +- Error hash: `0x199611f1` + +::: + +```solidity +error LSP1DelegateNotAllowedToSetDataKey(bytes32 dataKey); +``` + +_Couldn't set the Data Key: `dataKey`._ + +Reverts when the Vault version of [LSP1UniversalReceiverDelegate] sets LSP1/6/17 Data Keys. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | --------------------------------------------------------------------------------------------- | +| `dataKey` | `bytes32` | The data key that the Vault version of [LSP1UniversalReceiverDelegate] is not allowed to set. | + +
+ +### NoExtensionFoundForFunctionSelector + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#noextensionfoundforfunctionselector) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `NoExtensionFoundForFunctionSelector(bytes4)` +- Error hash: `0xbb370b2b` + +::: + +```solidity +error NoExtensionFoundForFunctionSelector(bytes4 functionSelector); +``` + +reverts when there is no extension for the function selector being called with + +#### Parameters + +| Name | Type | Description | +| ------------------ | :------: | ----------- | +| `functionSelector` | `bytes4` | - | + +
+ +### NotInRenounceOwnershipInterval + +:::note References + +- Specification details: [**LSP-9-Vault**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-9-Vault.md#notinrenounceownershipinterval) +- Solidity implementation: [`LSP9Vault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP9Vault/LSP9Vault.sol) +- Error signature: `NotInRenounceOwnershipInterval(uint256,uint256)` +- Error hash: `0x8b9bf507` + +::: + +```solidity +error NotInRenounceOwnershipInterval( + uint256 renounceOwnershipStart, + uint256 renounceOwnershipEnd +); +``` + +_Cannot confirm ownership renouncement yet. The ownership renouncement is allowed from: `renounceOwnershipStart` until: `renounceOwnershipEnd`._ + +Reverts when trying to renounce ownership before the initial confirmation delay. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-------: | ----------------------------------------------------------------------- | +| `renounceOwnershipStart` | `uint256` | The start timestamp when one can confirm the renouncement of ownership. | +| `renounceOwnershipEnd` | `uint256` | The end timestamp when one can confirm the renouncement of ownership. | + +
diff --git a/docs/contracts/UniversalProfile.md b/docs/contracts/UniversalProfile.md new file mode 100644 index 000000000..5edd23ff9 --- /dev/null +++ b/docs/contracts/UniversalProfile.md @@ -0,0 +1,1756 @@ + + + +# UniversalProfile + +:::info Standard Specifications + +[`UniversalProfile`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md) + +::: +:::info Solidity implementation + +[`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) + +::: + +> implementation of a LUKSO's Universal Profile based on LSP3 + +Implementation of the ERC725Account + LSP1 universalReceiver + +## 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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#constructor) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) + +::: + +```solidity +constructor(address initialOwner); +``` + +_Deploying a UniversalProfile contract with owner set to address `initialOwner`._ + +Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store. The `constructor` also allows funding the contract on deployment. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when funding the contract on deployment. +- [`OwnershipTransferred`](#ownershiptransferred) event when `initialOwner` is set as the contract [`owner`](#owner). +- [`DataChanged`](#datachanged) event when setting the [`_LSP3_SUPPORTED_STANDARDS_KEY`](#_lsp3_supported_standards_key). + +
+ +#### Parameters + +| Name | Type | Description | +| -------------- | :-------: | ------------------------- | +| `initialOwner` | `address` | the owner of the contract | + +
+ +### fallback + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#fallback) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) + +::: + +```solidity +fallback() external payable; +``` + +
+ +### receive + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#receive) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) + +::: + +```solidity +receive() external payable; +``` + +
+ +### RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#renounce_ownership_confirmation_delay) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY()` +- Function selector: `0xead3fbdf` + +::: + +```solidity +function RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY() + external + view + returns (uint256); +``` + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `uint256` | - | + +
+ +### RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#renounce_ownership_confirmation_period) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD()` +- Function selector: `0x01bfba61` + +::: + +```solidity +function RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD() + external + view + returns (uint256); +``` + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `uint256` | - | + +
+ +### acceptOwnership + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#acceptownership) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `acceptOwnership()` +- Function selector: `0x79ba5097` + +::: + +```solidity +function acceptOwnership() external nonpayable; +``` + +_`msg.sender` is accepting ownership of contract: `address(this)`._ + +Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: + +- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. + +- The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. + +
+ +**Requirements:** + +- Only the [`pendingOwner`](#pendingowner) can call this function. +- When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification]. +- When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification]. + +
+ +
+ +### batchCalls + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#batchcalls) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `batchCalls(bytes[])` +- Function selector: `0x6963d438` + +::: + +:::info + +It's not possible to send value along the functions call due to the use of `delegatecall`. + +::: + +```solidity +function batchCalls(bytes[] data) external nonpayable returns (bytes[] results); +``` + +_Executing the following batch of abi-encoded function calls on the contract: `data`._ + +Allows a caller to batch different function calls in one call. Perform a `delegatecall` on self, to call different functions with preserving the context. + +#### Parameters + +| Name | Type | Description | +| ------ | :-------: | -------------------------------------------------------------------- | +| `data` | `bytes[]` | An array of ABI encoded function calls to be called on the contract. | + +#### Returns + +| Name | Type | Description | +| --------- | :-------: | ---------------------------------------------------------------- | +| `results` | `bytes[]` | An array of abi-encoded data returned by the functions executed. | + +
+ +### execute + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#execute) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `execute(uint256,address,uint256,bytes)` +- Function selector: `0x44c028fe` + +::: + +```solidity +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 `data` parameter. + +- deploy a contract by providing its creation bytecode in the `data` parameter. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- If a `value` is provided, the contract must have at least this amount in its balance to execute successfully. +- If the operation type is `CREATE` (1) or `CREATE2` (2), `target` must be `address(0)`. +- If the operation type is `STATICCALL` (3) or `DELEGATECALL` (4), `value` transfer is disallowed and must be 0. + +
+ +
+ +**Emitted events:** + +- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). +- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2). +- [`ValueReceived`](#valuereceived) event when receiving native tokens. + +
+ +#### 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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#executebatch) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `executeBatch(uint256[],address[],uint256[],bytes[])` +- Function selector: `0x31858452` + +::: + +```solidity +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`](#execute) but allowing multiple operations in the same transaction. + +
+ +**Requirements:** + +- The length of the parameters provided must be equal. +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- If a `value` is provided, the contract must have at least this amount in its balance to execute successfully. +- If the operation type is `CREATE` (1) or `CREATE2` (2), `target` must be `address(0)`. +- If the operation type is `STATICCALL` (3) or `DELEGATECALL` (4), `value` transfer is disallowed and must be 0. + +
+ +
+ +**Emitted events:** + +- [`Executed`](#executed) event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). (each iteration) +- [`ContractCreated`](#contractcreated) event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2) (each iteration) +- [`ValueReceived`](#valuereceived) event when receiving native tokens. + +
+ +#### 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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#getdata) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `getData(bytes32)` +- Function selector: `0x54f6127f` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#getdatabatch) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `getDataBatch(bytes32[])` +- Function selector: `0xdedff9c6` + +::: + +```solidity +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 | + +
+ +### isValidSignature + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#isvalidsignature) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `isValidSignature(bytes32,bytes)` +- Function selector: `0x1626ba7e` + +::: + +```solidity +function isValidSignature( + bytes32 dataHash, + bytes signature +) external view returns (bytes4 magicValue); +``` + +_Achieves the goal of [EIP-1271] by validating signatures of smart contracts according to their own logic._ + +Handles two cases: + +1. If the owner is an EOA, recovers an address from the hash and the signature provided: + +- Returns the `magicValue` if the address recovered is the same as the owner, indicating that it was a valid signature. + +- If the address is different, it returns the fail value indicating that the signature is not valid. + +2. If the owner is a smart contract, it forwards the call of [`isValidSignature()`](#isvalidsignature) to the owner contract: + +- If the contract fails or returns the fail value, the [`isValidSignature()`](#isvalidsignature) on the account returns the fail value, indicating that the signature is not valid. + +- If the [`isValidSignature()`](#isvalidsignature) on the owner returned the `magicValue`, the [`isValidSignature()`](#isvalidsignature) on the account returns the `magicValue`, indicating that it's a valid signature. + +#### Parameters + +| Name | Type | Description | +| ----------- | :-------: | ------------------------------------------------------------ | +| `dataHash` | `bytes32` | The hash of the data to be validated. | +| `signature` | `bytes` | A signature that can validate the previous parameter (Hash). | + +#### Returns + +| Name | Type | Description | +| ------------ | :------: | ----------------------------------------------------------------- | +| `magicValue` | `bytes4` | A `bytes4` value that indicates if the signature is valid or not. | + +
+ +### owner + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#owner) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `owner()` +- Function selector: `0x8da5cb5b` + +::: + +```solidity +function owner() external view returns (address); +``` + +Returns the address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `address` | - | + +
+ +### pendingOwner + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#pendingowner) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `pendingOwner()` +- Function selector: `0xe30c3978` + +::: + +:::info + +If no ownership transfer is in progress, the pendingOwner will be `address(0).`. + +::: + +```solidity +function pendingOwner() external view returns (address); +``` + +The address that ownership of the contract is transferred to. This address may use [`acceptOwnership()`](#acceptownership) to gain ownership of the contract. + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------- | +| `0` | `address` | - | + +
+ +### renounceOwnership + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#renounceownership) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `renounceOwnership()` +- Function selector: `0x715018a6` + +::: + +:::danger + +Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. + +::: + +```solidity +function renounceOwnership() external nonpayable; +``` + +_`msg.sender` is renouncing ownership of contract `address(this)`._ + +Renounce ownership of the contract in a 2-step process. + +1. The first call will initiate the process of renouncing ownership. + +2. The second call is used as a confirmation and will leave the contract without an owner. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +### setData + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#setdata) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `setData(bytes32,bytes)` +- Function selector: `0x7f23690c` + +::: + +```solidity +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:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when receiving native tokens. +- [`DataChanged`](#datachanged) event. + +
+ +#### 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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#setdatabatch) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `setDataBatch(bytes32[],bytes[])` +- Function selector: `0x97902421` + +::: + +```solidity +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`](#setdata) but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. + +
+ +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) event when receiving native tokens. +- [`DataChanged`](#datachanged) event. (on each iteration of setting data) + +
+ +#### 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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#supportsinterface) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `supportsInterface(bytes4)` +- Function selector: `0x01ffc9a7` + +::: + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool); +``` + +_Checking if this contract supports the interface defined by the `bytes4` interface ID `interfaceId`._ + +Achieves the goal of [ERC-165] to detect supported interfaces and [LSP-17-ContractExtension] by checking if the interfaceId being queried is supported on another linked extension. If the contract doesn't support the `interfaceId`, it forwards the call to the `supportsInterface` extension according to [LSP-17-ContractExtension], and checks if the extension implements the interface defined by `interfaceId`. + +#### Parameters + +| Name | Type | Description | +| ------------- | :------: | ------------------------------------------------------ | +| `interfaceId` | `bytes4` | The interface ID to check if the contract supports it. | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | --------------------------------------------------------------------------------------------- | +| `0` | `bool` | `true` if this contract implements the interface defined by `interfaceId`, `false` otherwise. | + +
+ +### transferOwnership + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#transferownership) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `transferOwnership(address)` +- Function selector: `0xf2fde38b` + +::: + +```solidity +function transferOwnership(address pendingNewOwner) external nonpayable; +``` + +_Transfer ownership initiated by `newOwner`._ + +Initiate the process of transferring ownership of the contract by setting the new owner as the pending owner. If the new owner is a contract that supports + implements LSP1, this will also attempt to notify the new owner that ownership has been transferred to them by calling the [`universalReceiver()`](#universalreceiver) function on the `newOwner` contract. + +
+ +**Requirements:** + +- Can be only called by the [`owner`](#owner) or by an authorised address that pass the verification check performed on the owner. +- When notifying the new owner via LSP1, the `typeId` used must be the `keccak256(...)` hash of [LSP0OwnershipTransferStarted]. +- Pending owner cannot accept ownership in the same tx via the LSP1 hook. + +
+ +#### Parameters + +| Name | Type | Description | +| ----------------- | :-------: | ----------- | +| `pendingNewOwner` | `address` | - | + +
+ +### universalReceiver + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#universalreceiver) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Function signature: `universalReceiver(bytes32,bytes)` +- Function selector: `0x6bb56a14` + +::: + +```solidity +function universalReceiver( + bytes32 typeId, + bytes receivedData +) external payable returns (bytes returnedValues); +``` + +_Notifying the contract by calling its `universalReceiver` function with the following informations: typeId: `typeId`; data: `data`._ + +Achieves the goal of [LSP-1-UniversalReceiver] by allowing the account to be notified about incoming/outgoing transactions and enabling reactions to these actions. The reaction is achieved by having two external contracts ([LSP1UniversalReceiverDelegate]) that react on the whole transaction and on the specific typeId, respectively. The function performs the following steps: + +1. Query the [ERC-725Y] storage with the data key [_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY]. + +- If there is an address stored under the data key, check if this address supports the LSP1 interfaceId. + +- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function. + +2. Query the [ERC-725Y] storage with the data key [_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX] + `bytes32(typeId)`. (Check [LSP-2-ERC725YJSONSchema] for encoding the data key) + +- If there is an address stored under the data key, check if this address supports the LSP1 interfaceId. + +- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function. + +
+ +**Emitted events:** + +- [`ValueReceived`](#valuereceived) when receiving native tokens. +- [`UniversalReceiver`](#universalreceiver) event with the function parameters, call options, and the response of the UniversalReceiverDelegates (URD) contract that was called. + +
+ +#### Parameters + +| Name | Type | Description | +| -------------- | :-------: | -------------------------- | +| `typeId` | `bytes32` | The type of call received. | +| `receivedData` | `bytes` | The data received. | + +#### Returns + +| Name | Type | Description | +| ---------------- | :-----: | ------------------------------------------------------------------------------------------------------- | +| `returnedValues` | `bytes` | The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call. | + +
+ +## 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 + +```solidity +function _checkOwner() internal view; +``` + +Throws if the sender is not the owner. + +
+ +### \_setOwner + +```solidity +function _setOwner(address newOwner) internal nonpayable; +``` + +Changes the owner if `newOwner` and oldOwner are different +This pattern is useful in inheritance. + +
+ +### \_execute + +```solidity +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`](#execute)). + +
+ +### \_executeBatch + +```solidity +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`](#executebatch)). + +
+ +### \_executeCall + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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 + +```solidity +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. + +```solidity +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 + +```solidity +function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; +``` + +This function overrides the [`ERC725YCore`](#erc725ycore) internal [`_setData`](#_setdata) function to optimize gas usage by emitting only the first 256 bytes of the `dataValue`. + +
+ +**Emitted events:** + +- [`DataChanged`](#datachanged) event with only the first 256 bytes of [`dataValue`](#datavalue). + +
+ +#### Parameters + +| Name | Type | Description | +| ----------- | :-------: | -------------------------------------- | +| `dataKey` | `bytes32` | The key to store the data value under. | +| `dataValue` | `bytes` | The data value to be stored. | + +
+ +### \_transferOwnership + +```solidity +function _transferOwnership(address newOwner) internal nonpayable; +``` + +Set the pending owner of the contract and cancel any renounce ownership process that was previously started. + +
+ +**Requirements:** + +- `newOwner` cannot be the address of the contract itself. + +
+ +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ------------------------------------- | +| `newOwner` | `address` | The address of the new pending owner. | + +
+ +### \_acceptOwnership + +```solidity +function _acceptOwnership() internal nonpayable; +``` + +Set the pending owner of the contract as the new owner. + +
+ +### \_renounceOwnership + +```solidity +function _renounceOwnership() internal nonpayable; +``` + +Initiate or confirm the process of renouncing ownership after a specific delay of blocks have passed. + +
+ +### \_supportsInterfaceInERC165Extension + +```solidity +function _supportsInterfaceInERC165Extension( + bytes4 interfaceId +) internal view returns (bool); +``` + +Returns whether the interfaceId being checked is supported in the extension of the +[`supportsInterface`](#supportsinterface) selector. +To be used by extendable contracts wishing to extend the ERC165 interfaceIds originally +supported by reading whether the interfaceId queried is supported in the `supportsInterface` +extension if the extension is set, if not it returns false. + +
+ +### \_getExtension + +```solidity +function _getExtension(bytes4 functionSelector) internal view returns (address); +``` + +Returns the extension address stored under the following data key: + +- [`_LSP17_EXTENSION_PREFIX`](#_lsp17_extension_prefix) + `` (Check [LSP2-ERC725YJSONSchema] for encoding the data key). + +- If no extension is stored, returns the address(0). + +
+ +### \_fallbackLSP17Extendable + +```solidity +function _fallbackLSP17Extendable( + bytes callData +) internal nonpayable returns (bytes); +``` + +Forwards the call to an extension mapped to a function selector. +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value` + +
+ +### \_verifyCall + +```solidity +function _verifyCall( + address logicVerifier +) internal nonpayable returns (bool verifyAfter); +``` + +Calls [`lsp20VerifyCall`](#lsp20verifycall) function on the logicVerifier. +Reverts in case the value returned does not match the magic value (lsp20VerifyCall selector) +Returns whether a verification after the execution should happen based on the last byte of the magicValue + +
+ +### \_verifyCallResult + +```solidity +function _verifyCallResult( + address logicVerifier, + bytes callResult +) internal nonpayable; +``` + +Calls [`lsp20VerifyCallResult`](#lsp20verifycallresult) function on the logicVerifier. +Reverts in case the value returned does not match the magic value (lsp20VerifyCallResult selector) + +
+ +### \_validateCall + +```solidity +function _validateCall( + bool postCall, + bool success, + bytes returnedData +) internal pure; +``` + +
+ +### \_revertWithLSP20DefaultError + +```solidity +function _revertWithLSP20DefaultError( + bool postCall, + bytes returnedData +) internal pure; +``` + +
+ +## Events + +### ContractCreated + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#contractcreated) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `ContractCreated(uint256,address,uint256,bytes32)` +- Event topic hash: `0xa1fb700aaee2ae4a2ff6f91ce7eba292f89c2f5488b8ec4c5c5c8150692595c3` + +::: + +```solidity +event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 indexed value, bytes32 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` **`indexed`** | `uint256` | The amount of native tokens (in Wei) sent to fund the created contract on deployment. | +| `salt` | `bytes32` | The salt used to deterministically deploy the contract (`CREATE2` only). If `CREATE` opcode is used, the salt value will be `bytes32(0)`. | + +
+ +### DataChanged + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#datachanged) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `DataChanged(bytes32,bytes)` +- Event topic hash: `0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#executed) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `Executed(uint256,address,uint256,bytes4)` +- Event topic hash: `0x4810874456b8e6487bd861375cf6abd8e1c8bb5858c8ce36a86a04dabfac199e` + +::: + +```solidity +event Executed(uint256 indexed operationType, address indexed target, uint256 indexed value, bytes4 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` **`indexed`** | `uint256` | The amount of native tokens transferred along the call (in Wei). | +| `selector` | `bytes4` | The first 4 bytes (= function selector) of the data sent with the call. | + +
+ +### OwnershipRenounced + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#ownershiprenounced) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `OwnershipRenounced()` +- Event topic hash: `0xd1f66c3d2bc1993a86be5e3d33709d98f0442381befcedd29f578b9b2506b1ce` + +::: + +```solidity +event OwnershipRenounced(); +``` + +_Successfully renounced ownership of the contract. This contract is now owned by anyone, it's owner is `address(0)`._ + +Emitted when the ownership of the contract has been renounced. + +
+ +### OwnershipTransferStarted + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#ownershiptransferstarted) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `OwnershipTransferStarted(address,address)` +- Event topic hash: `0x38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700` + +::: + +```solidity +event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); +``` + +_The transfer of ownership of the contract was initiated. Pending new owner set to: `newOwner`._ + +Emitted when [`transferOwnership(..)`](#transferownership) was called and the first step of transferring ownership completed successfully which leads to [`pendingOwner`](#pendingowner) being updated. + +#### Parameters + +| Name | Type | Description | +| ----------------------------- | :-------: | ---------------------------------- | +| `previousOwner` **`indexed`** | `address` | The address of the previous owner. | +| `newOwner` **`indexed`** | `address` | The address of the new owner. | + +
+ +### OwnershipTransferred + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#ownershiptransferred) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `OwnershipTransferred(address,address)` +- Event topic hash: `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0` + +::: + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); +``` + +#### Parameters + +| Name | Type | Description | +| ----------------------------- | :-------: | ----------- | +| `previousOwner` **`indexed`** | `address` | - | +| `newOwner` **`indexed`** | `address` | - | + +
+ +### RenounceOwnershipStarted + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#renounceownershipstarted) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `RenounceOwnershipStarted()` +- Event topic hash: `0x81b7f830f1f0084db6497c486cbe6974c86488dcc4e3738eab94ab6d6b1653e7` + +::: + +```solidity +event RenounceOwnershipStarted(); +``` + +_Ownership renouncement initiated._ + +Emitted when starting the [`renounceOwnership(..)`](#renounceownership) 2-step process. + +
+ +### UniversalReceiver + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#universalreceiver) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` +- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` + +::: + +```solidity +event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); +``` + +\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` + +- Data received: `receivedData`.\* + +Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s + +#### Parameters + +| Name | Type | Description | +| ---------------------- | :-------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` **`indexed`** | `address` | The address of the EOA or smart contract that called the {universalReceiver(...)} function. | +| `value` **`indexed`** | `uint256` | The amount sent to the {universalReceiver(...)} function. | +| `typeId` **`indexed`** | `bytes32` | A `bytes32` unique identifier (= _"hook"_)that describe the type of notification, information or transaction received by the contract. Can be related to a specific standard or a hook. | +| `receivedData` | `bytes` | Any arbitrary data that was sent to the {universalReceiver(...)} function. | +| `returnedValue` | `bytes` | The value returned by the {universalReceiver(...)} function. | + +
+ +### ValueReceived + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#valuereceived) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Event signature: `ValueReceived(address,uint256)` +- Event topic hash: `0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493` + +::: + +```solidity +event ValueReceived(address indexed sender, uint256 indexed value); +``` + +_`value` native tokens received from `sender`._ + +Emitted when receiving native tokens. + +#### Parameters + +| Name | Type | Description | +| ---------------------- | :-------: | ---------------------------------------------------------- | +| `sender` **`indexed`** | `address` | The address that sent some native tokens to this contract. | +| `value` **`indexed`** | `uint256` | The amount of native tokens received. | + +
+ +## Errors + +### CannotTransferOwnershipToSelf + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#cannottransferownershiptoself) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `CannotTransferOwnershipToSelf()` +- Error hash: `0x43b248cd` + +::: + +```solidity +error CannotTransferOwnershipToSelf(); +``` + +_Cannot transfer ownership to the address of the contract itself._ + +Reverts when trying to transfer ownership to the `address(this)`. + +
+ +### ERC725X_ContractDeploymentFailed + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_contractdeploymentfailed) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_ContractDeploymentFailed()` +- Error hash: `0x0b07489b` + +::: + +```solidity +error ERC725X_ContractDeploymentFailed(); +``` + +Reverts when contract deployment failed via [`execute`](#execute) or [`executeBatch`](#executebatch) functions, This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_CreateOperationsRequireEmptyRecipientAddress + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_createoperationsrequireemptyrecipientaddress) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_CreateOperationsRequireEmptyRecipientAddress()` +- Error hash: `0x3041824a` + +::: + +```solidity +error ERC725X_CreateOperationsRequireEmptyRecipientAddress(); +``` + +Reverts when passing a `to` address that is not `address(0)` (= address zero) while deploying a contract via [`execute`](#execute) or [`executeBatch`](#executebatch) functions. This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_ExecuteParametersEmptyArray + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_executeparametersemptyarray) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_ExecuteParametersEmptyArray()` +- Error hash: `0xe9ad2b5f` + +::: + +```solidity +error ERC725X_ExecuteParametersEmptyArray(); +``` + +Reverts when one of the array parameter provided to the [`executeBatch`](#executebatch) function is an empty array. + +
+ +### ERC725X_ExecuteParametersLengthMismatch + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_executeparameterslengthmismatch) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_ExecuteParametersLengthMismatch()` +- Error hash: `0x3ff55f4d` + +::: + +```solidity +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`](#executebatch) function. + +
+ +### ERC725X_InsufficientBalance + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_insufficientbalance) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_InsufficientBalance(uint256,uint256)` +- Error hash: `0x0df9a8f8` + +::: + +```solidity +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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_msgvaluedisallowedindelegatecall) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_MsgValueDisallowedInDelegateCall()` +- Error hash: `0x5ac83135` + +::: + +```solidity +error ERC725X_MsgValueDisallowedInDelegateCall(); +``` + +Reverts when trying to send native tokens (`value` / `values[]` parameter of [`execute`](#execute) or [`executeBatch`](#executebatch) functions) while making a `delegatecall` (`operationType == 4`). Sending native tokens via `staticcall` is not allowed because `msg.value` is persisting. + +
+ +### ERC725X_MsgValueDisallowedInStaticCall + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_msgvaluedisallowedinstaticcall) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_MsgValueDisallowedInStaticCall()` +- Error hash: `0x72f2bc6a` + +::: + +```solidity +error ERC725X_MsgValueDisallowedInStaticCall(); +``` + +Reverts when trying to send native tokens (`value` / `values[]` parameter of [`execute`](#execute) or [`executeBatch`](#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 + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_nocontractbytecodeprovided) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_NoContractBytecodeProvided()` +- Error hash: `0xb81cd8d9` + +::: + +```solidity +error ERC725X_NoContractBytecodeProvided(); +``` + +Reverts when no contract bytecode was provided as parameter when trying to deploy a contract via [`execute`](#execute) or [`executeBatch`](#executebatch). This error can occur using either operation type 1 (`CREATE`) or 2 (`CREATE2`). + +
+ +### ERC725X_UnknownOperationType + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725x_unknownoperationtype) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725X_UnknownOperationType(uint256)` +- Error hash: `0x7583b3bc` + +::: + +```solidity +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_DataKeysValuesLengthMismatch + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725y_datakeysvalueslengthmismatch) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725Y_DataKeysValuesLengthMismatch()` +- Error hash: `0x3bcc8979` + +::: + +```solidity +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`](#setdatabatch) function. + +
+ +### LSP14MustAcceptOwnershipInSeparateTransaction + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#lsp14mustacceptownershipinseparatetransaction) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `LSP14MustAcceptOwnershipInSeparateTransaction()` +- Error hash: `0x5758dd07` + +::: + +```solidity +error LSP14MustAcceptOwnershipInSeparateTransaction(); +``` + +_Cannot accept ownership in the same transaction with [`transferOwnership(...)`](#transferownership)._ + +Reverts when pending owner accept ownership in the same transaction of transferring ownership. + +
+ +### LSP20CallingVerifierFailed + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#lsp20callingverifierfailed) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `LSP20CallingVerifierFailed(bool)` +- Error hash: `0x8c6a8ae3` + +::: + +```solidity +error LSP20CallingVerifierFailed(bool postCall); +``` + +reverts when the call to the owner fail with no revert reason + +#### Parameters + +| Name | Type | Description | +| ---------- | :----: | ---------------------------------------------------- | +| `postCall` | `bool` | True if the execution call was done, False otherwise | + +
+ +### LSP20InvalidMagicValue + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#lsp20invalidmagicvalue) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `LSP20InvalidMagicValue(bool,bytes)` +- Error hash: `0xd088ec40` + +::: + +```solidity +error LSP20InvalidMagicValue(bool postCall, bytes returnedData); +``` + +reverts when the call to the owner does not return the magic value + +#### Parameters + +| Name | Type | Description | +| -------------- | :-----: | ---------------------------------------------------- | +| `postCall` | `bool` | True if the execution call was done, False otherwise | +| `returnedData` | `bytes` | The data returned by the call to the logic verifier | + +
+ +### NoExtensionFoundForFunctionSelector + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#noextensionfoundforfunctionselector) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `NoExtensionFoundForFunctionSelector(bytes4)` +- Error hash: `0xbb370b2b` + +::: + +```solidity +error NoExtensionFoundForFunctionSelector(bytes4 functionSelector); +``` + +reverts when there is no extension for the function selector being called with + +#### Parameters + +| Name | Type | Description | +| ------------------ | :------: | ----------- | +| `functionSelector` | `bytes4` | - | + +
+ +### NotInRenounceOwnershipInterval + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#notinrenounceownershipinterval) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `NotInRenounceOwnershipInterval(uint256,uint256)` +- Error hash: `0x8b9bf507` + +::: + +```solidity +error NotInRenounceOwnershipInterval( + uint256 renounceOwnershipStart, + uint256 renounceOwnershipEnd +); +``` + +_Cannot confirm ownership renouncement yet. The ownership renouncement is allowed from: `renounceOwnershipStart` until: `renounceOwnershipEnd`._ + +Reverts when trying to renounce ownership before the initial confirmation delay. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-------: | ----------------------------------------------------------------------- | +| `renounceOwnershipStart` | `uint256` | The start timestamp when one can confirm the renouncement of ownership. | +| `renounceOwnershipEnd` | `uint256` | The end timestamp when one can confirm the renouncement of ownership. | + +