IERC1155Receiver

Git Source

Functions

onERC1155Received

Handles the receipt of a single ERC1155 token type. This function is called at the end of a safeTransferFrom after the balance has been updated. NOTE: To accept the transfer, this must return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) (i.e. 0xf23a6e61, or its own function selector).

function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
    external
    returns (bytes4);

Parameters

NameTypeDescription
operatoraddressThe address which initiated the transfer (i.e. msg.sender)
fromaddressThe address which previously owned the token
iduint256The ID of the token being transferred
valueuint256The amount of tokens being transferred
databytesAdditional data with no specified format

Returns

NameTypeDescription
<none>bytes4bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) if transfer is allowed

onERC1155BatchReceived

Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a safeBatchTransferFrom after the balances have been updated. NOTE: To accept the transfer(s), this must return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) (i.e. 0xbc197c81, or its own function selector).

function onERC1155BatchReceived(
    address operator,
    address from,
    uint256[] calldata ids,
    uint256[] calldata values,
    bytes calldata data
) external returns (bytes4);

Parameters

NameTypeDescription
operatoraddressThe address which initiated the batch transfer (i.e. msg.sender)
fromaddressThe address which previously owned the token
idsuint256[]An array containing ids of each token being transferred (order and length must match values array)
valuesuint256[]An array containing amounts of each token being transferred (order and length must match ids array)
databytesAdditional data with no specified format

Returns

NameTypeDescription
<none>bytes4bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed