LSP8Enumerable
LSP8 extension that enables to enumerate over all the tokenIds
ever minted.
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.
fallback
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
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
- 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)
. The data key relative tobytes4(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 ofmsg.sender
and 32 bytes ofmsg.value
). Return what the calls returns, or revert if the call failed.
- If the data sent to this function is of length less than 4 bytes (not a function selector), revert.
receive
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
receive() external payable;
LSP8 contract cannot receive native tokens.
Reverts whenever someone tries to send native tokens to a LSP8 contract.
authorizeOperator
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
authorizeOperator(address,bytes32,bytes)
- Function selector:
0x86a10ddd
function authorizeOperator(
address operator,
bytes32 tokenId,
bytes operatorNotificationData
) external nonpayable;
Allow an operator
address to transfer or burn a specific tokenId
on behalf of its token owner. See isOperatorFor
. Notify the operator based on the LSP1-UniversalReceiver standard
Parameters
Name | Type | Description |
---|---|---|
operator | address | The address to authorize as an operator. |
tokenId | bytes32 | The token ID operator has access to. |
operatorNotificationData | bytes | The data to notify the operator about via LSP1. |
balanceOf
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
balanceOf(address)
- Function selector:
0x70a08231
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. |
batchCalls
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
batchCalls(bytes[])
- Function selector:
0x6963d438
It's not possible to send value along the functions call due to the use of delegatecall
.
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. |
getData
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
getData(bytes32)
- Function selector:
0x54f6127f
function getData(bytes32 dataKey) external view returns (bytes dataValue);
Reading the ERC725Y storage for data key dataKey
returned the following value: dataValue
.
Get in the ERC725Y storage the bytes data stored at a specific data key dataKey
.
Parameters
Name | Type | Description |
---|---|---|
dataKey | bytes32 | The data key for which to retrieve the value. |
Returns
Name | Type | Description |
---|---|---|
dataValue | bytes | The bytes value stored under the specified data key. |
getDataBatch
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
getDataBatch(bytes32[])
- Function selector:
0xdedff9c6
function getDataBatch(
bytes32[] dataKeys
) external view returns (bytes[] dataValues);
Reading the ERC725Y storage for data keys dataKeys
returned the following values: dataValues
.
Get in the ERC725Y storage the bytes data stored at multiple data keys dataKeys
.
Parameters
Name | Type | Description |
---|---|---|
dataKeys | bytes32[] | The array of keys which values to retrieve |
Returns
Name | Type | Description |
---|---|---|
dataValues | bytes[] | The array of data stored at multiple keys |
getDataBatchForTokenIds
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
getDataBatchForTokenIds(bytes32[],bytes32[])
- Function selector:
0x1d26fce6
function getDataBatchForTokenIds(
bytes32[] tokenIds,
bytes32[] dataKeys
) external view returns (bytes[] dataValues);
Retrieves data in batch for multiple tokenId
and dataKey
pairs.
Parameters
Name | Type | Description |
---|---|---|
tokenIds | bytes32[] | An array of token IDs. |
dataKeys | bytes32[] | An array of data keys corresponding to the token IDs. |
Returns
Name | Type | Description |
---|---|---|
dataValues | bytes[] | An array of data values for each pair of tokenId and dataKey . |
getDataForTokenId
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
getDataForTokenId(bytes32,bytes32)
- Function selector:
0x16e023b3
function getDataForTokenId(
bytes32 tokenId,
bytes32 dataKey
) external view returns (bytes dataValue);
Retrieves data for a specific tokenId
and dataKey
.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | The unique identifier for a token. |
dataKey | bytes32 | The key for the data to retrieve. |
Returns
Name | Type | Description |
---|---|---|
dataValue | bytes | The data value associated with the given tokenId and dataKey . |
getOperatorsOf
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
getOperatorsOf(bytes32)
- Function selector:
0x49a6078d
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
isOperatorFor(address,bytes32)
- Function selector:
0x2a3654a4
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
owner()
- Function selector:
0x8da5cb5b
function owner() external view returns (address);
Returns the address of the current owner.
Returns
Name | Type | Description |
---|---|---|
0 | address | - |
renounceOwnership
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
renounceOwnership()
- Function selector:
0x715018a6
function renounceOwnership() external nonpayable;
Leaves the contract without owner. It will not be possible to call onlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
revokeOperator
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
revokeOperator(address,bytes32,bool,bytes)
- Function selector:
0xdb8c9663
function revokeOperator(
address operator,
bytes32 tokenId,
bool notify,
bytes operatorNotificationData
) external nonpayable;
Remove access of operator
for a given tokenId
, disallowing it to transfer tokenId
on behalf of its owner. See also isOperatorFor
.
Parameters
Name | Type | Description |
---|---|---|
operator | address | The address to revoke as an operator. |
tokenId | bytes32 | The tokenId operator is revoked from operating on. |
notify | bool | Boolean indicating whether to notify the operator or not |
operatorNotificationData | bytes | The data to notify the operator about via LSP1. |
setData
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
setData(bytes32,bytes)
- Function selector:
0x7f23690c
Note for developers: despite the fact that this function is set as payable
, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value
sent was equal to 0.
function setData(bytes32 dataKey, bytes dataValue) external payable;
Setting the following data key value pair in the ERC725Y storage. Data key: dataKey
, data value: dataValue
.
Sets a single bytes value dataValue
in the ERC725Y storage for a specific data key dataKey
. The function is marked as payable to enable flexibility on child contracts. For instance to implement a fee mechanism for setting specific data.
Requirements:
- SHOULD only be callable by the
owner
.
Emitted events:
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
setDataBatch(bytes32[],bytes[])
- Function selector:
0x97902421
Note for developers: despite the fact that this function is set as payable
, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value
sent was equal to 0.
function setDataBatch(bytes32[] dataKeys, bytes[] dataValues) external payable;
Setting the following data key value pairs in the ERC725Y storage. Data keys: dataKeys
, data values: dataValues
.
Batch data setting function that behaves the same as setData
but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction.
Requirements:
- SHOULD only be callable by the
owner
of the contract.
Emitted events:
DataChanged
event for each data key/value pair set.
Parameters
Name | Type | Description |
---|---|---|
dataKeys | bytes32[] | An array of data keys to set bytes values for. |
dataValues | bytes[] | An array of bytes values to set for each dataKeys . |
setDataBatchForTokenIds
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
setDataBatchForTokenIds(bytes32[],bytes32[],bytes[])
- Function selector:
0xbe9f0e6f
function setDataBatchForTokenIds(
bytes32[] tokenIds,
bytes32[] dataKeys,
bytes[] dataValues
) external nonpayable;
Sets data in batch for multiple tokenId
and dataKey
pairs.
Parameters
Name | Type | Description |
---|---|---|
tokenIds | bytes32[] | An array of token IDs. |
dataKeys | bytes32[] | An array of data keys corresponding to the token IDs. |
dataValues | bytes[] | An array of values to set for the given data keys. |
setDataForTokenId
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
setDataForTokenId(bytes32,bytes32,bytes)
- Function selector:
0xd6c1407c
function setDataForTokenId(
bytes32 tokenId,
bytes32 dataKey,
bytes dataValue
) external nonpayable;
Sets data for a specific tokenId
and dataKey
.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | The unique identifier for a token. |
dataKey | bytes32 | The key for the data to set. |
dataValue | bytes | The value to set for the given data key. |
supportsInterface
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
supportsInterface(bytes4)
- Function selector:
0x01ffc9a7
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 | - |
tokenAt
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
tokenAt(uint256)
- Function selector:
0x92a91a3a
function tokenAt(uint256 index) external view returns (bytes32);
Retrieving the tokenId
for msg.sender
located in its list at index number index
.
Returns a token id at index. See totalSupply
to get total number of minted tokens.
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | The index to search to search in the enumerable mapping. |
Returns
Name | Type | Description |
---|---|---|
0 | bytes32 | TokenId or bytes32(0) if no tokenId exist at index . |
tokenIdsOf
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
tokenIdsOf(address)
- Function selector:
0xa3b261f2
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
tokenOwnerOf(bytes32)
- Function selector:
0x217b2270
function tokenOwnerOf(bytes32 tokenId) external view returns (address);
Returns the address that owns a given tokenId
.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | The token ID to query the owner for. |
Returns
Name | Type | Description |
---|---|---|
0 | address | The owner address of the given tokenId . |
totalSupply
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
totalSupply()
- Function selector:
0x18160ddd
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
transfer(address,address,bytes32,bool,bytes)
- Function selector:
0x511b6952
function transfer(
address from,
address to,
bytes32 tokenId,
bool force,
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 force
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. |
force | 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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
transferBatch(address[],address[],bytes32[],bool[],bytes[])
- Function selector:
0x7e87632c
function transferBatch(
address[] from,
address[] to,
bytes32[] tokenId,
bool[] force,
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. |
force | 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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Function signature:
transferOwnership(address)
- Function selector:
0xf2fde38b
function transferOwnership(address newOwner) external nonpayable;
Transfers ownership of the contract to a new account (newOwner
). Can only be called by the current owner.
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | - |
Internal Methods
Any method labeled as internal
serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.
Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.
_checkOwner
function _checkOwner() internal view;
Throws if the sender is not the owner.
_setOwner
function _setOwner(address newOwner) internal nonpayable;
Changes the owner if newOwner
and oldOwner are different
This pattern is useful in inheritance.
_getData
function _getData(bytes32 dataKey) internal view returns (bytes dataValue);
Read the value stored under a specific dataKey
inside the underlying ERC725Y storage,
represented as a mapping of bytes32
data keys mapped to their bytes
data values.
mapping(bytes32 => bytes) _store
Parameters
Name | Type | Description |
---|---|---|
dataKey | bytes32 | A bytes32 data key to read the associated bytes value from the store. |
Returns
Name | Type | Description |
---|---|---|
dataValue | bytes | The bytes value associated with the given dataKey in the ERC725Y storage. |
_setData
function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable;
The ERC725Y data key _LSP8_TOKENID_FORMAT_KEY
cannot be changed
once the identifiable digital asset contract has been deployed.
_isOperatorOrOwner
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
function _revokeOperator(
address operator,
address tokenOwner,
bytes32 tokenId,
bool notified,
bytes operatorNotificationData
) internal nonpayable;
removes operator
from the list of operators for the tokenId
_clearOperators
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
function _exists(bytes32 tokenId) internal view returns (bool);
Returns whether tokenId
exists.
Tokens start existing when they are minted (_mint
), and stop existing when they are burned (_burn
).
_existsOrError
function _existsOrError(bytes32 tokenId) internal view;
When tokenId
does not exist then revert with an error.
_mint
Any logic in the:
-
_beforeTokenTransfer
function will run before updating the balances and ownership oftokenId
s. -
_afterTokenTransfer
function will run after updating the balances and ownership oftokenId
s, but before notifying the recipient via LSP1.
function _mint(
address to,
bytes32 tokenId,
bool force,
bytes data
) internal nonpayable;
Create tokenId
by minting it and transfers it to to
.
Emitted events:
Transfer
event withaddress(0)
asfrom
address.
Parameters
Name | Type | Description |
---|---|---|
to | address | @param tokenId The token ID to create (= mint). |
tokenId | bytes32 | The token ID to create (= mint). |
force | 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
Any logic in the:
-
_beforeTokenTransfer
function will run before updating the balances and ownership oftokenId
s. -
_afterTokenTransfer
function will run after updating the balances and ownership oftokenId
s, but before notifying the sender via LSP1.
In dApps, you can know which addresses are burning tokens by listening for the Transfer
event and filter with the zero address as to
.
function _burn(bytes32 tokenId, bytes data) internal nonpayable;
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.
Emitted events:
Transfer
event withaddress(0)
as theto
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
Any logic in the:
-
_beforeTokenTransfer
function will run before updating the balances and ownership oftokenId
s. -
_afterTokenTransfer
function will run after updating the balances and ownership oftokenId
s, but before notifying the sender/recipient via LSP1.
This internal function does not check if the sender is authorized or not to operate on the tokenId
.
function _transfer(
address from,
address to,
bytes32 tokenId,
bool force,
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
function, if they are contracts that support the LSP1 interface. Their universalReceiver
function will receive
all the parameters in the calldata packed encoded.
Emitted events:
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. |
force | 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. |
_setDataForTokenId
function _setDataForTokenId(
bytes32 tokenId,
bytes32 dataKey,
bytes dataValue
) internal nonpayable;
Sets data for a specific tokenId
and dataKey
in the ERC725Y storage
The ERC725Y data key is the hash of the tokenId
and dataKey
concatenated
Emitted events:
TokenIdDataChanged
event.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | The unique identifier for a token. |
dataKey | bytes32 | The key for the data to set. |
dataValue | bytes | The value to set for the given data key. |
_getDataForTokenId
function _getDataForTokenId(
bytes32 tokenId,
bytes32 dataKey
) internal view returns (bytes dataValues);
Retrieves data for a specific tokenId
and dataKey
from the ERC725Y storage
The ERC725Y data key is the hash of the tokenId
and dataKey
concatenated
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | The unique identifier for a token. |
dataKey | bytes32 | The key for the data to retrieve. |
Returns
Name | Type | Description |
---|---|---|
dataValues | bytes | The data value associated with the given tokenId and dataKey . |
_beforeTokenTransfer
function _beforeTokenTransfer(
address from,
address to,
bytes32 tokenId,
bytes data
) internal nonpayable;
Parameters
Name | Type | Description |
---|---|---|
from | address | The address sending the tokenId (address(0) when tokenId is being minted). |
to | address | @param tokenId The bytes32 identifier of the token being transferred. |
tokenId | bytes32 | The bytes32 identifier of the token being transferred. |
data | bytes | The data sent alongside the the token transfer. |
_afterTokenTransfer
function _afterTokenTransfer(
address from,
address to,
bytes32 tokenId,
bytes data
) internal nonpayable;
Hook that is called after any token transfer, including minting and burning. Allows to run custom logic after updating balances, but before notifiying sender/recipient via LSP1 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 |
data | bytes | The data sent alongside the transfer |
_notifyTokenOperator
function _notifyTokenOperator(
address operator,
bytes lsp1Data
) internal nonpayable;
Attempt to notify the operator operator
about the tokenId
being authorized.
This is done by calling its universalReceiver
function with the _TYPEID_LSP8_TOKENOPERATOR
as typeId, if operator
is a contract that supports the LSP1 interface.
If operator
is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
Parameters
Name | Type | Description |
---|---|---|
operator | address | The address to call the universalReceiver function on. |
lsp1Data | bytes | the data to be sent to the operator address in the universalReceiver call. |
_notifyTokenSender
function _notifyTokenSender(address from, bytes lsp1Data) internal nonpayable;
Attempt to notify the token sender from
about the tokenId
being transferred.
This is done by calling its universalReceiver
function with the _TYPEID_LSP8_TOKENSSENDER
as typeId, if from
is a contract that supports the LSP1 interface.
If from
is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
Parameters
Name | Type | Description |
---|---|---|
from | address | The address to call the universalReceiver function on. |
lsp1Data | bytes | the data to be sent to the from address in the universalReceiver call. |
_notifyTokenReceiver
function _notifyTokenReceiver(
address to,
bool force,
bytes lsp1Data
) internal nonpayable;
Attempt to notify the token receiver to
about the tokenId
being received.
This is done by calling its universalReceiver
function with the _TYPEID_LSP8_TOKENSRECIPIENT
as typeId, if to
is a contract that supports the LSP1 interface.
If to
is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the force
boolean flag.
-
if
force
is set totrue
, nothing will happen and no notification will be sent. -
if
force
is set to `false, the transaction will revert.
Parameters
Name | Type | Description |
---|---|---|
to | address | The address to call the universalReceiver function on. |
force | bool | A boolean that describe if transfer to a to address that does not support LSP1 is allowed or not. |
lsp1Data | bytes | The data to be sent to the to address in the universalReceiver(...) call. |
_supportsInterfaceInERC165Extension
function _supportsInterfaceInERC165Extension(
bytes4 interfaceId
) internal view returns (bool);
Returns whether the interfaceId being checked is supported in the extension of the
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.
_getExtensionAndForwardValue
function _getExtensionAndForwardValue(
bytes4 functionSelector
) internal view returns (address, bool);
Returns the extension address stored under the following data key:
-
_LSP17_EXTENSION_PREFIX
+<bytes4>
(Check [LSP2-ERC725YJSONSchema] for encoding the data key). -
If no extension is stored, returns the address(0).
_fallbackLSP17Extendable
The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract
will be forwarded to the extension address mapped to the selector from msg.sig
.
function _fallbackLSP17Extendable(
bytes callData
) internal nonpayable returns (bytes);
Forwards the call with the received value to an extension mapped to a function selector.
Calls _getExtensionAndForwardValue
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.
We will always forward the value to the extension, as the LSP8 contract is not supposed to hold any native tokens.
Reverts if there is no extension for the function being called.
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
Events
DataChanged
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
DataChanged(bytes32,bytes)
- Event topic hash:
0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2
event DataChanged(bytes32 indexed dataKey, bytes dataValue);
The following data key/value pair has been changed in the ERC725Y storage: Data key: dataKey
, data value: dataValue
.
Emitted when data at a specific dataKey
was changed to a new value dataValue
.
Parameters
Name | Type | Description |
---|---|---|
dataKey indexed | bytes32 | The data key for which a bytes value is set. |
dataValue | bytes | The value to set for the given data key. |
OperatorAuthorizationChanged
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
OperatorAuthorizationChanged(address,address,bytes32,bytes)
- Event topic hash:
0x1b1b58aa2ec0cec2228b2d37124556d41f5a1f7b12f089171f896cc236671215
event OperatorAuthorizationChanged(
address indexed operator,
address indexed tokenOwner,
bytes32 indexed tokenId,
bytes operatorNotificationData
);
Emitted when tokenOwner
enables operator
to transfer or burn the tokenId
.
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 . |
operatorNotificationData | bytes | The data to notify the operator about via LSP1. |
OperatorRevoked
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
OperatorRevoked(address,address,bytes32,bool,bytes)
- Event topic hash:
0xc78cd419d6136f9f1c1c6aec1d3fae098cffaf8bc86314a8f2685e32fe574e3c
event OperatorRevoked(
address indexed operator,
address indexed tokenOwner,
bytes32 indexed tokenId,
bool notified,
bytes operatorNotificationData
);
Emitted when tokenOwner
disables operator
to transfer or burn tokenId
on its behalf.
Parameters
Name | Type | Description |
---|---|---|
operator indexed | address | The address revoked from the operator array (getOperatorsOf ). |
tokenOwner indexed | address | The owner of the tokenId . |
tokenId indexed | bytes32 | The tokenId operator is revoked from operating on. |
notified | bool | Bool indicating whether the operator has been notified or not |
operatorNotificationData | bytes | The data to notify the operator about via LSP1. |
OwnershipTransferred
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
OwnershipTransferred(address,address)
- Event topic hash:
0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
Parameters
Name | Type | Description |
---|---|---|
previousOwner indexed | address | - |
newOwner indexed | address | - |
TokenIdDataChanged
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
TokenIdDataChanged(bytes32,bytes32,bytes)
- Event topic hash:
0xa6e4251f855f750545fe414f120db91c76b88def14d120969e5bb2d3f05debbb
event TokenIdDataChanged(
bytes32 indexed tokenId,
bytes32 indexed dataKey,
bytes dataValue
);
Emitted when setting data for tokenId
.
Parameters
Name | Type | Description |
---|---|---|
tokenId indexed | bytes32 | The tokenId which data is set for. |
dataKey indexed | bytes32 | The data key for which a bytes value is set. |
dataValue | bytes | The value to set for the given data key. |
Transfer
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Event signature:
Transfer(address,address,address,bytes32,bool,bytes)
- Event topic hash:
0xb333c813a7426a7a11e2b190cad52c44119421594b47f6f32ace6d8c7207b2bf
event Transfer(
address operator,
address indexed from,
address indexed to,
bytes32 indexed tokenId,
bool force,
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 |
force | 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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
ERC725Y_DataKeysValuesEmptyArray()
- Error hash:
0x97da5f95
error ERC725Y_DataKeysValuesEmptyArray();
Reverts when one of the array parameter provided to setDataBatch
function is an empty array.
ERC725Y_DataKeysValuesLengthMismatch
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
ERC725Y_DataKeysValuesLengthMismatch()
- Error hash:
0x3bcc8979
error ERC725Y_DataKeysValuesLengthMismatch();
Reverts when there is not the same number of elements in the datakeys
and dataValues
array parameters provided when calling the setDataBatch
function.
ERC725Y_MsgValueDisallowed
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
ERC725Y_MsgValueDisallowed()
- Error hash:
0xf36ba737
error ERC725Y_MsgValueDisallowed();
Reverts when sending value to the setData
or setDataBatch
function.
InvalidExtensionAddress
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
InvalidExtensionAddress(bytes)
- Error hash:
0x42bfe79f
error InvalidExtensionAddress(bytes storedData);
reverts when the bytes retrieved from the LSP17 data key is not a valid address (not 20 bytes)
Parameters
Name | Type | Description |
---|---|---|
storedData | bytes | - |
InvalidFunctionSelector
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
InvalidFunctionSelector(bytes)
- Error hash:
0xe5099ee3
error InvalidFunctionSelector(bytes data);
reverts when the contract is called with a function selector not valid (less than 4 bytes of data)
Parameters
Name | Type | Description |
---|---|---|
data | bytes | - |
LSP4TokenNameNotEditable
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP4TokenNameNotEditable()
- Error hash:
0x85c169bd
error LSP4TokenNameNotEditable();
Reverts when trying to edit the data key LSP4TokenName
after the digital asset contract has been deployed / initialized. 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 / initialized.
LSP4TokenSymbolNotEditable
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP4TokenSymbolNotEditable()
- Error hash:
0x76755b38
error LSP4TokenSymbolNotEditable();
Reverts when trying to edit the data key LSP4TokenSymbol
after the digital asset contract has been deployed / initialized. 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 / initialized.
LSP4TokenTypeNotEditable
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP4TokenTypeNotEditable()
- Error hash:
0x4ef6d7fb
error LSP4TokenTypeNotEditable();
Reverts when trying to edit the data key LSP4TokenType
after the digital asset contract has been deployed / initialized. The LSP4TokenType
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 / initialized.
LSP8BatchCallFailed
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8BatchCallFailed(uint256)
- Error hash:
0x234eb819
error LSP8BatchCallFailed(uint256 callIndex);
Batch call failed.
Reverts when a batch call failed.
Parameters
Name | Type | Description |
---|---|---|
callIndex | uint256 | - |
LSP8CannotSendToAddressZero
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8CannotSendToAddressZero()
- Error hash:
0x24ecef4d
error LSP8CannotSendToAddressZero();
Reverts when trying to send token to the zero address.
LSP8CannotUseAddressZeroAsOperator
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8CannotUseAddressZeroAsOperator()
- Error hash:
0x9577b8b3
error LSP8CannotUseAddressZeroAsOperator();
Reverts when trying to set the zero address as an operator.
LSP8InvalidTransferBatch
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8InvalidTransferBatch()
- Error hash:
0x93a83119
error LSP8InvalidTransferBatch();
Reverts when the parameters used for transferBatch
have different lengths.
LSP8NonExistentTokenId
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NonExistentTokenId(bytes32)
- Error hash:
0xae8f9a36
error LSP8NonExistentTokenId(bytes32 tokenId);
Reverts when tokenId
has not been minted.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | - |
LSP8NonExistingOperator
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NonExistingOperator(address,bytes32)
- Error hash:
0x4aa31a8c
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NotTokenOperator(bytes32,address)
- Error hash:
0x1294d2a9
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NotTokenOwner(address,bytes32,address)
- Error hash:
0x5b271ea2
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
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NotifyTokenReceiverContractMissingLSP1Interface(address)
- Error hash:
0x4349776d
error LSP8NotifyTokenReceiverContractMissingLSP1Interface(
address tokenReceiver
);
Reverts if the tokenReceiver
does not implement LSP1 when minting or transferring tokens with bool force
set as false
.
Parameters
Name | Type | Description |
---|---|---|
tokenReceiver | address | - |
LSP8NotifyTokenReceiverIsEOA
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8NotifyTokenReceiverIsEOA(address)
- Error hash:
0x03173137
error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver);
Reverts if the tokenReceiver
is an EOA when minting or transferring tokens with bool force
set as false
.
Parameters
Name | Type | Description |
---|---|---|
tokenReceiver | address | - |
LSP8OperatorAlreadyAuthorized
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8OperatorAlreadyAuthorized(address,bytes32)
- Error hash:
0xa7626b68
error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId);
Reverts when operator
is already authorized for the tokenId
.
Parameters
Name | Type | Description |
---|---|---|
operator | address | - |
tokenId | bytes32 | - |
LSP8RevokeOperatorNotAuthorized
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8RevokeOperatorNotAuthorized(address,address,bytes32)
- Error hash:
0x760b5acd
error LSP8RevokeOperatorNotAuthorized(
address caller,
address tokenOwner,
bytes32 tokenId
);
Reverts when the call to revoke operator is not authorized.
Parameters
Name | Type | Description |
---|---|---|
caller | address | - |
tokenOwner | address | - |
tokenId | bytes32 | - |
LSP8TokenContractCannotHoldValue
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenContractCannotHoldValue()
- Error hash:
0x61f49442
error LSP8TokenContractCannotHoldValue();
LSP8 contract cannot receive native tokens.
Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension.
LSP8TokenIdFormatNotEditable
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenIdFormatNotEditable()
- Error hash:
0x3664800a
error LSP8TokenIdFormatNotEditable();
Reverts when trying to edit the data key LSP8TokenIdFormat
after the identifiable digital asset contract has been deployed. The LSP8TokenIdFormat
data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed.
LSP8TokenIdsDataEmptyArray
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenIdsDataEmptyArray()
- Error hash:
0x80c98305
error LSP8TokenIdsDataEmptyArray();
Reverts when empty arrays is passed to the function
LSP8TokenIdsDataLengthMismatch
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenIdsDataLengthMismatch()
- Error hash:
0x2fa71dfe
error LSP8TokenIdsDataLengthMismatch();
Reverts when the length of the token IDs data arrays is not equal
LSP8TokenOwnerCannotBeOperator
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenOwnerCannotBeOperator()
- Error hash:
0x89fdad62
error LSP8TokenOwnerCannotBeOperator();
Reverts when trying to authorize or revoke the token's owner as an operator.
LSP8TokenOwnerChanged
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
LSP8TokenOwnerChanged(bytes32,address,address)
- Error hash:
0x5a9c31d3
error LSP8TokenOwnerChanged(
bytes32 tokenId,
address oldOwner,
address newOwner
);
Reverts when the token owner changed inside the _beforeTokenTransfer
hook.
Parameters
Name | Type | Description |
---|---|---|
tokenId | bytes32 | - |
oldOwner | address | - |
newOwner | address | - |
NoExtensionFoundForFunctionSelector
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
NoExtensionFoundForFunctionSelector(bytes4)
- Error hash:
0xbb370b2b
error NoExtensionFoundForFunctionSelector(bytes4 functionSelector);
reverts when there is no extension for the function selector being called with
Parameters
Name | Type | Description |
---|---|---|
functionSelector | bytes4 | - |
OwnableCallerNotTheOwner
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
OwnableCallerNotTheOwner(address)
- Error hash:
0xbf1169c5
error OwnableCallerNotTheOwner(address callerAddress);
Reverts when only the owner is allowed to call the function.
Parameters
Name | Type | Description |
---|---|---|
callerAddress | address | The address that tried to make the call. |
OwnableCannotSetZeroAddressAsOwner
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Enumerable.sol
- Error signature:
OwnableCannotSetZeroAddressAsOwner()
- Error hash:
0x1ad8836c
error OwnableCannotSetZeroAddressAsOwner();
Reverts when trying to set address(0)
as the contract owner when deploying the contract, initializing it or transferring ownership of the contract.