ERC1155NaiveReceiver

The ERC1155NaiveReceiver contract is an implementation of the IERC1155Receiver interface provided by OpenZeppelin, which allows the contract to receive ERC-1155 tokens. The contract handles single and batch transfers of ERC-1155 tokens, and can be used as a basic receiver for testing or simple use cases.

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4)

This function is called when a single ERC-1155 token is transferred to the contract. The function takes the following parameters:

  • address operator: The address initiating the transfer.

  • address from: The address from which the tokens are being transferred.

  • uint256 id: The identifier of the token being transferred.

  • uint256 value: The amount of tokens being transferred.

  • bytes calldata data: Additional data provided with the transfer.

The function returns the function selector of onERC1155Received as a bytes4 value, which is required by the ERC-1155 standard to acknowledge the successful receipt of the tokens.

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external pure override returns (bytes4)

This function is called when a batch of ERC-1155 tokens is transferred to the contract. The function takes the following parameters:

  • address operator: The address initiating the transfer.

  • address from: The address from which the tokens are being transferred.

  • uint256[] calldata ids: An array of token identifiers being transferred.

  • uint256[] calldata values: An array of amounts of tokens being transferred, with each element corresponding to an element in the ids array.

  • bytes calldata data: Additional data provided with the transfer.

The function returns the function selector of onERC1155BatchReceived as a bytes4 value, which is required by the ERC-1155 standard to acknowledge the successful receipt of the tokens.

supportsInterface

function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool)

This function checks if the contract supports a specific interface. It takes the following parameter:

  • bytes4 interfaceId: The identifier of the interface to be checked.

The function returns a bool value indicating whether the contract supports the specified interface. In this implementation, the contract only supports the IERC1155Receiver interface.

Last updated