Transaction Hash:
Block:
22273046 at Apr-15-2025 07:58:23 AM +UTC
Transaction Fee:
0.000016505036071678 ETH
$0.04
Gas Used:
45,034 Gas / 0.366501667 Gwei
Emitted Events:
| 107 |
DMCCOIN.Sent( operator=[Sender] 0x354508023cb93cf95a69791f2a8d6520434db693, from=[Sender] 0x354508023cb93cf95a69791f2a8d6520434db693, to=0x6690069D669fa5820063A57195651f46c22b7418, amount=11185000000000000000000, data=0x, operatorData=0x )
|
| 108 |
DMCCOIN.Transfer( from=[Sender] 0x354508023cb93cf95a69791f2a8d6520434db693, to=0x6690069D669fa5820063A57195651f46c22b7418, value=11185000000000000000000 )
|
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
| 0x148255a3...48974bf2C | |||||
| 0x35450802...0434db693 |
0.000699565698992784 Eth
Nonce: 2
|
0.000683060662921106 Eth
Nonce: 3
| 0.000016505036071678 | ||
|
0x388C818C...7ccB19297
Miner
| (Lido: Execution Layer Rewards Vault) | 83.467848382695660087 Eth | 83.467848401372655941 Eth | 0.000000018676995854 |
Execution Trace
DMCCOIN.transfer( recipient=0x6690069D669fa5820063A57195651f46c22b7418, amount=11185000000000000000000 ) => ( True )
-
ERC1820Registry.getInterfaceImplementer( _addr=0x354508023cb93cF95a69791f2a8D6520434db693, _interfaceHash=29DDB589B1FB5FC7CF394961C1ADF5F8C6454761ADF795E67FE149F658ABE895 ) => ( 0x0000000000000000000000000000000000000000 ) -
ERC1820Registry.getInterfaceImplementer( _addr=0x6690069D669fa5820063A57195651f46c22b7418, _interfaceHash=B281FC8C12954D22544DB45DE3159A39272895B169A852B314F9CC762E44C53B ) => ( 0x0000000000000000000000000000000000000000 )
File 1 of 2: DMCCOIN
File 2 of 2: ERC1820Registry
{"Address.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\r\n\r\npragma solidity ^0.8.1;\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * You shouldn\u0027t rely on `isContract` to protect against flash loan attacks!\r\n *\r\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\r\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\r\n * constructor.\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize/address.code.length, which returns 0\r\n // for contracts in construction, since the code is only stored at the end\r\n // of the constructor execution.\r\n\r\n return account.code.length \u003e 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity\u0027s `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\r\n (bool success, bytes memory returndata) = target.call{value: value}(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\r\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.delegatecall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\r\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\r\n *\r\n * _Available since v4.8._\r\n */\r\n function verifyCallResultFromTarget(\r\n address target,\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n if (success) {\r\n if (returndata.length == 0) {\r\n // only check isContract if the call was successful and the return data is empty\r\n // otherwise we already know that it was a contract\r\n require(isContract(target), \"Address: call to non-contract\");\r\n }\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call was successful, and revert if it wasn\u0027t, either by bubbling the\r\n * revert reason or using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length \u003e 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n}"},"Context.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n}"},"DMCCOIN.sol":{"content":"// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.0;\r\n\r\nimport \"ERC777.sol\";\r\n\r\ncontract DMCCOIN is ERC777 {\r\n constructor(uint256 initialSupply, address[] memory defaultOperators)\r\n ERC777(\"DMCCOIN\", \"DMCC\", defaultOperators)\r\n {\r\n _mint(msg.sender, initialSupply, \"\", \"\");\r\n }\r\n}"},"ERC777.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC777/ERC777.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"IERC777.sol\";\r\nimport \"IERC777Recipient.sol\";\r\nimport \"IERC777Sender.sol\";\r\nimport \"IERC20.sol\";\r\nimport \"Address.sol\";\r\nimport \"Context.sol\";\r\nimport \"IERC1820Registry.sol\";\r\n\r\n/**\r\n * @dev Implementation of the {IERC777} interface.\r\n *\r\n * This implementation is agnostic to the way tokens are created. This means\r\n * that a supply mechanism has to be added in a derived contract using {_mint}.\r\n *\r\n * Support for ERC20 is included in this contract, as specified by the EIP: both\r\n * the ERC777 and ERC20 interfaces can be safely used when interacting with it.\r\n * Both {IERC777-Sent} and {IERC20-Transfer} events are emitted on token\r\n * movements.\r\n *\r\n * Additionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there\r\n * are no special restrictions in the amount of tokens that created, moved, or\r\n * destroyed. This makes integration with ERC20 applications seamless.\r\n */\r\ncontract ERC777 is Context, IERC777, IERC20 {\r\n using Address for address;\r\n\r\n IERC1820Registry internal constant _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);\r\n\r\n mapping(address =\u003e uint256) private _balances;\r\n\r\n uint256 private _totalSupply;\r\n\r\n string private _name;\r\n string private _symbol;\r\n\r\n bytes32 private constant _TOKENS_SENDER_INTERFACE_HASH = keccak256(\"ERC777TokensSender\");\r\n bytes32 private constant _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256(\"ERC777TokensRecipient\");\r\n\r\n // This isn\u0027t ever read from - it\u0027s only used to respond to the defaultOperators query.\r\n address[] private _defaultOperatorsArray;\r\n\r\n // Immutable, but accounts may revoke them (tracked in __revokedDefaultOperators).\r\n mapping(address =\u003e bool) private _defaultOperators;\r\n\r\n // For each account, a mapping of its operators and revoked default operators.\r\n mapping(address =\u003e mapping(address =\u003e bool)) private _operators;\r\n mapping(address =\u003e mapping(address =\u003e bool)) private _revokedDefaultOperators;\r\n\r\n // ERC20-allowances\r\n mapping(address =\u003e mapping(address =\u003e uint256)) private _allowances;\r\n\r\n /**\r\n * @dev `defaultOperators` may be an empty array.\r\n */\r\n constructor(\r\n string memory name_,\r\n string memory symbol_,\r\n address[] memory defaultOperators_\r\n ) {\r\n _name = name_;\r\n _symbol = symbol_;\r\n\r\n _defaultOperatorsArray = defaultOperators_;\r\n for (uint256 i = 0; i \u003c defaultOperators_.length; i++) {\r\n _defaultOperators[defaultOperators_[i]] = true;\r\n }\r\n\r\n // register interfaces\r\n _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256(\"ERC777Token\"), address(this));\r\n _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256(\"ERC20Token\"), address(this));\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-name}.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-symbol}.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev See {ERC20-decimals}.\r\n *\r\n * Always returns 18, as per the\r\n * [ERC777 EIP](https://eips.ethereum.org/EIPS/eip-777#backward-compatibility).\r\n */\r\n function decimals() public pure virtual returns (uint8) {\r\n return 18;\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-granularity}.\r\n *\r\n * This implementation always returns `1`.\r\n */\r\n function granularity() public view virtual override returns (uint256) {\r\n return 1;\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-totalSupply}.\r\n */\r\n function totalSupply() public view virtual override(IERC20, IERC777) returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by an account (`tokenHolder`).\r\n */\r\n function balanceOf(address tokenHolder) public view virtual override(IERC20, IERC777) returns (uint256) {\r\n return _balances[tokenHolder];\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-send}.\r\n *\r\n * Also emits a {IERC20-Transfer} event for ERC20 compatibility.\r\n */\r\n function send(\r\n address recipient,\r\n uint256 amount,\r\n bytes memory data\r\n ) public virtual override {\r\n _send(_msgSender(), recipient, amount, data, \"\", true);\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transfer}.\r\n *\r\n * Unlike `send`, `recipient` is _not_ required to implement the {IERC777Recipient}\r\n * interface if it is a contract.\r\n *\r\n * Also emits a {Sent} event.\r\n */\r\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\r\n _send(_msgSender(), recipient, amount, \"\", \"\", false);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-burn}.\r\n *\r\n * Also emits a {IERC20-Transfer} event for ERC20 compatibility.\r\n */\r\n function burn(uint256 amount, bytes memory data) public virtual override {\r\n _burn(_msgSender(), amount, data, \"\");\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-isOperatorFor}.\r\n */\r\n function isOperatorFor(address operator, address tokenHolder) public view virtual override returns (bool) {\r\n return\r\n operator == tokenHolder ||\r\n (_defaultOperators[operator] \u0026\u0026 !_revokedDefaultOperators[tokenHolder][operator]) ||\r\n _operators[tokenHolder][operator];\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-authorizeOperator}.\r\n */\r\n function authorizeOperator(address operator) public virtual override {\r\n require(_msgSender() != operator, \"ERC777: authorizing self as operator\");\r\n\r\n if (_defaultOperators[operator]) {\r\n delete _revokedDefaultOperators[_msgSender()][operator];\r\n } else {\r\n _operators[_msgSender()][operator] = true;\r\n }\r\n\r\n emit AuthorizedOperator(operator, _msgSender());\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-revokeOperator}.\r\n */\r\n function revokeOperator(address operator) public virtual override {\r\n require(operator != _msgSender(), \"ERC777: revoking self as operator\");\r\n\r\n if (_defaultOperators[operator]) {\r\n _revokedDefaultOperators[_msgSender()][operator] = true;\r\n } else {\r\n delete _operators[_msgSender()][operator];\r\n }\r\n\r\n emit RevokedOperator(operator, _msgSender());\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-defaultOperators}.\r\n */\r\n function defaultOperators() public view virtual override returns (address[] memory) {\r\n return _defaultOperatorsArray;\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-operatorSend}.\r\n *\r\n * Emits {Sent} and {IERC20-Transfer} events.\r\n */\r\n function operatorSend(\r\n address sender,\r\n address recipient,\r\n uint256 amount,\r\n bytes memory data,\r\n bytes memory operatorData\r\n ) public virtual override {\r\n require(isOperatorFor(_msgSender(), sender), \"ERC777: caller is not an operator for holder\");\r\n _send(sender, recipient, amount, data, operatorData, true);\r\n }\r\n\r\n /**\r\n * @dev See {IERC777-operatorBurn}.\r\n *\r\n * Emits {Burned} and {IERC20-Transfer} events.\r\n */\r\n function operatorBurn(\r\n address account,\r\n uint256 amount,\r\n bytes memory data,\r\n bytes memory operatorData\r\n ) public virtual override {\r\n require(isOperatorFor(_msgSender(), account), \"ERC777: caller is not an operator for holder\");\r\n _burn(account, amount, data, operatorData);\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-allowance}.\r\n *\r\n * Note that operator and allowance concepts are orthogonal: operators may\r\n * not have allowance, and accounts with allowance may not be operators\r\n * themselves.\r\n */\r\n function allowance(address holder, address spender) public view virtual override returns (uint256) {\r\n return _allowances[holder][spender];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-approve}.\r\n *\r\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\r\n * `transferFrom`. This is semantically equivalent to an infinite approval.\r\n *\r\n * Note that accounts cannot have allowance issued by their operators.\r\n */\r\n function approve(address spender, uint256 value) public virtual override returns (bool) {\r\n address holder = _msgSender();\r\n _approve(holder, spender, value);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transferFrom}.\r\n *\r\n * NOTE: Does not update the allowance if the current allowance\r\n * is the maximum `uint256`.\r\n *\r\n * Note that operator and allowance concepts are orthogonal: operators cannot\r\n * call `transferFrom` (unless they have allowance), and accounts with\r\n * allowance cannot call `operatorSend` (unless they are operators).\r\n *\r\n * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events.\r\n */\r\n function transferFrom(\r\n address holder,\r\n address recipient,\r\n uint256 amount\r\n ) public virtual override returns (bool) {\r\n address spender = _msgSender();\r\n _spendAllowance(holder, spender, amount);\r\n _send(holder, recipient, amount, \"\", \"\", false);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Creates `amount` tokens and assigns them to `account`, increasing\r\n * the total supply.\r\n *\r\n * If a send hook is registered for `account`, the corresponding function\r\n * will be called with the caller address as the `operator` and with\r\n * `userData` and `operatorData`.\r\n *\r\n * See {IERC777Sender} and {IERC777Recipient}.\r\n *\r\n * Emits {Minted} and {IERC20-Transfer} events.\r\n *\r\n * Requirements\r\n *\r\n * - `account` cannot be the zero address.\r\n * - if `account` is a contract, it must implement the {IERC777Recipient}\r\n * interface.\r\n */\r\n function _mint(\r\n address account,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData\r\n ) internal virtual {\r\n _mint(account, amount, userData, operatorData, true);\r\n }\r\n\r\n /**\r\n * @dev Creates `amount` tokens and assigns them to `account`, increasing\r\n * the total supply.\r\n *\r\n * If `requireReceptionAck` is set to true, and if a send hook is\r\n * registered for `account`, the corresponding function will be called with\r\n * `operator`, `data` and `operatorData`.\r\n *\r\n * See {IERC777Sender} and {IERC777Recipient}.\r\n *\r\n * Emits {Minted} and {IERC20-Transfer} events.\r\n *\r\n * Requirements\r\n *\r\n * - `account` cannot be the zero address.\r\n * - if `account` is a contract, it must implement the {IERC777Recipient}\r\n * interface.\r\n */\r\n function _mint(\r\n address account,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData,\r\n bool requireReceptionAck\r\n ) internal virtual {\r\n require(account != address(0), \"ERC777: mint to the zero address\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, address(0), account, amount);\r\n\r\n // Update state variables\r\n _totalSupply += amount;\r\n _balances[account] += amount;\r\n\r\n _callTokensReceived(operator, address(0), account, amount, userData, operatorData, requireReceptionAck);\r\n\r\n emit Minted(operator, account, amount, userData, operatorData);\r\n emit Transfer(address(0), account, amount);\r\n }\r\n\r\n /**\r\n * @dev Send tokens\r\n * @param from address token holder address\r\n * @param to address recipient address\r\n * @param amount uint256 amount of tokens to transfer\r\n * @param userData bytes extra information provided by the token holder (if any)\r\n * @param operatorData bytes extra information provided by the operator (if any)\r\n * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient\r\n */\r\n function _send(\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData,\r\n bool requireReceptionAck\r\n ) internal virtual {\r\n require(from != address(0), \"ERC777: transfer from the zero address\");\r\n require(to != address(0), \"ERC777: transfer to the zero address\");\r\n\r\n address operator = _msgSender();\r\n\r\n _callTokensToSend(operator, from, to, amount, userData, operatorData);\r\n\r\n _move(operator, from, to, amount, userData, operatorData);\r\n\r\n _callTokensReceived(operator, from, to, amount, userData, operatorData, requireReceptionAck);\r\n }\r\n\r\n /**\r\n * @dev Burn tokens\r\n * @param from address token holder address\r\n * @param amount uint256 amount of tokens to burn\r\n * @param data bytes extra information provided by the token holder\r\n * @param operatorData bytes extra information provided by the operator (if any)\r\n */\r\n function _burn(\r\n address from,\r\n uint256 amount,\r\n bytes memory data,\r\n bytes memory operatorData\r\n ) internal virtual {\r\n require(from != address(0), \"ERC777: burn from the zero address\");\r\n\r\n address operator = _msgSender();\r\n\r\n _callTokensToSend(operator, from, address(0), amount, data, operatorData);\r\n\r\n _beforeTokenTransfer(operator, from, address(0), amount);\r\n\r\n // Update state variables\r\n uint256 fromBalance = _balances[from];\r\n require(fromBalance \u003e= amount, \"ERC777: burn amount exceeds balance\");\r\n unchecked {\r\n _balances[from] = fromBalance - amount;\r\n }\r\n _totalSupply -= amount;\r\n\r\n emit Burned(operator, from, amount, data, operatorData);\r\n emit Transfer(from, address(0), amount);\r\n }\r\n\r\n function _move(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData\r\n ) private {\r\n _beforeTokenTransfer(operator, from, to, amount);\r\n\r\n uint256 fromBalance = _balances[from];\r\n require(fromBalance \u003e= amount, \"ERC777: transfer amount exceeds balance\");\r\n unchecked {\r\n _balances[from] = fromBalance - amount;\r\n }\r\n _balances[to] += amount;\r\n\r\n emit Sent(operator, from, to, amount, userData, operatorData);\r\n emit Transfer(from, to, amount);\r\n }\r\n\r\n /**\r\n * @dev See {ERC20-_approve}.\r\n *\r\n * Note that accounts cannot have allowance issued by their operators.\r\n */\r\n function _approve(\r\n address holder,\r\n address spender,\r\n uint256 value\r\n ) internal virtual {\r\n require(holder != address(0), \"ERC777: approve from the zero address\");\r\n require(spender != address(0), \"ERC777: approve to the zero address\");\r\n\r\n _allowances[holder][spender] = value;\r\n emit Approval(holder, spender, value);\r\n }\r\n\r\n /**\r\n * @dev Call from.tokensToSend() if the interface is registered\r\n * @param operator address operator requesting the transfer\r\n * @param from address token holder address\r\n * @param to address recipient address\r\n * @param amount uint256 amount of tokens to transfer\r\n * @param userData bytes extra information provided by the token holder (if any)\r\n * @param operatorData bytes extra information provided by the operator (if any)\r\n */\r\n function _callTokensToSend(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData\r\n ) private {\r\n address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(from, _TOKENS_SENDER_INTERFACE_HASH);\r\n if (implementer != address(0)) {\r\n IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Call to.tokensReceived() if the interface is registered. Reverts if the recipient is a contract but\r\n * tokensReceived() was not registered for the recipient\r\n * @param operator address operator requesting the transfer\r\n * @param from address token holder address\r\n * @param to address recipient address\r\n * @param amount uint256 amount of tokens to transfer\r\n * @param userData bytes extra information provided by the token holder (if any)\r\n * @param operatorData bytes extra information provided by the operator (if any)\r\n * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient\r\n */\r\n function _callTokensReceived(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes memory userData,\r\n bytes memory operatorData,\r\n bool requireReceptionAck\r\n ) private {\r\n address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(to, _TOKENS_RECIPIENT_INTERFACE_HASH);\r\n if (implementer != address(0)) {\r\n IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData);\r\n } else if (requireReceptionAck) {\r\n require(!to.isContract(), \"ERC777: token recipient contract has no implementer for ERC777TokensRecipient\");\r\n }\r\n }\r\n\r\n /**\r\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\r\n *\r\n * Does not update the allowance amount in case of infinite allowance.\r\n * Revert if not enough allowance is available.\r\n *\r\n * Might emit an {IERC20-Approval} event.\r\n */\r\n function _spendAllowance(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n uint256 currentAllowance = allowance(owner, spender);\r\n if (currentAllowance != type(uint256).max) {\r\n require(currentAllowance \u003e= amount, \"ERC777: insufficient allowance\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - amount);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any token transfer. This includes\r\n * calls to {send}, {transfer}, {operatorSend}, minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``\u0027s tokens\r\n * will be to transferred to `to`.\r\n * - when `from` is zero, `amount` tokens will be minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``\u0027s tokens will be burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n}"},"IERC1820Registry.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/IERC1820Registry.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the global ERC1820 Registry, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register\r\n * implementers for interfaces in this registry, as well as query support.\r\n *\r\n * Implementers may be shared by multiple accounts, and can also implement more\r\n * than a single interface for each account. Contracts can implement interfaces\r\n * for themselves, but externally-owned accounts (EOA) must delegate this to a\r\n * contract.\r\n *\r\n * {IERC165} interfaces can also be queried via the registry.\r\n *\r\n * For an in-depth explanation and source code analysis, see the EIP text.\r\n */\r\ninterface IERC1820Registry {\r\n event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);\r\n\r\n event ManagerChanged(address indexed account, address indexed newManager);\r\n\r\n /**\r\n * @dev Sets `newManager` as the manager for `account`. A manager of an\r\n * account is able to set interface implementers for it.\r\n *\r\n * By default, each account is its own manager. Passing a value of `0x0` in\r\n * `newManager` will reset the manager to this initial state.\r\n *\r\n * Emits a {ManagerChanged} event.\r\n *\r\n * Requirements:\r\n *\r\n * - the caller must be the current manager for `account`.\r\n */\r\n function setManager(address account, address newManager) external;\r\n\r\n /**\r\n * @dev Returns the manager for `account`.\r\n *\r\n * See {setManager}.\r\n */\r\n function getManager(address account) external view returns (address);\r\n\r\n /**\r\n * @dev Sets the `implementer` contract as ``account``\u0027s implementer for\r\n * `interfaceHash`.\r\n *\r\n * `account` being the zero address is an alias for the caller\u0027s address.\r\n * The zero address can also be used in `implementer` to remove an old one.\r\n *\r\n * See {interfaceHash} to learn how these are created.\r\n *\r\n * Emits an {InterfaceImplementerSet} event.\r\n *\r\n * Requirements:\r\n *\r\n * - the caller must be the current manager for `account`.\r\n * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not\r\n * end in 28 zeroes).\r\n * - `implementer` must implement {IERC1820Implementer} and return true when\r\n * queried for support, unless `implementer` is the caller. See\r\n * {IERC1820Implementer-canImplementInterfaceForAddress}.\r\n */\r\n function setInterfaceImplementer(\r\n address account,\r\n bytes32 _interfaceHash,\r\n address implementer\r\n ) external;\r\n\r\n /**\r\n * @dev Returns the implementer of `interfaceHash` for `account`. If no such\r\n * implementer is registered, returns the zero address.\r\n *\r\n * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28\r\n * zeroes), `account` will be queried for support of it.\r\n *\r\n * `account` being the zero address is an alias for the caller\u0027s address.\r\n */\r\n function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);\r\n\r\n /**\r\n * @dev Returns the interface hash for an `interfaceName`, as defined in the\r\n * corresponding\r\n * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].\r\n */\r\n function interfaceHash(string calldata interfaceName) external pure returns (bytes32);\r\n\r\n /**\r\n * @notice Updates the cache with whether the contract implements an ERC165 interface or not.\r\n * @param account Address of the contract for which to update the cache.\r\n * @param interfaceId ERC165 interface for which to update the cache.\r\n */\r\n function updateERC165Cache(address account, bytes4 interfaceId) external;\r\n\r\n /**\r\n * @notice Checks whether a contract implements an ERC165 interface or not.\r\n * If the result is not cached a direct lookup on the contract address is performed.\r\n * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling\r\n * {updateERC165Cache} with the contract address.\r\n * @param account Address of the contract to check.\r\n * @param interfaceId ERC165 interface to check.\r\n * @return True if `account` implements `interfaceId`, false otherwise.\r\n */\r\n function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);\r\n\r\n /**\r\n * @notice Checks whether a contract implements an ERC165 interface or not without using or updating the cache.\r\n * @param account Address of the contract to check.\r\n * @param interfaceId ERC165 interface to check.\r\n * @return True if `account` implements `interfaceId`, false otherwise.\r\n */\r\n function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);\r\n}"},"IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC20 standard as defined in the EIP.\r\n */\r\ninterface IERC20 {\r\n /**\r\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n * another (`to`).\r\n *\r\n * Note that `value` may be zero.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n /**\r\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n * a call to {approve}. `value` is the new allowance.\r\n */\r\n event Approval(address indexed owner, address indexed spender, uint256 value);\r\n\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by `account`.\r\n */\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller\u0027s account to `to`.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transfer(address to, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Returns the remaining number of tokens that `spender` will be\r\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n * zero by default.\r\n *\r\n * This value changes when {approve} or {transferFrom} are called.\r\n */\r\n function allowance(address owner, address spender) external view returns (uint256);\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the caller\u0027s tokens.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n * that someone may use both the old and the new allowance by unfortunate\r\n * transaction ordering. One possible solution to mitigate this race\r\n * condition is to first reduce the spender\u0027s allowance to 0 and set the\r\n * desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `from` to `to` using the\r\n * allowance mechanism. `amount` is then deducted from the caller\u0027s\r\n * allowance.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) external returns (bool);\r\n}"},"IERC777.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC777/IERC777.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC777Token standard as defined in the EIP.\r\n *\r\n * This contract uses the\r\n * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let\r\n * token holders and recipients react to token movements by using setting implementers\r\n * for the associated interfaces in said registry. See {IERC1820Registry} and\r\n * {ERC1820Implementer}.\r\n */\r\ninterface IERC777 {\r\n /**\r\n * @dev Emitted when `amount` tokens are created by `operator` and assigned to `to`.\r\n *\r\n * Note that some additional user `data` and `operatorData` can be logged in the event.\r\n */\r\n event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);\r\n\r\n /**\r\n * @dev Emitted when `operator` destroys `amount` tokens from `account`.\r\n *\r\n * Note that some additional user `data` and `operatorData` can be logged in the event.\r\n */\r\n event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);\r\n\r\n /**\r\n * @dev Emitted when `operator` is made operator for `tokenHolder`.\r\n */\r\n event AuthorizedOperator(address indexed operator, address indexed tokenHolder);\r\n\r\n /**\r\n * @dev Emitted when `operator` is revoked its operator status for `tokenHolder`.\r\n */\r\n event RevokedOperator(address indexed operator, address indexed tokenHolder);\r\n\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the symbol of the token, usually a shorter version of the\r\n * name.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the smallest part of the token that is not divisible. This\r\n * means all token operations (creation, movement and destruction) must have\r\n * amounts that are a multiple of this number.\r\n *\r\n * For most token contracts, this value will equal 1.\r\n */\r\n function granularity() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by an account (`owner`).\r\n */\r\n function balanceOf(address owner) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller\u0027s account to `recipient`.\r\n *\r\n * If send or receive hooks are registered for the caller and `recipient`,\r\n * the corresponding functions will be called with `data` and empty\r\n * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.\r\n *\r\n * Emits a {Sent} event.\r\n *\r\n * Requirements\r\n *\r\n * - the caller must have at least `amount` tokens.\r\n * - `recipient` cannot be the zero address.\r\n * - if `recipient` is a contract, it must implement the {IERC777Recipient}\r\n * interface.\r\n */\r\n function send(\r\n address recipient,\r\n uint256 amount,\r\n bytes calldata data\r\n ) external;\r\n\r\n /**\r\n * @dev Destroys `amount` tokens from the caller\u0027s account, reducing the\r\n * total supply.\r\n *\r\n * If a send hook is registered for the caller, the corresponding function\r\n * will be called with `data` and empty `operatorData`. See {IERC777Sender}.\r\n *\r\n * Emits a {Burned} event.\r\n *\r\n * Requirements\r\n *\r\n * - the caller must have at least `amount` tokens.\r\n */\r\n function burn(uint256 amount, bytes calldata data) external;\r\n\r\n /**\r\n * @dev Returns true if an account is an operator of `tokenHolder`.\r\n * Operators can send and burn tokens on behalf of their owners. All\r\n * accounts are their own operator.\r\n *\r\n * See {operatorSend} and {operatorBurn}.\r\n */\r\n function isOperatorFor(address operator, address tokenHolder) external view returns (bool);\r\n\r\n /**\r\n * @dev Make an account an operator of the caller.\r\n *\r\n * See {isOperatorFor}.\r\n *\r\n * Emits an {AuthorizedOperator} event.\r\n *\r\n * Requirements\r\n *\r\n * - `operator` cannot be calling address.\r\n */\r\n function authorizeOperator(address operator) external;\r\n\r\n /**\r\n * @dev Revoke an account\u0027s operator status for the caller.\r\n *\r\n * See {isOperatorFor} and {defaultOperators}.\r\n *\r\n * Emits a {RevokedOperator} event.\r\n *\r\n * Requirements\r\n *\r\n * - `operator` cannot be calling address.\r\n */\r\n function revokeOperator(address operator) external;\r\n\r\n /**\r\n * @dev Returns the list of default operators. These accounts are operators\r\n * for all token holders, even if {authorizeOperator} was never called on\r\n * them.\r\n *\r\n * This list is immutable, but individual holders may revoke these via\r\n * {revokeOperator}, in which case {isOperatorFor} will return false.\r\n */\r\n function defaultOperators() external view returns (address[] memory);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must\r\n * be an operator of `sender`.\r\n *\r\n * If send or receive hooks are registered for `sender` and `recipient`,\r\n * the corresponding functions will be called with `data` and\r\n * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.\r\n *\r\n * Emits a {Sent} event.\r\n *\r\n * Requirements\r\n *\r\n * - `sender` cannot be the zero address.\r\n * - `sender` must have at least `amount` tokens.\r\n * - the caller must be an operator for `sender`.\r\n * - `recipient` cannot be the zero address.\r\n * - if `recipient` is a contract, it must implement the {IERC777Recipient}\r\n * interface.\r\n */\r\n function operatorSend(\r\n address sender,\r\n address recipient,\r\n uint256 amount,\r\n bytes calldata data,\r\n bytes calldata operatorData\r\n ) external;\r\n\r\n /**\r\n * @dev Destroys `amount` tokens from `account`, reducing the total supply.\r\n * The caller must be an operator of `account`.\r\n *\r\n * If a send hook is registered for `account`, the corresponding function\r\n * will be called with `data` and `operatorData`. See {IERC777Sender}.\r\n *\r\n * Emits a {Burned} event.\r\n *\r\n * Requirements\r\n *\r\n * - `account` cannot be the zero address.\r\n * - `account` must have at least `amount` tokens.\r\n * - the caller must be an operator for `account`.\r\n */\r\n function operatorBurn(\r\n address account,\r\n uint256 amount,\r\n bytes calldata data,\r\n bytes calldata operatorData\r\n ) external;\r\n\r\n event Sent(\r\n address indexed operator,\r\n address indexed from,\r\n address indexed to,\r\n uint256 amount,\r\n bytes data,\r\n bytes operatorData\r\n );\r\n}"},"IERC777Recipient.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Recipient.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP.\r\n *\r\n * Accounts can be notified of {IERC777} tokens being sent to them by having a\r\n * contract implement this interface (contract holders can be their own\r\n * implementer) and registering it on the\r\n * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].\r\n *\r\n * See {IERC1820Registry} and {ERC1820Implementer}.\r\n */\r\ninterface IERC777Recipient {\r\n /**\r\n * @dev Called by an {IERC777} token contract whenever tokens are being\r\n * moved or created into a registered account (`to`). The type of operation\r\n * is conveyed by `from` being the zero address or not.\r\n *\r\n * This call occurs _after_ the token contract\u0027s state is updated, so\r\n * {IERC777-balanceOf}, etc., can be used to query the post-operation state.\r\n *\r\n * This function may revert to prevent the operation from being executed.\r\n */\r\n function tokensReceived(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes calldata userData,\r\n bytes calldata operatorData\r\n ) external;\r\n}"},"IERC777Sender.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Sender.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC777TokensSender standard as defined in the EIP.\r\n *\r\n * {IERC777} Token holders can be notified of operations performed on their\r\n * tokens by having a contract implement this interface (contract holders can be\r\n * their own implementer) and registering it on the\r\n * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].\r\n *\r\n * See {IERC1820Registry} and {ERC1820Implementer}.\r\n */\r\ninterface IERC777Sender {\r\n /**\r\n * @dev Called by an {IERC777} token contract whenever a registered holder\u0027s\r\n * (`from`) tokens are about to be moved or destroyed. The type of operation\r\n * is conveyed by `to` being the zero address or not.\r\n *\r\n * This call occurs _before_ the token contract\u0027s state is updated, so\r\n * {IERC777-balanceOf}, etc., can be used to query the pre-operation state.\r\n *\r\n * This function may revert to prevent the operation from being executed.\r\n */\r\n function tokensToSend(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 amount,\r\n bytes calldata userData,\r\n bytes calldata operatorData\r\n ) external;\r\n}"}}File 2 of 2: ERC1820Registry
/* ERC1820 Pseudo-introspection Registry Contract
* This standard defines a universal registry smart contract where any address (contract or regular account) can
* register which interface it supports and which smart contract is responsible for its implementation.
*
* Written in 2019 by Jordi Baylina and Jacques Dafflon
*
* To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to
* this software to the public domain worldwide. This software is distributed without any warranty.
*
* You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*
* ███████╗██████╗ ██████╗ ██╗ █████╗ ██████╗ ██████╗
* ██╔════╝██╔══██╗██╔════╝███║██╔══██╗╚════██╗██╔═████╗
* █████╗ ██████╔╝██║ ╚██║╚█████╔╝ █████╔╝██║██╔██║
* ██╔══╝ ██╔══██╗██║ ██║██╔══██╗██╔═══╝ ████╔╝██║
* ███████╗██║ ██║╚██████╗ ██║╚█████╔╝███████╗╚██████╔╝
* ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚════╝ ╚══════╝ ╚═════╝
*
* ██████╗ ███████╗ ██████╗ ██╗███████╗████████╗██████╗ ██╗ ██╗
* ██╔══██╗██╔════╝██╔════╝ ██║██╔════╝╚══██╔══╝██╔══██╗╚██╗ ██╔╝
* ██████╔╝█████╗ ██║ ███╗██║███████╗ ██║ ██████╔╝ ╚████╔╝
* ██╔══██╗██╔══╝ ██║ ██║██║╚════██║ ██║ ██╔══██╗ ╚██╔╝
* ██║ ██║███████╗╚██████╔╝██║███████║ ██║ ██║ ██║ ██║
* ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
*
*/
pragma solidity 0.5.3;
// IV is value needed to have a vanity address starting with '0x1820'.
// IV: 53759
/// @dev The interface a contract MUST implement if it is the implementer of
/// some (other) interface for any address other than itself.
interface ERC1820ImplementerInterface {
/// @notice Indicates whether the contract implements the interface 'interfaceHash' for the address 'addr' or not.
/// @param interfaceHash keccak256 hash of the name of the interface
/// @param addr Address for which the contract will implement the interface
/// @return ERC1820_ACCEPT_MAGIC only if the contract implements 'interfaceHash' for the address 'addr'.
function canImplementInterfaceForAddress(bytes32 interfaceHash, address addr) external view returns(bytes32);
}
/// @title ERC1820 Pseudo-introspection Registry Contract
/// @author Jordi Baylina and Jacques Dafflon
/// @notice This contract is the official implementation of the ERC1820 Registry.
/// @notice For more details, see https://eips.ethereum.org/EIPS/eip-1820
contract ERC1820Registry {
/// @notice ERC165 Invalid ID.
bytes4 constant internal INVALID_ID = 0xffffffff;
/// @notice Method ID for the ERC165 supportsInterface method (= `bytes4(keccak256('supportsInterface(bytes4)'))`).
bytes4 constant internal ERC165ID = 0x01ffc9a7;
/// @notice Magic value which is returned if a contract implements an interface on behalf of some other address.
bytes32 constant internal ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
/// @notice mapping from addresses and interface hashes to their implementers.
mapping(address => mapping(bytes32 => address)) internal interfaces;
/// @notice mapping from addresses to their manager.
mapping(address => address) internal managers;
/// @notice flag for each address and erc165 interface to indicate if it is cached.
mapping(address => mapping(bytes4 => bool)) internal erc165Cached;
/// @notice Indicates a contract is the 'implementer' of 'interfaceHash' for 'addr'.
event InterfaceImplementerSet(address indexed addr, bytes32 indexed interfaceHash, address indexed implementer);
/// @notice Indicates 'newManager' is the address of the new manager for 'addr'.
event ManagerChanged(address indexed addr, address indexed newManager);
/// @notice Query if an address implements an interface and through which contract.
/// @param _addr Address being queried for the implementer of an interface.
/// (If '_addr' is the zero address then 'msg.sender' is assumed.)
/// @param _interfaceHash Keccak256 hash of the name of the interface as a string.
/// E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface.
/// @return The address of the contract which implements the interface '_interfaceHash' for '_addr'
/// or '0' if '_addr' did not register an implementer for this interface.
function getInterfaceImplementer(address _addr, bytes32 _interfaceHash) external view returns (address) {
address addr = _addr == address(0) ? msg.sender : _addr;
if (isERC165Interface(_interfaceHash)) {
bytes4 erc165InterfaceHash = bytes4(_interfaceHash);
return implementsERC165Interface(addr, erc165InterfaceHash) ? addr : address(0);
}
return interfaces[addr][_interfaceHash];
}
/// @notice Sets the contract which implements a specific interface for an address.
/// Only the manager defined for that address can set it.
/// (Each address is the manager for itself until it sets a new manager.)
/// @param _addr Address for which to set the interface.
/// (If '_addr' is the zero address then 'msg.sender' is assumed.)
/// @param _interfaceHash Keccak256 hash of the name of the interface as a string.
/// E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface.
/// @param _implementer Contract address implementing '_interfaceHash' for '_addr'.
function setInterfaceImplementer(address _addr, bytes32 _interfaceHash, address _implementer) external {
address addr = _addr == address(0) ? msg.sender : _addr;
require(getManager(addr) == msg.sender, "Not the manager");
require(!isERC165Interface(_interfaceHash), "Must not be an ERC165 hash");
if (_implementer != address(0) && _implementer != msg.sender) {
require(
ERC1820ImplementerInterface(_implementer)
.canImplementInterfaceForAddress(_interfaceHash, addr) == ERC1820_ACCEPT_MAGIC,
"Does not implement the interface"
);
}
interfaces[addr][_interfaceHash] = _implementer;
emit InterfaceImplementerSet(addr, _interfaceHash, _implementer);
}
/// @notice Sets '_newManager' as manager for '_addr'.
/// The new manager will be able to call 'setInterfaceImplementer' for '_addr'.
/// @param _addr Address for which to set the new manager.
/// @param _newManager Address of the new manager for 'addr'. (Pass '0x0' to reset the manager to '_addr'.)
function setManager(address _addr, address _newManager) external {
require(getManager(_addr) == msg.sender, "Not the manager");
managers[_addr] = _newManager == _addr ? address(0) : _newManager;
emit ManagerChanged(_addr, _newManager);
}
/// @notice Get the manager of an address.
/// @param _addr Address for which to return the manager.
/// @return Address of the manager for a given address.
function getManager(address _addr) public view returns(address) {
// By default the manager of an address is the same address
if (managers[_addr] == address(0)) {
return _addr;
} else {
return managers[_addr];
}
}
/// @notice Compute the keccak256 hash of an interface given its name.
/// @param _interfaceName Name of the interface.
/// @return The keccak256 hash of an interface name.
function interfaceHash(string calldata _interfaceName) external pure returns(bytes32) {
return keccak256(abi.encodePacked(_interfaceName));
}
/* --- ERC165 Related Functions --- */
/* --- Developed in collaboration with William Entriken. --- */
/// @notice Updates the cache with whether the contract implements an ERC165 interface or not.
/// @param _contract Address of the contract for which to update the cache.
/// @param _interfaceId ERC165 interface for which to update the cache.
function updateERC165Cache(address _contract, bytes4 _interfaceId) external {
interfaces[_contract][_interfaceId] = implementsERC165InterfaceNoCache(
_contract, _interfaceId) ? _contract : address(0);
erc165Cached[_contract][_interfaceId] = true;
}
/// @notice Checks whether a contract implements an ERC165 interface or not.
// If the result is not cached a direct lookup on the contract address is performed.
// If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
// 'updateERC165Cache' with the contract address.
/// @param _contract Address of the contract to check.
/// @param _interfaceId ERC165 interface to check.
/// @return True if '_contract' implements '_interfaceId', false otherwise.
function implementsERC165Interface(address _contract, bytes4 _interfaceId) public view returns (bool) {
if (!erc165Cached[_contract][_interfaceId]) {
return implementsERC165InterfaceNoCache(_contract, _interfaceId);
}
return interfaces[_contract][_interfaceId] == _contract;
}
/// @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
/// @param _contract Address of the contract to check.
/// @param _interfaceId ERC165 interface to check.
/// @return True if '_contract' implements '_interfaceId', false otherwise.
function implementsERC165InterfaceNoCache(address _contract, bytes4 _interfaceId) public view returns (bool) {
uint256 success;
uint256 result;
(success, result) = noThrowCall(_contract, ERC165ID);
if (success == 0 || result == 0) {
return false;
}
(success, result) = noThrowCall(_contract, INVALID_ID);
if (success == 0 || result != 0) {
return false;
}
(success, result) = noThrowCall(_contract, _interfaceId);
if (success == 1 && result == 1) {
return true;
}
return false;
}
/// @notice Checks whether the hash is a ERC165 interface (ending with 28 zeroes) or not.
/// @param _interfaceHash The hash to check.
/// @return True if '_interfaceHash' is an ERC165 interface (ending with 28 zeroes), false otherwise.
function isERC165Interface(bytes32 _interfaceHash) internal pure returns (bool) {
return _interfaceHash & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0;
}
/// @dev Make a call on a contract without throwing if the function does not exist.
function noThrowCall(address _contract, bytes4 _interfaceId)
internal view returns (uint256 success, uint256 result)
{
bytes4 erc165ID = ERC165ID;
assembly {
let x := mload(0x40) // Find empty storage location using "free memory pointer"
mstore(x, erc165ID) // Place signature at beginning of empty storage
mstore(add(x, 0x04), _interfaceId) // Place first argument directly next to signature
success := staticcall(
30000, // 30k gas
_contract, // To addr
x, // Inputs are stored at location x
0x24, // Inputs are 36 (4 + 32) bytes long
x, // Store output over input (saves space)
0x20 // Outputs are 32 bytes long
)
result := mload(x) // Load the result
}
}
}