IERC777.sol 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC777.sol)
  3. pragma solidity >=0.5.0;
  4. /**
  5. * @dev Interface of the ERC-777 Token standard as defined in the ERC.
  6. *
  7. * This contract uses the
  8. * https://eips.ethereum.org/EIPS/eip-1820[ERC-1820 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. * {IERC1820Implementer}.
  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(address recipient, uint256 amount, bytes calldata data) external;
  76. /**
  77. * @dev Destroys `amount` tokens from the caller's account, reducing the
  78. * total supply.
  79. *
  80. * If a send hook is registered for the caller, the corresponding function
  81. * will be called with `data` and empty `operatorData`. See {IERC777Sender}.
  82. *
  83. * Emits a {Burned} event.
  84. *
  85. * Requirements
  86. *
  87. * - the caller must have at least `amount` tokens.
  88. */
  89. function burn(uint256 amount, bytes calldata data) external;
  90. /**
  91. * @dev Returns true if an account is an operator of `tokenHolder`.
  92. * Operators can send and burn tokens on behalf of their owners. All
  93. * accounts are their own operator.
  94. *
  95. * See {operatorSend} and {operatorBurn}.
  96. */
  97. function isOperatorFor(address operator, address tokenHolder) external view returns (bool);
  98. /**
  99. * @dev Make an account an operator of the caller.
  100. *
  101. * See {isOperatorFor}.
  102. *
  103. * Emits an {AuthorizedOperator} event.
  104. *
  105. * Requirements
  106. *
  107. * - `operator` cannot be calling address.
  108. */
  109. function authorizeOperator(address operator) external;
  110. /**
  111. * @dev Revoke an account's operator status for the caller.
  112. *
  113. * See {isOperatorFor} and {defaultOperators}.
  114. *
  115. * Emits a {RevokedOperator} event.
  116. *
  117. * Requirements
  118. *
  119. * - `operator` cannot be calling address.
  120. */
  121. function revokeOperator(address operator) external;
  122. /**
  123. * @dev Returns the list of default operators. These accounts are operators
  124. * for all token holders, even if {authorizeOperator} was never called on
  125. * them.
  126. *
  127. * This list is immutable, but individual holders may revoke these via
  128. * {revokeOperator}, in which case {isOperatorFor} will return false.
  129. */
  130. function defaultOperators() external view returns (address[] memory);
  131. /**
  132. * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must
  133. * be an operator of `sender`.
  134. *
  135. * If send or receive hooks are registered for `sender` and `recipient`,
  136. * the corresponding functions will be called with `data` and
  137. * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
  138. *
  139. * Emits a {Sent} event.
  140. *
  141. * Requirements
  142. *
  143. * - `sender` cannot be the zero address.
  144. * - `sender` must have at least `amount` tokens.
  145. * - the caller must be an operator for `sender`.
  146. * - `recipient` cannot be the zero address.
  147. * - if `recipient` is a contract, it must implement the {IERC777Recipient}
  148. * interface.
  149. */
  150. function operatorSend(
  151. address sender,
  152. address recipient,
  153. uint256 amount,
  154. bytes calldata data,
  155. bytes calldata operatorData
  156. ) external;
  157. /**
  158. * @dev Destroys `amount` tokens from `account`, reducing the total supply.
  159. * The caller must be an operator of `account`.
  160. *
  161. * If a send hook is registered for `account`, the corresponding function
  162. * will be called with `data` and `operatorData`. See {IERC777Sender}.
  163. *
  164. * Emits a {Burned} event.
  165. *
  166. * Requirements
  167. *
  168. * - `account` cannot be the zero address.
  169. * - `account` must have at least `amount` tokens.
  170. * - the caller must be an operator for `account`.
  171. */
  172. function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
  173. event Sent(
  174. address indexed operator,
  175. address indexed from,
  176. address indexed to,
  177. uint256 amount,
  178. bytes data,
  179. bytes operatorData
  180. );
  181. }