【发布时间】:2021-12-11 02:58:58
【问题描述】:
我在这里得到了一份非常简单的 ERC-20 合约:
pragma solidity 0.8.1;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract SonnyCoin is ERC20 {
constructor(uint256 initialValue) public ERC20("SonnyCoin", "SCN") {
_mint(msg.sender, initialValue);
}
}
然后我的合约迁移代码如下:
const SonnyCoin = artifacts.require("SonnyCoin");
const web3 = require("web3");
const initialValue = web3.utils.toWei("1", "ether");
module.exports = function(deployer) {
deployer.deploy(SonnyCoin(initialValue))
//I've also tried deployer.deploy(SonnyCoin({value: initialValue}))
}
我只想添加参数以使其成为动态发行合同,但我不确定我缺少什么,我查看了有关迁移脚本及其参数的 truffle 文档here,看来我正在做documentation dictates 是什么,但我显然错过了一个关键部分。对于向构造函数添加参数的任何帮助表示赞赏。
【问题讨论】: