ODCdataManagersERC1155extensions

ERC1155Transfers

Abstract contract that provides ERC1155 transfer functions of the ERC1155 Data Manager

Based on OpenZeppelin ERC1155 implementation

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes data) public virtual

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

NameTypeDescription
fromaddressSource address
toaddressDestination address
iduint256Token ID
valueuint256Amount of tokens to transfer
databytesAdditional data with no specified format

safeBatchTransferFrom

function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] values, bytes data) public virtual

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

NameTypeDescription
fromaddressSource address
toaddressDestination address
idsuint256[]Array of token IDs
valuesuint256[]Array of amounts of tokens to transfer
databytesAdditional data with no specified format

_safeTransferFrom

function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes data) internal

_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 type id of at least value amount.
  • If to refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value._

_safeBatchTransferFrom

function _safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] values, bytes data) internal

_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 and values must have the same length._

_updateWithAcceptanceCheck

function _updateWithAcceptanceCheck(address from, address to, uint256 id, uint256 value, bytes data) internal virtual

_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

function _updateWithAcceptanceCheck(address from, address to, uint256[] ids, uint256[] values, bytes data) internal virtual

_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

function _update(address from, address to, uint256 id, uint256 value) internal virtual

_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 and values must have the same length.

NOTE: The ERC-1155 acceptance check is not performed in this function. See {updateWithAcceptanceCheck} instead.

_update

function _update(address from, address to, uint256[] ids, uint256[] values) internal virtual

_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 and values 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

function _writeTransfer(address from, address to, uint256 id, uint256 value) internal virtual

_writeTransferBatch

function _writeTransferBatch(address from, address to, uint256[] ids, uint256[] values) internal virtual

_doSafeTransferAcceptanceCheck

function _doSafeTransferAcceptanceCheck(address operator, address from, address to, uint256 id, uint256 value, bytes data) internal

Performs an acceptance check by calling {IERC1155-onERC1155Received} on the to address if it contains code at the moment of execution.

_doSafeBatchTransferAcceptanceCheck

function _doSafeBatchTransferAcceptanceCheck(address operator, address from, address to, uint256[] ids, uint256[] values, bytes data) internal

Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the to address if it contains code at the moment of execution.

On this page