IERC777.sol 5.9 KB

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