Skip to content

Instantly share code, notes, and snippets.

@dmihal
Created March 5, 2021 12:53
Show Gist options
  • Save dmihal/7020e248c3574123ce2cb4f2137fbaaa to your computer and use it in GitHub Desktop.
Save dmihal/7020e248c3574123ce2cb4f2137fbaaa to your computer and use it in GitHub Desktop.
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC777/IERC777.sol";
import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import "@openzeppelin/contracts/introspection/IERC1820Registry.sol";
abstract contract ERC777Receiver is IERC777Recipient {
IERC1820Registry constant internal ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
constructor() {
ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777TokensRecipient"), address(this));
}
function _tokensReceived(IERC777 token, address from, uint256 amount, bytes memory data) internal virtual;
function tokensReceived(
address /*operator*/,
address from,
address /*to*/,
uint256 amount,
bytes calldata userData,
bytes calldata /*operatorData*/
) external override {
_tokensReceived(IERC777(msg.sender), from, amount, userData);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment