IERC1155Receiver.sol 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.0;
  3. import "../../introspection/IERC165.sol";
  4. /**
  5. @title ERC-1155 Multi Token Receiver Interface
  6. @dev See https://eips.ethereum.org/EIPS/eip-1155
  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. )
  29. external
  30. 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. To accept the transfer(s), this must return
  35. `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
  36. (i.e. 0xbc197c81, or its own function selector).
  37. @param operator The address which initiated the batch transfer (i.e. msg.sender)
  38. @param from The address which previously owned the token
  39. @param ids An array containing ids of each token being transferred (order and length must match values array)
  40. @param values An array containing amounts of each token being transferred (order and length must match ids array)
  41. @param data Additional data with no specified format
  42. @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
  43. */
  44. function onERC1155BatchReceived(
  45. address operator,
  46. address from,
  47. uint256[] calldata ids,
  48. uint256[] calldata values,
  49. bytes calldata data
  50. )
  51. external
  52. returns(bytes4);
  53. }