IERC777.sol 6.1 KB

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