Mint函数的传递事件与ERC20智能合约的传递函数有什么区别?



Mint函数的传递事件与ERC20智能合约的传递函数有什么区别?

我知道在Mint的转移事件中,从地址是address(0),而在转移中有发件人的地址但不为零。我期待一个不同的方法。

Transfer事件接受3个参数:令牌发送方、接收方和金额。

创建新令牌的令牌合约应该在创建令牌时触发将_from地址设置为0x0的Transfer事件

来源:https://eips.ethereum.org/EIPS/eip-20

这是在生成令牌时发出事件的标准化方法。

你还可以在上面发出自定义事件。例如:

event Transfer(address indexed from, address indexed to, uint256 amount);
event Mint(uint256 amount, uint256 timestamp);
function mint(uint256 amount) external onlyOwner {
balanceOf[msg.sender] += amount;
totalSupply += amount;
emit Transfer(address(0x0), msg.sender, amount);
emit Mint(amount, block.timestamp);
}

最新更新