[英]Add custom field when mint new ERC721 token
将消息存储在区块链上的最简单方法是发出事件。 事件被永久存储并且公开可读。
mint()
function 之外定义新的MintMessage
事件。 我不建议扩展在铸造期间使用的默认Transfer
事件,因为外部工具(例如 Etherscan)可能会忽略非标准事件并且因此不会显示铸造的代币。mint()
function 添加一个新参数mint()
function 中发出MintMessage
事件event MintMessage(string message);
function mint(address to, string message) public virtual {
// keep the rest of your function as is
// add a new line emiting the event to the end of the function
emit MintMessage(message);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.