IERC1155.sol 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.7.0;
  3. import "../../introspection/IERC165.sol";
  4. /**
  5. * @dev Required interface of an ERC1155 compliant contract, as defined in the
  6. * https://eips.ethereum.org/EIPS/eip-1155[EIP].
  7. *
  8. * _Available since v3.1._
  9. */
  10. interface IERC1155 is IERC165 {
  11. /**
  12. * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
  13. */
  14. event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
  15. /**
  16. * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
  17. * transfers.
  18. */
  19. event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
  20. /**
  21. * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
  22. * `approved`.
  23. */
  24. event ApprovalForAll(address indexed account, address indexed operator, bool approved);
  25. /**
  26. * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
  27. *
  28. * If an {URI} event was emitted for `id`, the standard
  29. * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
  30. * returned by {IERC1155MetadataURI-uri}.
  31. */
  32. event URI(string value, uint256 indexed id);
  33. /**
  34. * @dev Returns the amount of tokens of token type `id` owned by `account`.
  35. *
  36. * Requirements:
  37. *
  38. * - `account` cannot be the zero address.
  39. */
  40. function balanceOf(address account, uint256 id) external view returns (uint256);
  41. /**
  42. * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
  43. *
  44. * Requirements:
  45. *
  46. * - `accounts` and `ids` must have the same length.
  47. */
  48. function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
  49. /**
  50. * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
  51. *
  52. * Emits an {ApprovalForAll} event.
  53. *
  54. * Requirements:
  55. *
  56. * - `operator` cannot be the caller.
  57. */
  58. function setApprovalForAll(address operator, bool approved) external;
  59. /**
  60. * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
  61. *
  62. * See {setApprovalForAll}.
  63. */
  64. function isApprovedForAll(address account, address operator) external view returns (bool);
  65. /**
  66. * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
  67. *
  68. * Emits a {TransferSingle} event.
  69. *
  70. * Requirements:
  71. *
  72. * - `to` cannot be the zero address.
  73. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
  74. * - `from` must have a balance of tokens of type `id` of at least `amount`.
  75. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
  76. * acceptance magic value.
  77. */
  78. function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
  79. /**
  80. * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
  81. *
  82. * Emits a {TransferBatch} event.
  83. *
  84. * Requirements:
  85. *
  86. * - `ids` and `amounts` must have the same length.
  87. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
  88. * acceptance magic value.
  89. */
  90. function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
  91. }