LSP8Mintable
LSP8IdentifiableDigitalAsset deployable preset contract with a public
mint
function callable only by the contractowner
.
Public Methods​
Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts. When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.
constructor​
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Mintable.sol
constructor(
string name_,
string symbol_,
address newOwner_,
uint256 lsp4TokenType_,
uint256 lsp8TokenIdFormat_
);
Deploying a LSP8Mintable
token contract with: token name = name_
, token symbol = symbol_
, and address newOwner_
as the token contract owner.
Parameters​
Name | Type | Description |
---|---|---|
name_ | string | The name of the token. |
symbol_ | string | The symbol of the token. |
newOwner_ | address | The owner of the token contract. |
lsp4TokenType_ | uint256 | The type of token this digital asset contract represents (0 = Token, 1 = NFT, 2 = Collection). |
lsp8TokenIdFormat_ | uint256 | The format of tokenIds (= NFTs) that this contract will create. |
fallback​
- Specification details: LSP-8-IdentifiableDigitalAsset
- Solidity implementation:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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:
LSP8Mintable.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. |