Skip to content

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.

NameTypeDescription
accountbytes32- Spanning Address to be queried
iduint256- Token type
NameTypeDescription
[0]uint256Token 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.

NameTypeDescription
accountsbytes32[]- a batch of Spanning Address to be queried
idsuint256[]- a batch of Token type
NameTypeDescription
[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.

NameTypeDescription
receiverAddressbytes32- Spanning Address to receive permission
approvedbool- 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.

NameTypeDescription
senderAddressbytes32- Spanning Address to initiate the transfer
receiverAddressbytes32- Spanning Address to receive the transfer
iduint256- Token type
amountuint256- 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.
databytes

safeBatchTransferFrom

function safeBatchTransferFrom(bytes32 senderAddress, bytes32 receiverAddress, uint256[] ids, uint256[] amounts, bytes data) external

Batched version of safeTransferFrom. Emits a {TransferBatch} event.

NameTypeDescription
senderAddressbytes32- Spanning Address to initiate the transfer
receiverAddressbytes32- Spanning Address to receive the transfer
idsuint256[]- a batch of Token type
amountsuint256[]- 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.
databytes

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.

NameTypeDescription
operatorAddressbytes32- Spanning Address of the operator
senderAddressbytes32- Spanning Address to initiate the transfer
receiverAddressbytes32- Spanning Address to receive the transfer
iduint256- token type
amountuint256- 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.

NameTypeDescription
operatorAddressbytes32- Spanning Address of the operator
senderAddressbytes32- Spanning Address to initiate the transfer
receiverAddressbytes32- Spanning Address to receive the transfer
idsuint256[]- a batch of token type
amountsuint256[]- 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.

NameTypeDescription
senderAddressbytes32- Spanning Address to grants or revokes permission
receiverAddressbytes32- Spanning Address to receive permission
approvedbool- grants or revokes permission