IERC777.sol 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC777/IERC777.sol)
  3. pragma solidity ^0.8.0;
  4. /**
  5. * @dev Interface of the ERC777Token standard as defined in the EIP.
  6. *
  7. * This contract uses the
  8. * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let
  9. * token holders and recipients react to token movements by using setting implementers
  10. * for the associated interfaces in said registry. See {IERC1820Registry} and
  11. * {ERC1820Implementer}.
  12. */
  13. interface IERC777 {
  14. /**
  15. * @dev Emitted when `amount` tokens are created by `operator` and assigned to `to`.
  16. *
  17. * Note that some additional user `data` and `operatorData` can be logged in the event.
  18. */
  19. event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
  20. /**
  21. * @dev Emitted when `operator` destroys `amount` tokens from `account`.
  22. *
  23. * Note that some additional user `data` and `operatorData` can be logged in the event.
  24. */
  25. event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
  26. /**
  27. * @dev Emitted when `operator` is made operator for `tokenHolder`
  28. */
  29. event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
  30. /**
  31. * @dev Emitted when `operator` is revoked its operator status for `tokenHolder`
  32. */
  33. event RevokedOperator(address indexed operator, address indexed tokenHolder);
  34. /**
  35. * @dev Returns the name of the token.
  36. */
  37. function name() external view returns (string memory);
  38. /**
  39. * @dev Returns the symbol of the token, usually a shorter version of the
  40. * name.
  41. */
  42. function symbol() external view returns (string memory);
  43. /**
  44. * @dev Returns the smallest part of the token that is not divisible. This
  45. * means all token operations (creation, movement and destruction) must have
  46. * amounts that are a multiple of this number.
  47. *
  48. * For most token contracts, this value will equal 1.
  49. */
  50. function granularity() external view returns (uint256);
  51. /**
  52. * @dev Returns the amount of tokens in existence.
  53. */
  54. function totalSupply() external view returns (uint256);
  55. /**
  56. * @dev Returns the amount of tokens owned by an account (`owner`).
  57. */
  58. function balanceOf(address owner) external view returns (uint256);
  59. /**
  60. * @dev Moves `amount` tokens from the caller's account to `recipient`.
  61. *
  62. * If send or receive hooks are registered for the caller and `recipient`,
  63. * the corresponding functions will be called with `data` and empty
  64. * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
  65. *
  66. * Emits a {Sent} event.
  67. *
  68. * Requirements
  69. *
  70. * - the caller must have at least `amount` tokens.
  71. * - `recipient` cannot be the zero address.
  72. * - if `recipient` is a contract, it must implement the {IERC777Recipient}
  73. * interface.
  74. */
  75. function send(
  76. address recipient,
  77. uint256 amount,
  78. bytes calldata data
  79. ) external;
  80. /**
  81. * @dev Destroys `amount` tokens from the caller's account, reducing the
  82. * total supply.
  83. *
  84. * If a send hook is registered for the caller, the corresponding function
  85. * will be called with `data` and empty `operatorData`. See {IERC777Sender}.
  86. *
  87. * Emits a {Burned} event.
  88. *
  89. * Requirements
  90. *
  91. * - the caller must have at least `amount` tokens.
  92. */
  93. function burn(uint256 amount, bytes calldata data) external;
  94. /**
  95. * @dev Returns true if an account is an operator of `tokenHolder`.
  96. * Operators can send and burn tokens on behalf of their owners. All
  97. * accounts are their own operator.
  98. *
  99. * See {operatorSend} and {operatorBurn}.
  100. */
  101. function isOperatorFor(address operator, address tokenHolder) external view returns (bool);
  102. /**
  103. * @dev Make an account an operator of the caller.
  104. *
  105. * See {isOperatorFor}.
  106. *
  107. * Emits an {AuthorizedOperator} event.
  108. *
  109. * Requirements
  110. *
  111. * - `operator` cannot be calling address.
  112. */
  113. function authorizeOperator(address operator) external;
  114. /**
  115. * @dev Revoke an account's operator status for the caller.
  116. *
  117. * See {isOperatorFor} and {defaultOperators}.
  118. *
  119. * Emits a {RevokedOperator} event.
  120. *
  121. * Requirements
  122. *
  123. * - `operator` cannot be calling address.
  124. */
  125. function revokeOperator(address operator) external;
  126. /**
  127. * @dev Returns the list of default operators. These accounts are operators
  128. * for all token holders, even if {authorizeOperator} was never called on
  129. * them.
  130. *
  131. * This list is immutable, but individual holders may revoke these via
  132. * {revokeOperator}, in which case {isOperatorFor} will return false.
  133. */
  134. function defaultOperators() external view returns (address[] memory);
  135. /**
  136. * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must
  137. * be an operator of `sender`.
  138. *
  139. * If send or receive hooks are registered for `sender` and `recipient`,
  140. * the corresponding functions will be called with `data` and
  141. * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
  142. *
  143. * Emits a {Sent} event.
  144. *
  145. * Requirements
  146. *
  147. * - `sender` cannot be the zero address.
  148. * - `sender` must have at least `amount` tokens.
  149. * - the caller must be an operator for `sender`.
  150. * - `recipient` cannot be the zero address.
  151. * - if `recipient` is a contract, it must implement the {IERC777Recipient}
  152. * interface.
  153. */
  154. function operatorSend(
  155. address sender,
  156. address recipient,
  157. uint256 amount,
  158. bytes calldata data,
  159. bytes calldata operatorData
  160. ) external;
  161. /**
  162. * @dev Destroys `amount` tokens from `account`, reducing the total supply.
  163. * The caller must be an operator of `account`.
  164. *
  165. * If a send hook is registered for `account`, the corresponding function
  166. * will be called with `data` and `operatorData`. See {IERC777Sender}.
  167. *
  168. * Emits a {Burned} event.
  169. *
  170. * Requirements
  171. *
  172. * - `account` cannot be the zero address.
  173. * - `account` must have at least `amount` tokens.
  174. * - the caller must be an operator for `account`.
  175. */
  176. function operatorBurn(
  177. address account,
  178. uint256 amount,
  179. bytes calldata data,
  180. bytes calldata operatorData
  181. ) external;
  182. event Sent(
  183. address indexed operator,
  184. address indexed from,
  185. address indexed to,
  186. uint256 amount,
  187. bytes data,
  188. bytes operatorData
  189. );
  190. }