IERC1155
Inherits: IERC165
Required interface of an ERC-1155 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-1155[ERC].
Functions
balanceOf
Returns the value of tokens of token type id
owned by account
.
function balanceOf(address account, uint256 id) external view returns (uint256);
balanceOfBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of balanceOf. Requirements:
accounts
andids
must have the same length.*
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
setApprovalForAll
*Grants or revokes permission to operator
to transfer the caller's tokens, according to approved
,
Emits an ApprovalForAll event.
Requirements:
operator
cannot be the zero address.*
function setApprovalForAll(address operator, bool approved) external;
isApprovedForAll
Returns true if operator
is approved to transfer account
's tokens.
See setApprovalForAll.
function isApprovedForAll(address account, address operator) external view returns (bool);
safeTransferFrom
*Transfers a value
amount of tokens of type id
from from
to to
.
WARNING: This function can potentially allow a reentrancy attack when transferring tokens
to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
Ensure to follow the checks-effects-interactions pattern and consider employing
reentrancy guards when interacting with untrusted contracts.
Emits a {TransferSingle} event.
Requirements:
to
cannot be the zero address.- If the caller is not
from
, it must have been approved to spendfrom
's tokens via {setApprovalForAll}. from
must have a balance of tokens of typeid
of at leastvalue
amount.- If
to
refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
safeBatchTransferFrom
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of safeTransferFrom. WARNING: This function can potentially allow a reentrancy attack when transferring tokens to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver. Ensure to follow the checks-effects-interactions pattern and consider employing reentrancy guards when interacting with untrusted contracts. Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. Requirements:
ids
andvalues
must have the same length.- If
to
refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.*
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
Events
TransferSingle
Emitted when value
amount of tokens of type id
are transferred from from
to to
by operator
.
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
TransferBatch
Equivalent to multiple TransferSingle events, where operator
, from
and to
are the same for all
transfers.
event TransferBatch(
address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values
);
ApprovalForAll
Emitted when account
grants or revokes permission to operator
to transfer their tokens, according to
approved
.
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
URI
Emitted when the URI for token type id
changes to value
, if it is a non-programmatic URI.
If an URI event was emitted for id
, the standard
https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that value
will equal the value
returned by {IERC1155MetadataURI-uri}.
event URI(string value, uint256 indexed id);