Solidity API
ISpanningERC1155
Interface of ERC1155 in the Spanning Protocol
balanceOf
function balanceOf(bytes32 account, uint256 id) external view returns (uint256)
Returns the amount of tokens of token type id
owned by account
.
Name | Type | Description |
---|---|---|
account | bytes32 | - Spanning Address to be queried |
id | uint256 | - Token type |
Name | Type | Description |
---|---|---|
[0] | uint256 | Token value of token type id for an account Requirements: - account cannot be the zero address. |
balanceOfBatch
function balanceOfBatch(bytes32[] accounts, uint256[] ids) external view returns (uint256[])
Batched version of balanceOf
.
Name | Type | Description |
---|---|---|
accounts | bytes32[] | - a batch of Spanning Address to be queried |
ids | uint256[] | - a batch of Token type |
Name | Type | Description |
---|---|---|
[0] | uint256[] | a batch of token value of token type ids for a batch of accounts Requirements: - accounts and ids must have the same length. |
setApprovalForAll
function setApprovalForAll(bytes32 receiverAddress, bool approved) external
Grants or revokes permission to receiverAddress
to transfer the caller's tokens, according to approved
.
Name | Type | Description |
---|---|---|
receiverAddress | bytes32 | - Spanning Address to receive permission |
approved | bool | - grants or revokes permission Emits an {ApprovalForAll} event. Requirements: - receiverAddress cannot be the caller. |
isApprovedForAll
function isApprovedForAll(bytes32 senderAddress, bytes32 receiverAddress) external view returns (bool)
Returns true if receiverAddress
is approved to transfer senderAddress
's tokens. See {setApprovalForAll}.
safeTransferFrom
function safeTransferFrom(bytes32 senderAddress, bytes32 receiverAddress, uint256 id, uint256 amount, bytes data) external
Transfers amount
tokens of token type id
from senderAddress
to receiverAddress
. Emits a {TransferSingle} event.
Name | Type | Description |
---|---|---|
senderAddress | bytes32 | - Spanning Address to initiate the transfer |
receiverAddress | bytes32 | - Spanning Address to receive the transfer |
id | uint256 | - Token type |
amount | uint256 | - Amount to transfer Requirements: - receiverAddress cannot be the zero address. - If the caller is not senderAddress , it must be have been approved to spend senderAddress 's tokens via {setApprovalForAll}. - senderAddress must have a balance of tokens of type id of at least amount . - If receiverAddress refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value. |
data | bytes |
safeBatchTransferFrom
function safeBatchTransferFrom(bytes32 senderAddress, bytes32 receiverAddress, uint256[] ids, uint256[] amounts, bytes data) external
Batched version of safeTransferFrom
. Emits a {TransferBatch} event.
Name | Type | Description |
---|---|---|
senderAddress | bytes32 | - Spanning Address to initiate the transfer |
receiverAddress | bytes32 | - Spanning Address to receive the transfer |
ids | uint256[] | - a batch of Token type |
amounts | uint256[] | - a batch of amounts Requirements: - ids and amounts must have the same length. - If receiverAddress refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. |
data | bytes |
Events
SpanningTransferSingle
event SpanningTransferSingle(bytes32 operatorAddress, bytes32 senderAddress, bytes32 receiverAddress, uint256 id, uint256 amount)
Emitted when amount
tokens of token type id
are transferred from senderAddress
to receiverAddress
by operatorAddress
.
Name | Type | Description |
---|---|---|
operatorAddress | bytes32 | - Spanning Address of the operator |
senderAddress | bytes32 | - Spanning Address to initiate the transfer |
receiverAddress | bytes32 | - Spanning Address to receive the transfer |
id | uint256 | - token type |
amount | uint256 | - Amount to transfer |
SpanningTransferBatch
event SpanningTransferBatch(bytes32 operatorAddress, bytes32 senderAddress, bytes32 receiverAddress, uint256[] ids, uint256[] amounts)
Equivalent to multiple {TransferSingle} events, where operatorAddress
, senderAddress
and receiverAddress
are the same for all transfers.
Name | Type | Description |
---|---|---|
operatorAddress | bytes32 | - Spanning Address of the operator |
senderAddress | bytes32 | - Spanning Address to initiate the transfer |
receiverAddress | bytes32 | - Spanning Address to receive the transfer |
ids | uint256[] | - a batch of token type |
amounts | uint256[] | - a batch of amounts |
SpanningApprovalForAll
event SpanningApprovalForAll(bytes32 senderAddress, bytes32 receiverAddress, bool approved)
Emitted when senderAddress
grants or revokes permission to receiverAddress
to transfer their tokens, according to approved
.
Name | Type | Description |
---|---|---|
senderAddress | bytes32 | - Spanning Address to grants or revokes permission |
receiverAddress | bytes32 | - Spanning Address to receive permission |
approved | bool | - grants or revokes permission |