IERC777.sol 6.0 KB

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