IERC1155Receiver.sol 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity >=0.6.0 <0.8.0;
  3. import "../../introspection/IERC165.sol";
  4. /**
  5. * _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. )
  28. external
  29. returns(bytes4);
  30. /**
  31. @dev Handles the receipt of a multiple ERC1155 token types. This function
  32. is called at the end of a `safeBatchTransferFrom` after the balances have
  33. been updated. To accept the transfer(s), this must return
  34. `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
  35. (i.e. 0xbc197c81, or its own function selector).
  36. @param operator The address which initiated the batch transfer (i.e. msg.sender)
  37. @param from The address which previously owned the token
  38. @param ids An array containing ids of each token being transferred (order and length must match values array)
  39. @param values An array containing amounts of each token being transferred (order and length must match ids array)
  40. @param data Additional data with no specified format
  41. @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
  42. */
  43. function onERC1155BatchReceived(
  44. address operator,
  45. address from,
  46. uint256[] calldata ids,
  47. uint256[] calldata values,
  48. bytes calldata data
  49. )
  50. external
  51. returns(bytes4);
  52. }