IERC1155Receiver.sol 2.5 KB

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