IERC1155Receiver.sol 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0) (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. *
  13. * NOTE: To accept the transfer, this must return
  14. * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
  15. * (i.e. 0xf23a6e61, or its own function selector).
  16. *
  17. * @param operator The address which initiated the transfer (i.e. msg.sender)
  18. * @param from The address which previously owned the token
  19. * @param id The ID of the token being transferred
  20. * @param value The amount of tokens being transferred
  21. * @param data Additional data with no specified format
  22. * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
  23. */
  24. function onERC1155Received(
  25. address operator,
  26. address from,
  27. uint256 id,
  28. uint256 value,
  29. bytes calldata data
  30. ) external returns (bytes4);
  31. /**
  32. * @dev Handles the receipt of a multiple ERC1155 token types. This function
  33. * is called at the end of a `safeBatchTransferFrom` after the balances have
  34. * been updated.
  35. *
  36. * NOTE: To accept the transfer(s), this must return
  37. * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
  38. * (i.e. 0xbc197c81, or its own function selector).
  39. *
  40. * @param operator The address which initiated the batch transfer (i.e. msg.sender)
  41. * @param from The address which previously owned the token
  42. * @param ids An array containing ids of each token being transferred (order and length must match values array)
  43. * @param values An array containing amounts of each token being transferred (order and length must match ids array)
  44. * @param data Additional data with no specified format
  45. * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
  46. */
  47. function onERC1155BatchReceived(
  48. address operator,
  49. address from,
  50. uint256[] calldata ids,
  51. uint256[] calldata values,
  52. bytes calldata data
  53. ) external returns (bytes4);
  54. }