IERC1155Receiver.sol 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.0-rc.1 (token/ERC1155/IERC1155Receiver.sol)
  3. pragma solidity ^0.8.0;
  4. import "../../utils/introspection/IERC165.sol";
  5. /**
  6. * @dev _Available since v3.1._
  7. */
  8. interface IERC1155Receiver is IERC165 {
  9. /**
  10. @dev Handles the receipt of a single ERC1155 token type. This function is
  11. called at the end of a `safeTransferFrom` after the balance has been updated.
  12. To accept the transfer, this must return
  13. `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
  14. (i.e. 0xf23a6e61, or its own function selector).
  15. @param operator The address which initiated the transfer (i.e. msg.sender)
  16. @param from The address which previously owned the token
  17. @param id The ID of the token being transferred
  18. @param value The amount of tokens being transferred
  19. @param data Additional data with no specified format
  20. @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
  21. */
  22. function onERC1155Received(
  23. address operator,
  24. address from,
  25. uint256 id,
  26. uint256 value,
  27. bytes calldata data
  28. ) external returns (bytes4);
  29. /**
  30. @dev Handles the receipt of a multiple ERC1155 token types. This function
  31. is called at the end of a `safeBatchTransferFrom` after the balances have
  32. been updated. To accept the transfer(s), this must return
  33. `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
  34. (i.e. 0xbc197c81, or its own function selector).
  35. @param operator The address which initiated the batch transfer (i.e. msg.sender)
  36. @param from The address which previously owned the token
  37. @param ids An array containing ids of each token being transferred (order and length must match values array)
  38. @param values An array containing amounts of each token being transferred (order and length must match ids array)
  39. @param data Additional data with no specified format
  40. @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
  41. */
  42. function onERC1155BatchReceived(
  43. address operator,
  44. address from,
  45. uint256[] calldata ids,
  46. uint256[] calldata values,
  47. bytes calldata data
  48. ) external returns (bytes4);
  49. }