diff --git a/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol b/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol index 3a480111d..199223a4f 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol @@ -15,14 +15,13 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { // --- Events /** - * @dev Emitted when `tokenId` token is transferred from `from` to `to`. - * @param operator The address of operator sending tokens - * @param from The address which tokens are sent - * @param to The receiving address - * @param tokenId The tokenId transferred - * @param allowNonLSP1Recipient When set to TRUE, `to` may be any address but - * when set to FALSE `to` must be a contract that supports LSP1 UniversalReceiver - * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses + * @dev Emitted when `tokenId` token is transferred from the `from` to the `to` address. + * @param operator The address of operator that sent the `tokenId` + * @param from The previous owner of the `tokenId` + * @param to The new owner of `tokenId` + * @param tokenId The tokenId that was transferred + * @param allowNonLSP1Recipient If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. + * @param data Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. */ event Transfer( address operator, @@ -34,10 +33,10 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { ); /** - * @dev Emitted when `tokenOwner` enables `operator` for `tokenId`. - * @param operator The address authorized as an operator - * @param tokenOwner The token owner - * @param tokenId The tokenId `operator` address has access to from `tokenOwner` + * @dev Emitted when `tokenOwner` enables `operator` to transfer or burn the `tokenId`. + * @param operator The address authorized as an operator. + * @param tokenOwner The owner of the `tokenId`. + * @param tokenId The tokenId `operator` address has access on behalf of `tokenOwner`. */ event AuthorizedOperator( address indexed operator, @@ -46,10 +45,10 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { ); /** - * @dev Emitted when `tokenOwner` disables `operator` for `tokenId`. - * @param operator The address revoked from operating - * @param tokenOwner The token owner - * @param tokenId The tokenId `operator` is revoked from operating + * @dev Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on its behalf. + * @param operator The address revoked from the operator array ({getOperatorsOf}). + * @param tokenOwner The owner of the `tokenId`. + * @param tokenId The tokenId `operator` is revoked from operating on. */ event RevokedOperator( address indexed operator, @@ -60,37 +59,36 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { // --- Token queries /** - * @dev Returns the number of existing tokens. - * @return The number of existing tokens + * @dev Returns the number of existing tokens that have been minted in this contract. + * @return The number of existing tokens. */ function totalSupply() external view returns (uint256); - // // --- Token owner queries - // /** - * @dev Returns the number of tokens owned by `tokenOwner`. - * @param tokenOwner The address to query - * @return The number of tokens owned by this address + * @dev Get the number of token IDs owned by `tokenOwner`. + + * @param tokenOwner The address to query * + * @return The total number of token IDs that `tokenOwner` owns. */ function balanceOf(address tokenOwner) external view returns (uint256); /** - * @param tokenId The tokenId to query - * @return The address owning the `tokenId` - * @dev Returns the `tokenOwner` address of the `tokenId` token. + * @dev Returns the list of `tokenIds` for the `tokenOwner` address. * - * Requirements: + * @param tokenId tokenOwner The address to query owned tokens + * @return The owner address of the given `tokenId`. * - * - `tokenId` must exist. + * @custom:requirements `tokenId` must exist. + * @custom:info if the `tokenId` is not owned by any address, the returned address will be `address(0)` */ function tokenOwnerOf(bytes32 tokenId) external view returns (address); /** - * @dev Returns the list of `tokenIds` for the `tokenOwner` address. - * @param tokenOwner The address to query owned tokens - * @return List of owned tokens by `tokenOwner` address + * @dev Returns the list of token IDs that the `tokenOwner` address owns. + * @param tokenOwner The address that we want to get the list of token IDs for. + * @return An array of `bytes32[] tokenIds` owned by `tokenOwner`. */ function tokenIdsOf( address tokenOwner @@ -99,50 +97,51 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { // --- Operator functionality /** - * @param operator The address to authorize as an operator. - * @param tokenId The tokenId operator has access to. - * @dev Makes `operator` address an operator of `tokenId`. - * - * See {isOperatorFor}. + * @dev Allow an `operator` address to transfer or burn a specific `tokenId` on behalf of its token owner. See {isOperatorFor}. * - * Requirements + * @param operator The address to authorize as an operator. + * @param tokenId The token ID operator has access to.. * + * @custom:requirements * - `tokenId` must exist. - * - caller must be current `tokenOwner` of `tokenId`. + * - caller MUST be the {tokenOwnerOf} `tokenId`. + * - the owner of a `tokenId` cannot grant itself as an `operator` (`operator` cannot be the calling address). * - `operator` cannot be the zero address. * - * Emits an {AuthorizedOperator} event. + * @custom:events {AuthorizedOperator} event. */ function authorizeOperator(address operator, bytes32 tokenId) external; /** - * @param operator The address to revoke as an operator. - * @param tokenId The tokenId `operator` is revoked from operating - * @dev Removes `operator` address as an operator of `tokenId`. + * @dev Remove access of `operator` for a given `tokenId`, disallowing it to transfer `tokenId` on behalf of its owner. + * See also {isOperatorFor}. * - * See {isOperatorFor}. - * - * Requirements + * @param operator The address to revoke as an operator. + * @param tokenId The tokenId `operator` is revoked from operating on. * + * @custom:requirements * - `tokenId` must exist. - * - caller must be current `tokenOwner` of `tokenId`. + * - caller must be the {tokenOwnerOf} `tokenId`. + * - the owner of a `tokenId` cannot grant revoke itself as an `operator` (`operator` cannot be the calling address). * - `operator` cannot be the zero address. * - * Emits a {RevokedOperator} event. + * @custom:events {RevokedOperator} event with address of the operator being revoked for the caller (token owner).. */ function revokeOperator(address operator, bytes32 tokenId) external; /** - * @param operator The address to query - * @param tokenId The tokenId to query - * @return True if the owner of `tokenId` is `operator` address, false otherwise - * @dev Returns whether `operator` address is an operator of `tokenId`. - * Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own - * operator. + * @dev Returns whether `operator` address is an operator for a given `tokenId`. * - * Requirements + * @param operator The address to query operator status for. + * @param tokenId The token ID to check if `operator` is allowed to operate on. + * + * @return `true` if `operator` is an operator for `tokenId`, `false` otherwise. * + * @custom:requirements * - `tokenId` must exist. + * - caller must be the current {tokenOwnerOf} `tokenId`. + * + * @custom:info The tokenOwner is its own operator. */ function isOperatorFor( address operator, @@ -150,12 +149,12 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { ) external view returns (bool); /** - * @param tokenId The tokenId to query - * @return The list of operators for the `tokenId` - * @dev Returns all `operator` addresses of `tokenId`. + * @dev Returns all `operator` addresses that are allowed to transfer or burn a specific `tokenId` on behalf of its owner. * - * Requirements + * @param tokenId The token ID to get the operators for. + * @return An array of operators allowed to transfer or burn a specific `tokenId`. * + * Requirements * - `tokenId` must exist. */ function getOperatorsOf( @@ -165,23 +164,37 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { // --- Transfer functionality /** - * @param from The sending address. - * @param to The receiving address. - * @param tokenId The tokenId to transfer. - * @param allowNonLSP1Recipient When set to TRUE, to may be any address but - * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver - * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. - * @dev Transfers `tokenId` token from `from` to `to`. + * @dev Transfer a given `tokenId` token from the `from` address to the `to` address. * - * Requirements: + * If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. * + * The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) + * or contracts that do not implement the LSP1 standard. + * + * @param from The address that owns the given `tokenId`. + * @param to The address that will receive the `tokenId`. + * @param tokenId The token ID to transfer. + * @param allowNonLSP1Recipient When set to `true`, the `to` address CAN be any addres. + * When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. + * @param data Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. + * + * @custom:requirements * - `from` cannot be the zero address. * - `to` cannot be the zero address. - * - `from` and `to` cannot be the same address. - * - `tokenId` token must be owned by `from`. - * - If the caller is not `from`, it must be an operator of `tokenId`. + * - `from` and `to` cannot be the same address (`from` cannot send the `tokenId` to itself). + * - `from` must own the given `tokenId`. + * - If the caller is not `from`, it must be an operator for the `tokenId`. + * + * @custom:events + * - {Transfer} event when the `tokenId` is successfully transferred. + * + * @custom:hint The `allowNonLSP1Recipient` parameter **MUST be set to `true`** to transfer tokens to Externally Owned Accounts (EOAs) + * or contracts that do not implement the LSP1 Universal Receiver Standard. Otherwise the function will revert making the transfer fail. + * + * @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `allowNonLSP1Recipient` is set to `true` or `false`. * - * Emits a {Transfer} event. + * @custom:warning Be aware that when either the sender or the recipient can have logic that revert in their `universalReceiver(...)` function when being notified. + * This even if the `allowNonLSP1Recipient` was set to `true`. */ function transfer( address from, @@ -192,26 +205,27 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y { ) external; /** - * @param from The list of sending addresses. - * @param to The list of receiving addresses. - * @param tokenId The list of tokenId to transfer. - * @param allowNonLSP1Recipient When set to TRUE, to may be any address but - * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver - * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. - * - * @dev Transfers many tokens based on the list `from`, `to`, `tokenId`. If any transfer fails - * the call will revert. - * - * Requirements: - * - * - `from`, `to`, `tokenId` lists are the same length. - * - no values in `from` can be the zero address. - * - no values in `to` can be the zero address. - * - `from` and `to` cannot be the same address at the same index of each lists. - * - each `tokenId` token must be owned by `from`. + * @dev Transfers multiple tokens at once based on the arrays of `from`, `to` and `tokenId`. + * If any transfer fails, the whole call will revert. + * + * @param from An array of sending addresses. + * @param to An array of recipient addresses. + * @param tokenId An array of token IDs to transfer. + * @param allowNonLSP1Recipient When set to `true`, `to` may be any address. + * When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. + * @param data Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. + * + * + * @custom:requirements + * - The arrays of `from`, `to` and `tokenId` must have the same length. + * - no values in the `from` array can be the zero address. + * - no values in the `to` array can be the zero address. + * - `from` and `to` cannot be the same address at the same index on each arrays. + * - each `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be an operator of each `tokenId`. * - * Emits {Transfer} events. + * @custom:events + * - {Transfer} events on each successful token transfer. */ function transferBatch( address[] memory from, diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol index 8b6b8fb1a..5942c8d6b 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol @@ -17,9 +17,15 @@ import { import {_INTERFACEID_LSP8} from "./LSP8Constants.sol"; /** - * @title LSP8IdentifiableDigitalAsset contract + * @title Implementation of a LSP8 Identifiable Digital Asset, a contract that represents a non-fungible token. * @author Matthew Stevens - * @dev Implementation of a LSP8 compliant contract. + * + * @dev Standard implementation contract of the LSP8 standard. + * + * Minting and transferring are done by providing a unique `tokenId`. + * This implementation is agnostic to the way tokens are created. + * A supply mechanism has to be added in a derived contract using {_mint} + * For a generic mechanism, see {LSP7Mintable}. */ abstract contract LSP8IdentifiableDigitalAsset is LSP4DigitalAssetMetadata, @@ -38,7 +44,7 @@ abstract contract LSP8IdentifiableDigitalAsset is ) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {} /** - * @dev See {IERC165-supportsInterface}. + * @inheritdoc IERC165 */ function supportsInterface( bytes4 interfaceId diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol index d651ca784..469e86a6b 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol @@ -253,7 +253,10 @@ abstract contract LSP8IdentifiableDigitalAssetCore is } /** - * @dev clear all the operators for the `tokenId` + * @dev revoke all the current operators for a specific `tokenId` token which belongs to `tokenOwner`. + * + * @param tokenOwner The address that is the owner of the `tokenId`. + * @param tokenId The token to remove the associated operators for. */ function _clearOperators( address tokenOwner, @@ -284,8 +287,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is /** * @dev Returns whether `tokenId` exists. * - * Tokens start existing when they are minted (`_mint`), and stop existing when they are burned - * (`_burn`). + * Tokens start existing when they are minted ({_mint}), and stop existing when they are burned ({_burn}). */ function _exists(bytes32 tokenId) internal view virtual returns (bool) { return _tokenOwners[tokenId] != address(0); @@ -301,14 +303,18 @@ abstract contract LSP8IdentifiableDigitalAssetCore is } /** - * @dev Mints `tokenId` and transfers it to `to`. - * - * Requirements: + * @dev Create `tokenId` by minting it and transfers it to `to`. * - * - `tokenId` must not exist. + * @custom:requirements + * - `tokenId` must not exist and not have been already minted. * - `to` cannot be the zero address. * - * Emits a {Transfer} event. + * @param to The address that will receive the minted `tokenId`. + * @param tokenId The token ID to create (= mint). + * @param allowNonLSP1Recipient When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. + * @param data Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. + * + * @custom:events {Transfer} event with `address(0)` as `from` address. */ function _mint( address to, @@ -348,13 +354,24 @@ abstract contract LSP8IdentifiableDigitalAssetCore is } /** - * @dev Destroys `tokenId`, clearing authorized operators. + * @dev Burn a specific `tokenId`, removing the `tokenId` from the {tokenIdsOf} the caller and decreasing its {balanceOf} by -1. + * This will also clear all the operators allowed to transfer the `tokenId`. + * + * The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 {universalReceiver} + * function, if it is a contract that supports the LSP1 interface. Its {universalReceiver} function will receive + * all the parameters in the calldata packed encoded. + * + * Any logic in the {_beforeTokenTransfer} function will run before burning `tokenId` and updating the balances. * - * Requirements: + * @param tokenId The token to burn. + * @param data Any additional data the caller wants included in the emitted event, and sent in the LSP1 hook on the token owner's address. * + * @custom:hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. + * + * @custom:requirements * - `tokenId` must exist. * - * Emits a {Transfer} event. + * @custom:events {Transfer} event with `address(0)` as the `to` address. */ function _burn(bytes32 tokenId, bytes memory data) internal virtual { address tokenOwner = tokenOwnerOf(tokenId); @@ -382,14 +399,27 @@ abstract contract LSP8IdentifiableDigitalAssetCore is } /** - * @dev Transfers `tokenId` from `from` to `to`. + * @dev Change the owner of the `tokenId` from `from` to `to`. + * + * Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 {universalReceiver} + * function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive + * all the parameters in the calldata packed encoded. + * + * Any logic in the {_beforeTokenTransfer} function will run before changing the owner of `tokenId`. * - * Requirements: + * @param from The sender address. + * @param to The recipient address. + * @param tokenId The token to transfer. + * @param allowNonLSP1Recipient When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. + * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. * + * @custom:requirements * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - * Emits a {Transfer} event. + * @custom:events {Transfer} event. + * + * @custom:danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. */ function _transfer( address from, @@ -430,16 +460,12 @@ abstract contract LSP8IdentifiableDigitalAssetCore is } /** - * @dev Hook that is called before any token transfer. This includes minting - * and burning. - * - * Calling conditions: + * @dev Hook that is called before any token transfer, including minting and burning. + * * Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. * - * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be - * transferred to `to`. - * - When `from` is zero, `tokenId` will be minted for `to`. - * - When `to` is zero, ``from``'s `tokenId` will be burned. - * - `from` and `to` are never both zero. + * @param from The sender address + * @param to The recipient address + * @param tokenId The tokenId to transfer */ function _beforeTokenTransfer( address from, diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol index 0103a474c..14af58cb4 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol @@ -17,9 +17,15 @@ import { import {_INTERFACEID_LSP8} from "./LSP8Constants.sol"; /** - * @title LSP8IdentifiableDigitalAsset contract + * @title Implementation of a LSP8 Identifiable Digital Asset, a contract that represents a non-fungible token. * @author Matthew Stevens - * @dev Proxy Implementation of a LSP8 compliant contract. + * + * @dev Inheritable proxy implementation contract of the LSP8 standard. + * + * Minting and transferring are done using by giving a unique `tokenId`. + * This implementation is agnostic to the way tokens are created. + * A supply mechanism has to be added in a derived contract using {_mint} + * For a generic mechanism, see {LSP7Mintable}. */ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is LSP4DigitalAssetMetadataInitAbstract, diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md new file mode 100644 index 000000000..3e4055dba --- /dev/null +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md @@ -0,0 +1,1343 @@ + + + +# LSP8IdentifiableDigitalAsset + +:::info Standard Specifications + +[`LSP-8-IdentifiableDigitalAsset`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md) + +::: +:::info Solidity implementation + +[`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) + +::: + +> Implementation of a LSP8 Identifiable Digital Asset, a contract that represents a non-fungible token. + +Standard implementation contract of the LSP8 standard. Minting and transferring are done using by giving a unique `tokenId`. This implementation is agnostic to the way tokens are created. A supply mechanism has to be added in a derived contract using [`_mint`](#_mint) For a generic mechanism, see [`LSP7Mintable`](#lsp7mintable). + +## 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. + +### authorizeOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#authorizeoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `authorizeOperator(address,bytes32)` +- Function selector: `0xcf5182ba` + +::: + +```solidity +function authorizeOperator( + address operator, + bytes32 tokenId +) external nonpayable; +``` + +Allow an `operator` address to transfer or burn a specific `tokenId` on behalf of its token owner. See [`isOperatorFor`](#isoperatorfor). + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ---------------------------------------- | +| `operator` | `address` | The address to authorize as an operator. | +| `tokenId` | `bytes32` | The token ID operator has access to.. | + +
+ +### balanceOf + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#balanceof) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `balanceOf(address)` +- Function selector: `0x70a08231` + +::: + +```solidity +function balanceOf(address tokenOwner) external view returns (uint256); +``` + +Get the number of token IDs owned by `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| ------------ | :-------: | ----------------------- | +| `tokenOwner` | `address` | The address to query \* | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------------------------------------------------- | +| `0` | `uint256` | The total number of token IDs that `tokenOwner` owns. | + +
+ +### getData + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#getdata) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `getData(bytes32)` +- Function selector: `0x54f6127f` + +::: + +```solidity +function getData(bytes32 dataKey) external view returns (bytes dataValue); +``` + +_Gets singular data at a given `dataKey`_ + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | ------------------------------- | +| `dataKey` | `bytes32` | The key which value to retrieve | + +#### Returns + +| Name | Type | Description | +| ----------- | :-----: | -------------------------- | +| `dataValue` | `bytes` | The data stored at the key | + +
+ +### getDataBatch + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#getdatabatch) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `getDataBatch(bytes32[])` +- Function selector: `0xdedff9c6` + +::: + +```solidity +function getDataBatch( + bytes32[] dataKeys +) external view returns (bytes[] dataValues); +``` + +_Gets array of data for multiple given keys_ + +#### 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 | + +
+ +### getOperatorsOf + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#getoperatorsof) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `getOperatorsOf(bytes32)` +- Function selector: `0x49a6078d` + +::: + +```solidity +function getOperatorsOf(bytes32 tokenId) external view returns (address[]); +``` + +Returns all `operator` addresses that are allowed to transfer or burn a specific `tokenId` on behalf of its owner. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `tokenId` | `bytes32` | The token ID to get the operators for. | + +#### Returns + +| Name | Type | Description | +| ---- | :---------: | ------------------------------------------------------------------------------------------------------------ | +| `0` | `address[]` | An array of operators allowed to transfer or burn a specific `tokenId`. Requirements - `tokenId` must exist. | + +
+ +### isOperatorFor + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#isoperatorfor) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `isOperatorFor(address,bytes32)` +- Function selector: `0x2a3654a4` + +::: + +```solidity +function isOperatorFor( + address operator, + bytes32 tokenId +) external view returns (bool); +``` + +Returns whether `operator` address is an operator for a given `tokenId`. + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ------------------------------------------------------------- | +| `operator` | `address` | The address to query operator status for. | +| `tokenId` | `bytes32` | The token ID to check if `operator` is allowed to operate on. | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | --------------------------------------------------------------------- | +| `0` | `bool` | `true` if `operator` is an operator for `tokenId`, `false` otherwise. | + +
+ +### owner + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#owner) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.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` | - | + +
+ +### renounceOwnership + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#renounceownership) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `renounceOwnership()` +- Function selector: `0x715018a6` + +::: + +```solidity +function renounceOwnership() external nonpayable; +``` + +Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner. + +
+ +### revokeOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#revokeoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `revokeOperator(address,bytes32)` +- Function selector: `0x0b0c6d82` + +::: + +```solidity +function revokeOperator(address operator, bytes32 tokenId) external nonpayable; +``` + +Remove access of `operator` for a given `tokenId`, disallowing it to transfer `tokenId` on behalf of its owner. See also [`isOperatorFor`](#isoperatorfor). + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ---------------------------------------------------- | +| `operator` | `address` | The address to revoke as an operator. | +| `tokenId` | `bytes32` | The tokenId `operator` is revoked from operating on. | + +
+ +### setData + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#setdata) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `setData(bytes32,bytes)` +- Function selector: `0x7f23690c` + +::: + +```solidity +function setData(bytes32 dataKey, bytes dataValue) external payable; +``` + +_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. | + +
+ +### setDataBatch + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#setdatabatch) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `setDataBatch(bytes32[],bytes[])` +- Function selector: `0x97902421` + +::: + +```solidity +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 + +0. Emits a [`DataChanged`](#datachanged) event. + +#### Parameters + +| Name | Type | Description | +| ------------ | :---------: | ---------------------------------------- | +| `dataKeys` | `bytes32[]` | The array of data keys for values to set | +| `dataValues` | `bytes[]` | The array of values to set | + +
+ +### supportsInterface + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#supportsinterface) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `supportsInterface(bytes4)` +- Function selector: `0x01ffc9a7` + +::: + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool); +``` + +Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas. + +#### Parameters + +| Name | Type | Description | +| ------------- | :------: | ----------- | +| `interfaceId` | `bytes4` | - | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | ----------- | +| `0` | `bool` | - | + +
+ +### tokenIdsOf + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#tokenidsof) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `tokenIdsOf(address)` +- Function selector: `0xa3b261f2` + +::: + +```solidity +function tokenIdsOf(address tokenOwner) external view returns (bytes32[]); +``` + +Returns the list of token IDs that the `tokenOwner` address owns. + +#### Parameters + +| Name | Type | Description | +| ------------ | :-------: | ---------------------------------------------------------- | +| `tokenOwner` | `address` | The address that we want to get the list of token IDs for. | + +#### Returns + +| Name | Type | Description | +| ---- | :---------: | ------------------------------------------------------- | +| `0` | `bytes32[]` | An array of `bytes32[] tokenIds` owned by `tokenOwner`. | + +
+ +### tokenOwnerOf + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#tokenownerof) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `tokenOwnerOf(bytes32)` +- Function selector: `0x217b2270` + +::: + +```solidity +function tokenOwnerOf(bytes32 tokenId) external view returns (address); +``` + +Returns the list of `tokenIds` for the `tokenOwner` address. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------- | +| `tokenId` | `bytes32` | tokenOwner The address to query owned tokens | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------------------------------------- | +| `0` | `address` | The owner address of the given `tokenId`. | + +
+ +### totalSupply + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#totalsupply) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `totalSupply()` +- Function selector: `0x18160ddd` + +::: + +```solidity +function totalSupply() external view returns (uint256); +``` + +Returns the number of existing tokens that have been minted in this contract. + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ------------------------------ | +| `0` | `uint256` | The number of existing tokens. | + +
+ +### transfer + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#transfer) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `transfer(address,address,bytes32,bool,bytes)` +- Function selector: `0x511b6952` + +::: + +```solidity +function transfer( + address from, + address to, + bytes32 tokenId, + bool allowNonLSP1Recipient, + bytes data +) external nonpayable; +``` + +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. + +#### Parameters + +| Name | Type | Description | +| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | + +
+ +### transferBatch + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#transferbatch) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `transferBatch(address[],address[],bytes32[],bool[],bytes[])` +- Function selector: `0x7e87632c` + +::: + +```solidity +function transferBatch( + address[] from, + address[] to, + bytes32[] tokenId, + bool[] allowNonLSP1Recipient, + bytes[] data +) external nonpayable; +``` + +Transfers multiple tokens at once based on the arrays of `from`, `to` and `tokenId`. If any transfer fails, the whole call will revert. + +#### Parameters + +| Name | Type | Description | +| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | + +
+ +### transferOwnership + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#transferownership) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Function signature: `transferOwnership(address)` +- Function selector: `0xf2fde38b` + +::: + +```solidity +function transferOwnership(address newOwner) external nonpayable; +``` + +Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner. + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ----------- | +| `newOwner` | `address` | - | + +
+ +## Internal Methods + +Any method labeled as `internal` serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs. + +Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities. + +### \_checkOwner + +```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. + +
+ +### \_getData + +```solidity +function _getData(bytes32 dataKey) internal view returns (bytes dataValue); +``` + +
+ +### \_setData + +```solidity +function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; +``` + +Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue + +
+ +### \_isOperatorOrOwner + +```solidity +function _isOperatorOrOwner( + address caller, + bytes32 tokenId +) internal view returns (bool); +``` + +verifies if the `caller` is operator or owner for the `tokenId` + +#### Returns + +| Name | Type | Description | +| ---- | :----: | -------------------------------------------- | +| `0` | `bool` | true if `caller` is either operator or owner | + +
+ +### \_revokeOperator + +```solidity +function _revokeOperator( + address operator, + address tokenOwner, + bytes32 tokenId +) internal nonpayable; +``` + +removes `operator` from the list of operators for the `tokenId` + +
+ +### \_clearOperators + +```solidity +function _clearOperators( + address tokenOwner, + bytes32 tokenId +) internal nonpayable; +``` + +revoke all the current operators for a specific `tokenId` token which belongs to `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| ------------ | :-------: | ------------------------------------------------- | +| `tokenOwner` | `address` | The address that is the owner of the `tokenId`. | +| `tokenId` | `bytes32` | The token to remove the associated operators for. | + +
+ +### \_exists + +```solidity +function _exists(bytes32 tokenId) internal view returns (bool); +``` + +Returns whether `tokenId` exists. +Tokens start existing when they are minted ([`_mint`](#_mint)), and stop existing when they are burned ([`_burn`](#_burn)). + +
+ +### \_existsOrError + +```solidity +function _existsOrError(bytes32 tokenId) internal view; +``` + +When `tokenId` does not exist then revert with an error. + +
+ +### \_mint + +```solidity +function _mint( + address to, + bytes32 tokenId, + bool allowNonLSP1Recipient, + bytes data +) internal nonpayable; +``` + +Create `tokenId` by minting it and transfers it to `to`. + +
+ +**Emitted events:** + +- [`Transfer`](#transfer) event with `address(0)` as `from` address. + +
+ +#### Parameters + +| Name | Type | Description | +| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | @param tokenId The token ID to create (= mint). | +| `tokenId` | `bytes32` | The token ID to create (= mint). | +| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. | + +
+ +### \_burn + +:::tip Hint + +In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. + +::: + +```solidity +function _burn(bytes32 tokenId, bytes data) internal nonpayable; +``` + +Burn a specific `tokenId`, removing the `tokenId` from the [`tokenIdsOf`](#tokenidsof) the caller and decreasing its [`balanceOf`](#balanceof) by -1. +This will also clear all the operators allowed to transfer the `tokenId`. +The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) +function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive +all the parameters in the calldata packed encoded. +Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances. + +
+ +**Emitted events:** + +- [`Transfer`](#transfer) event with `address(0)` as the `to` address. + +
+ +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | --------------------------------------------------------------------------------------------------------------------------- | +| `tokenId` | `bytes32` | The token to burn. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the LSP1 hook on the token owner's address. | + +
+ +### \_transfer + +:::danger + +This internal function does not check if the sender is authorized or not to operate on the `tokenId`. + +::: + +```solidity +function _transfer( + address from, + address to, + bytes32 tokenId, + bool allowNonLSP1Recipient, + bytes data +) internal nonpayable; +``` + +Change the owner of the `tokenId` from `from` to `to`. +Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) +function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive +all the parameters in the calldata packed encoded. +Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`. + +
+ +**Emitted events:** + +- [`Transfer`](#transfer) event. + +
+ +#### Parameters + +| Name | Type | Description | +| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | + +
+ +### \_beforeTokenTransfer + +```solidity +function _beforeTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` + +Hook that is called before any token transfer, including minting and burning. + +- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_notifyTokenSender + +```solidity +function _notifyTokenSender(address from, bytes lsp1Data) internal nonpayable; +``` + +An attempt is made to notify the token sender about the `tokenId` changing owners using +LSP1 interface. + +
+ +### \_notifyTokenReceiver + +```solidity +function _notifyTokenReceiver( + address to, + bool allowNonLSP1Recipient, + bytes lsp1Data +) internal nonpayable; +``` + +An attempt is made to notify the token receiver about the `tokenId` changing owners +using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +The receiver may revert when the token being sent is not wanted. + +
+ +## Events + +### AuthorizedOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#authorizedoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Event signature: `AuthorizedOperator(address,address,bytes32)` +- Event topic hash: `0x34b797fc5a526f7bf1d2b5de25f6564fd85ae364e3ee939aee7c1ac27871a988` + +::: + +```solidity +event AuthorizedOperator(address indexed operator, address indexed tokenOwner, bytes32 indexed tokenId); +``` + +Emitted when `tokenOwner` enables `operator` to transfer or burn `tokenId` on its behalf. + +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | -------------------------------------------------------------------- | +| `operator` **`indexed`** | `address` | The address authorized as an operator. | +| `tokenOwner` **`indexed`** | `address` | The owner of the `tokenId`. | +| `tokenId` **`indexed`** | `bytes32` | The tokenId `operator` address has access on behalf of `tokenOwner`. | + +
+ +### DataChanged + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#datachanged) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Event signature: `DataChanged(bytes32,bytes)` +- Event topic hash: `0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2` + +::: + +```solidity +event DataChanged(bytes32 indexed dataKey, bytes dataValue); +``` + +_Emitted when data at a key is changed_ + +#### Parameters + +| Name | Type | Description | +| ----------------------- | :-------: | ------------------------------------ | +| `dataKey` **`indexed`** | `bytes32` | The data key which data value is set | +| `dataValue` | `bytes` | The data value to set | + +
+ +### OwnershipTransferred + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#ownershiptransferred) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.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` | - | + +
+ +### RevokedOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#revokedoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Event signature: `RevokedOperator(address,address,bytes32)` +- Event topic hash: `0x17d5389f6ab6adb2647dfa0aa365c323d37adacc30b33a65310b6158ce1373d5` + +::: + +```solidity +event RevokedOperator(address indexed operator, address indexed tokenOwner, bytes32 indexed tokenId); +``` + +Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on its behalf. + +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | ---------------------------------------------------- | +| `operator` **`indexed`** | `address` | The address revoked as an operator. | +| `tokenOwner` **`indexed`** | `address` | The owner of the `tokenId`. | +| `tokenId` **`indexed`** | `bytes32` | The tokenId `operator` is revoked from operating on. | + +
+ +### Transfer + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#transfer) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Event signature: `Transfer(address,address,address,bytes32,bool,bytes)` +- Event topic hash: `0xb333c813a7426a7a11e2b190cad52c44119421594b47f6f32ace6d8c7207b2bf` + +::: + +```solidity +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +``` + +Emitted when `tokenId` token is transferred from the `from` to the `to` address. + +#### Parameters + +| Name | Type | Description | +| ----------------------- | :-------: | ---------------------------------------------------------------------------------------------------------------------------------- | +| `operator` | `address` | The address of operator that sent the `tokenId` | +| `from` **`indexed`** | `address` | The previous owner of the `tokenId` | +| `to` **`indexed`** | `address` | The new owner of `tokenId` | +| `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | +| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. | + +
+ +## Errors + +### ERC725Y_DataKeysValuesEmptyArray + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#erc725y_datakeysvaluesemptyarray) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `ERC725Y_DataKeysValuesEmptyArray()` +- Error hash: `0x97da5f95` + +::: + +```solidity +error ERC725Y_DataKeysValuesEmptyArray(); +``` + +reverts when one of the array parameter provided to `setDataBatch` is an empty array + +
+ +### ERC725Y_DataKeysValuesLengthMismatch + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#erc725y_datakeysvalueslengthmismatch) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `ERC725Y_DataKeysValuesLengthMismatch()` +- Error hash: `0x3bcc8979` + +::: + +```solidity +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. + +
+ +### ERC725Y_MsgValueDisallowed + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#erc725y_msgvaluedisallowed) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `ERC725Y_MsgValueDisallowed()` +- Error hash: `0xf36ba737` + +::: + +```solidity +error ERC725Y_MsgValueDisallowed(); +``` + +reverts when sending value to the `setData(..)` functions + +
+ +### LSP4TokenNameNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp4tokennamenoteditable) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP4TokenNameNotEditable()` +- Error hash: `0x85c169bd` + +::: + +```solidity +error LSP4TokenNameNotEditable(); +``` + +Reverts when trying to edit the data key `LSP4TokenName` after the digital asset contract has been deployed. The `LSP4TokenName` data key is located inside the ERC725Y Data key-value store of the digital asset contract. It can be set only once inside the constructor/initializer when the digital asset contract is being deployed. + +
+ +### LSP4TokenSymbolNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp4tokensymbolnoteditable) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP4TokenSymbolNotEditable()` +- Error hash: `0x76755b38` + +::: + +```solidity +error LSP4TokenSymbolNotEditable(); +``` + +Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital asset contract has been deployed. The `LSP4TokenSymbol` data key is located inside the ERC725Y Data key-value store of the digital asset contract. It can be set only once inside the constructor/initializer when the digital asset contract is being deployed. + +
+ +### LSP8CannotSendToAddressZero + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8cannotsendtoaddresszero) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8CannotSendToAddressZero()` +- Error hash: `0x24ecef4d` + +::: + +```solidity +error LSP8CannotSendToAddressZero(); +``` + +reverts when trying to send token to the zero address. + +
+ +### LSP8CannotSendToSelf + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8cannotsendtoself) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8CannotSendToSelf()` +- Error hash: `0x5d67d6c1` + +::: + +```solidity +error LSP8CannotSendToSelf(); +``` + +reverts when specifying the same address for `from` and `to` in a token transfer. + +
+ +### LSP8CannotUseAddressZeroAsOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8cannotuseaddresszeroasoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8CannotUseAddressZeroAsOperator()` +- Error hash: `0x9577b8b3` + +::: + +```solidity +error LSP8CannotUseAddressZeroAsOperator(); +``` + +reverts when trying to set the zero address as an operator. + +
+ +### LSP8InvalidTransferBatch + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8invalidtransferbatch) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8InvalidTransferBatch()` +- Error hash: `0x93a83119` + +::: + +```solidity +error LSP8InvalidTransferBatch(); +``` + +reverts when the parameters used for `transferBatch` have different lengths. + +
+ +### LSP8NonExistentTokenId + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8nonexistenttokenid) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NonExistentTokenId(bytes32)` +- Error hash: `0xae8f9a36` + +::: + +```solidity +error LSP8NonExistentTokenId(bytes32 tokenId); +``` + +reverts when `tokenId` has not been minted. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | ----------- | +| `tokenId` | `bytes32` | - | + +
+ +### LSP8NonExistingOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8nonexistingoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NonExistingOperator(address,bytes32)` +- Error hash: `0x4aa31a8c` + +::: + +```solidity +error LSP8NonExistingOperator(address operator, bytes32 tokenId); +``` + +reverts when `operator` is not an operator for the `tokenId`. + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ----------- | +| `operator` | `address` | - | +| `tokenId` | `bytes32` | - | + +
+ +### LSP8NotTokenOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8nottokenoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NotTokenOperator(bytes32,address)` +- Error hash: `0x1294d2a9` + +::: + +```solidity +error LSP8NotTokenOperator(bytes32 tokenId, address caller); +``` + +reverts when `caller` is not an allowed operator for `tokenId`. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | ----------- | +| `tokenId` | `bytes32` | - | +| `caller` | `address` | - | + +
+ +### LSP8NotTokenOwner + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8nottokenowner) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NotTokenOwner(address,bytes32,address)` +- Error hash: `0x5b271ea2` + +::: + +```solidity +error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); +``` + +reverts when `caller` is not the `tokenOwner` of the `tokenId`. + +#### Parameters + +| Name | Type | Description | +| ------------ | :-------: | ----------- | +| `tokenOwner` | `address` | - | +| `tokenId` | `bytes32` | - | +| `caller` | `address` | - | + +
+ +### LSP8NotifyTokenReceiverContractMissingLSP1Interface + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8notifytokenreceivercontractmissinglsp1interface) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NotifyTokenReceiverContractMissingLSP1Interface(address)` +- Error hash: `0x4349776d` + +::: + +```solidity +error LSP8NotifyTokenReceiverContractMissingLSP1Interface( + address tokenReceiver +); +``` + +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ----------- | +| `tokenReceiver` | `address` | - | + +
+ +### LSP8NotifyTokenReceiverIsEOA + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8notifytokenreceiveriseoa) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8NotifyTokenReceiverIsEOA(address)` +- Error hash: `0x03173137` + +::: + +```solidity +error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); +``` + +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ----------- | +| `tokenReceiver` | `address` | - | + +
+ +### LSP8OperatorAlreadyAuthorized + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8operatoralreadyauthorized) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8OperatorAlreadyAuthorized(address,bytes32)` +- Error hash: `0xa7626b68` + +::: + +```solidity +error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); +``` + +reverts when `operator` is already authorized for the `tokenId`. + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ----------- | +| `operator` | `address` | - | +| `tokenId` | `bytes32` | - | + +
+ +### LSP8TokenOwnerCannotBeOperator + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenownercannotbeoperator) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8TokenOwnerCannotBeOperator()` +- Error hash: `0x89fdad62` + +::: + +```solidity +error LSP8TokenOwnerCannotBeOperator(); +``` + +reverts when trying to authorize or revoke the token's owner as an operator. + +