ERC1820协议的问题

pragma solidity >=0.8.4;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.1/contracts/token/ERC777/ERC777.sol";

contract ERC777 is IERC777Recipient {
//calling the setInterfaceImplementer function on the ERC-1820 registry with the holder address as the address
  IERC1820Registry private registry1820= IERC1820Registry (0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
  registry1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensSender"), address(this));
  mapping (address=>uint) public balances;

//ERC777 Sender Hook
function tokensToSend(address operator, address from,address to,uint256 amount,bytes calldata userData,
    bytes calldata operatorData) external{
}

function () external payable {}

最近看777token有关于ERC1820协议的问题。 我的问题是在注册ERC1820的时候,为什么要注册ERC777TokensSender这个,我看到有的777token注册amcERC777TokensSender或者是其他的aaaERC777TokensSender。 每一个777token都要去注册一个,为什么可以有不同的注册名。 iShot_2022-08-07_16.25.06.png

我知道这个是hook来的。 假如有一个777token代币,他的接受hook是ERC777TokensReceived,发送ERC777TokensSender的话。我要做个基于777token代币合约,那么我的合约也注册ERC777TokensReceived和ERC777TokensSender的hook才可以接受发送代币对吧。

还有一个问题,假如有一个777token的合约,我怎么去确认777token的合约这两个hook呢

请先 登录 后评论

1 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论