我有一个问题,考虑继承/扩展ERC-20令牌智能合同。
我想在上部署之前向ERC-20令牌添加额外的可变变量。
与接口定义的变量一起使用:
name (string),
symbol (string),
decimals (uint8),
totalSupply(uint8)我想添加额外的可变变量,这些值可以在通过事务部署后进行更改。它们看起来会是这样:
issuedSupply(uint8),
dedicatedManager(string)我还没有在官方规范参考资料中找到答案:
有两个类似的问题:
因此,为了使我的问题完整:
非常感谢你看我的问题,
亲切的问候
发布于 2021-06-24 16:14:43
可以使用继承模式扩展智能契约,如果需要,还可以在块存储中添加其他字段。还可以使用事务更新这些字段。一个样本看起来像
contract ERC20FixedSupply is ERC20 {
string public test;
constructor() public {
_mint(msg.sender, 1000);
}
function setTest(string memory _test) public {
require( msg.sender == owner, "Should be owner" );
test = _test;
}
}在上面的示例中,可以使用setTest函数来设置自定义变量test,而ERC20FixedSupply是ERC-20智能契约。
https://ethereum.stackexchange.com/questions/102404
复制相似问题