IERC777.sol 6.5 KB

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