在构造函数中使用数组部署智能合约
Deploying smart contract with arrays in the constructor
我对 solidity 很陌生,在检查更复杂的合约时,我发现了这种类型的构造函数,我想知道在部署它时应该如何编写字符串。
constructor(
address[] memory payees,
uint256[] memory shares,
address[] memory addresses,
uint256 swapAmount
) ERC20("Token", "TOKEN") PaymentSplitter(payees, shares) {
require(addresses.length == 5, "Count of Addresses must be 5");
treasuryPool = addresses[0];
distributionPool = addresses[1];
marketingPool = addresses[2];
expensePool = addresses[3];
cashoutPool = addresses[4];
for (uint256 i = 0; i < 5; i++)
_isExcludedFromFee[addresses[i]] = true;
require(expensePool != address(0) && distributionPool != address(0), "FUTUR & REWARD ADDRESS CANNOT BE ZERO");
我尝试了不同的方法,但都失败了。
Remix IDE 中 Deploy 按钮旁边的输入字段是我们放置数据的地方。
以下将是调用您的 constructor/deploy 合同的有效输入。
["0x0000000000000000000000000000000000000001"],[0,1,2],["0x0000000000000000000000000000000000000002"],3
我对 solidity 很陌生,在检查更复杂的合约时,我发现了这种类型的构造函数,我想知道在部署它时应该如何编写字符串。
constructor(
address[] memory payees,
uint256[] memory shares,
address[] memory addresses,
uint256 swapAmount
) ERC20("Token", "TOKEN") PaymentSplitter(payees, shares) {
require(addresses.length == 5, "Count of Addresses must be 5");
treasuryPool = addresses[0];
distributionPool = addresses[1];
marketingPool = addresses[2];
expensePool = addresses[3];
cashoutPool = addresses[4];
for (uint256 i = 0; i < 5; i++)
_isExcludedFromFee[addresses[i]] = true;
require(expensePool != address(0) && distributionPool != address(0), "FUTUR & REWARD ADDRESS CANNOT BE ZERO");
我尝试了不同的方法,但都失败了。
Remix IDE 中 Deploy 按钮旁边的输入字段是我们放置数据的地方。 以下将是调用您的 constructor/deploy 合同的有效输入。
["0x0000000000000000000000000000000000000001"],[0,1,2],["0x0000000000000000000000000000000000000002"],3