IERC777.sol 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.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(address recipient, uint256 amount, bytes calldata data) external;
  55. /**
  56. * @dev Destroys `amount` tokens from the caller's account, reducing the
  57. * total supply.
  58. *
  59. * If a send hook is registered for the caller, the corresponding function
  60. * will be called with `data` and empty `operatorData`. See {IERC777Sender}.
  61. *
  62. * Emits a {Burned} event.
  63. *
  64. * Requirements
  65. *
  66. * - the caller must have at least `amount` tokens.
  67. */
  68. function burn(uint256 amount, bytes calldata data) external;
  69. /**
  70. * @dev Returns true if an account is an operator of `tokenHolder`.
  71. * Operators can send and burn tokens on behalf of their owners. All
  72. * accounts are their own operator.
  73. *
  74. * See {operatorSend} and {operatorBurn}.
  75. */
  76. function isOperatorFor(address operator, address tokenHolder) external view returns (bool);
  77. /**
  78. * @dev Make an account an operator of the caller.
  79. *
  80. * See {isOperatorFor}.
  81. *
  82. * Emits an {AuthorizedOperator} event.
  83. *
  84. * Requirements
  85. *
  86. * - `operator` cannot be calling address.
  87. */
  88. function authorizeOperator(address operator) external;
  89. /**
  90. * @dev Revoke an account's operator status for the caller.
  91. *
  92. * See {isOperatorFor} and {defaultOperators}.
  93. *
  94. * Emits a {RevokedOperator} event.
  95. *
  96. * Requirements
  97. *
  98. * - `operator` cannot be calling address.
  99. */
  100. function revokeOperator(address operator) external;
  101. /**
  102. * @dev Returns the list of default operators. These accounts are operators
  103. * for all token holders, even if {authorizeOperator} was never called on
  104. * them.
  105. *
  106. * This list is immutable, but individual holders may revoke these via
  107. * {revokeOperator}, in which case {isOperatorFor} will return false.
  108. */
  109. function defaultOperators() external view returns (address[] memory);
  110. /**
  111. * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must
  112. * be an operator of `sender`.
  113. *
  114. * If send or receive hooks are registered for `sender` and `recipient`,
  115. * the corresponding functions will be called with `data` and
  116. * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
  117. *
  118. * Emits a {Sent} event.
  119. *
  120. * Requirements
  121. *
  122. * - `sender` cannot be the zero address.
  123. * - `sender` must have at least `amount` tokens.
  124. * - the caller must be an operator for `sender`.
  125. * - `recipient` cannot be the zero address.
  126. * - if `recipient` is a contract, it must implement the {IERC777Recipient}
  127. * interface.
  128. */
  129. function operatorSend(
  130. address sender,
  131. address recipient,
  132. uint256 amount,
  133. bytes calldata data,
  134. bytes calldata operatorData
  135. ) external;
  136. /**
  137. * @dev Destroys `amount` tokens from `account`, reducing the total supply.
  138. * The caller must be an operator of `account`.
  139. *
  140. * If a send hook is registered for `account`, the corresponding function
  141. * will be called with `data` and `operatorData`. See {IERC777Sender}.
  142. *
  143. * Emits a {Burned} event.
  144. *
  145. * Requirements
  146. *
  147. * - `account` cannot be the zero address.
  148. * - `account` must have at least `amount` tokens.
  149. * - the caller must be an operator for `account`.
  150. */
  151. function operatorBurn(
  152. address account,
  153. uint256 amount,
  154. bytes calldata data,
  155. bytes calldata operatorData
  156. ) external;
  157. event Sent(
  158. address indexed operator,
  159. address indexed from,
  160. address indexed to,
  161. uint256 amount,
  162. bytes data,
  163. bytes operatorData
  164. );
  165. event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
  166. event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
  167. event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
  168. event RevokedOperator(address indexed operator, address indexed tokenHolder);
  169. }