I've written a contract…
contract TimeLock is TimelockController {
uint256 minDelay = block.timestamp + 4 minutes;
constructor(
address[] memory proposers,
address[] memory executors
) TimelockController( minDelay, proposers, executors ) {}
//rest of contract's code
}
Now, I want to test it with mocha and javascript, so I wrote a test…
beforeEach(async function(){
//const date = new Date();
TimeLock = await ethers.getContractFactory('TimeLock');
[proposer, executor, sendTo, admin, ...addrs] = await ethers.getSigners();
timelock = await TimeLock.deploy(proposer.address, executor.address);
await timelock.deployed();
});
The problem, I can't figure out how to pass the array of addresses via javascript while testing my contract, with my past knowledge I'm doing it like this…
timelock = await TimeLock.deploy(proposer.address, executor.address);
and this is how my contract take addresses via constructor…
constructor(
address[] memory proposers,
address[] memory executors
) TimelockController( minDelay, proposers, executors ) {}
By giving the addresses like the above I'm getting this error…
1) "before each" hook for "deploys the contract":
Error: invalid value for array (argument="value", value="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", code=INVALID_ARGUMENT, version=contracts/5.5.0)
Can anyone please help me how to send addresses via array, Am I doing it wrong?
Best Answer
Your contract constructor expects two arrays as parameters. Your code is sending two addresses and not the arrays.
It would be something like this