1

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?

1
  • You are supposed to be passing arrays of addresses as arguments, not addresses. Try: await TimeLock.deploy([proposer.address], [executor.address]) as arrays with only one item.
    – razgraf
    Jan 24, 2022 at 14:18

1 Answer 1

1

Your contract constructor expects two arrays as parameters. Your code is sending two addresses and not the arrays.

It would be something like this

timelock = await TimeLock.deploy([proposer.address], [executor.address]);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.