ERC1155Transfers
Abstract contract that provides ERC1155 transfer functions of the ERC1155 Data Manager
Based on OpenZeppelin ERC1155 implementation
safeTransferFrom
Transfers value
amount of an id
from from
to to
The caller must have allowance for from
's tokens of at least value
or be from
Parameters
Name | Type | Description |
---|---|---|
from | address | Source address |
to | address | Destination address |
id | uint256 | Token ID |
value | uint256 | Amount of tokens to transfer |
data | bytes | Additional data with no specified format |
safeBatchTransferFrom
Transfers values
amount of multiple ids
from from
to to
The caller must have allowance for from
's tokens of at least value
for each id
or be from
Parameters
Name | Type | Description |
---|---|---|
from | address | Source address |
to | address | Destination address |
ids | uint256[] | Array of token IDs |
values | uint256[] | Array of amounts of tokens to transfer |
data | bytes | Additional data with no specified format |
_safeTransferFrom
_Transfers a value
tokens of token type id
from from
to to
.
Emits a {TransferSingle} event.
Requirements:
to
cannot be the zero address.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._
_safeBatchTransferFrom
_xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
Emits a {TransferBatch} event.
Requirements:
- If
to
refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. ids
andvalues
must have the same length._
_updateWithAcceptanceCheck
_Version of {_update} that performs the token acceptance check by calling {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it contains code (eg. is a smart contract at the moment of execution).
IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any update to the contract state after this function would break the check-effect-interaction pattern. Consider overriding {update} instead.
_updateWithAcceptanceCheck
_Version of {_update} that performs the token acceptance check by calling {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it contains code (eg. is a smart contract at the moment of execution).
IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any update to the contract state after this function would break the check-effect-interaction pattern. Consider overriding {update} instead.
_update
_Transfers a value
amount of tokens of type id
from from
to to
. Will mint (or burn) if from
(or to
) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
to
refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. ids
andvalues
must have the same length.
NOTE: The ERC-1155 acceptance check is not performed in this function. See {updateWithAcceptanceCheck} instead.
_update
_Transfers a value
amount of tokens of type id
from from
to to
. Will mint (or burn) if from
(or to
) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
to
refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. ids
andvalues
must have the same length.
NOTE: The ERC-1155 acceptance check is not performed in this function. See {updateWithAcceptanceCheck} instead. NOTE: Array length check is not performed in this function and must be performed in the caller
_writeTransfer
_writeTransferBatch
_doSafeTransferAcceptanceCheck
Performs an acceptance check by calling {IERC1155-onERC1155Received} on the to
address
if it contains code at the moment of execution.
_doSafeBatchTransferAcceptanceCheck
Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the to
address
if it contains code at the moment of execution.