IERC1155Receiver.sol 2.3 KB

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