Advanced Section: mintTransferOrBurn function

mintTransferOrBurn

function mintTransferOrBurn(bool isMulti, bytes calldata data) external;
  • Function type: write

  • Callable by:

    • Interoperable Interface contract

    • Extension contract

This function is super powerful because it is a utility function that handles all mint, transfer and burn operations of items.

The functions of:

  • mintItems

  • safeTransferFrom/safeBatchTransferFrom

  • burn/burnBatch both standard and with data

they all go through this mintTransferOrBurn function.

Even transfer and burn operations done on the interoperable interface of an item (ERC20 face) pass through this function.

However, this function is not directly callable by users but can be called only by Extensions and Interoparable Interfaces of Items.

This function is used to execute, in a variety of ways, one or more of the following operations:

  • mint single

  • mint in batch mode

  • transfer single

  • transfer in batch mode

  • burn

  • burn in batch mode

How the function works

As input, it takes the isMulti (bool) and data (bytes) parameters.

mint, transfer or burn in single mode

If isMulti is false, the function will execute a mint, transfer or burn in single mode. In this case, the data parameter is composed as follows:

  • address operator

  • address sender

  • address recipient

  • uint256 itemId

  • uint256 amount

To execute a transfer, the sender address and the recipient address must both be populated differently from address(0).

To execute a burn, the sender address must be populated differently from address(0) and the recipient address must be equal to address(0).

To execute a mint, the sender address must be equal to address(0).

mint, transfer or burn in batch multi mode

If isMulti is true, the data parameter must contain the batch (bool) and data (bytes) parameters.

(batch, data) = abi.decode(data, (bool, bytes));

If batch is also true, the function will execute a batch multi mint, batch multi transfer or batch multi burn.

This allows you to mint, transfer or burn multiple Items in a single transaction, using a single operator address, a single sender address and a single recipient address.

In this case, the data parameter is composed as follows:

  • address operator

  • address sender

  • address recipient

  • uint256[] itemIds

  • uint256[] amounts

To execute a batch transfer, the sender and the recipient addresses must be populated differently from address(0).

To execute a batch burn, the sender address must be populated differently from address(0) and the recipient address must be equal to address(0).

To execute a batch mint, the sender address must be equal to address(0).

This function can be used to execute even more complex operations such as a batch transfer sending tokens to different receivers or a batch mint, a batch transfer, and a batch burn in the same transaction.

These operations will be unlocked in the future when new Extensions will be released.

Last updated