This is so frustrating and I don't know why these errors don't give more information.

I compiled and deployed a contract in remix using the left panel and everything is working fine. I then proceeded to make a test file for my contract in the /tests folder in Remix.

Here is my test file:

pragma solidity ^0.8.0;

import "../contracts/Buds.sol";

contract BudsTester {
    Buds codeTested;
    function beforeEach() public {
        codeTested = new Buds(0x988401257b1D1630681e0C51176db25b0d3a69e5, 0x0CF74C6B34560FF9116CA9E19fc06A6FB5Cf65c0, [0xB4a925BAe55743AcF3Dc65a8de0b9507F0491617, 0x288071244112050c93389A950d02c9E626D611dD]);
    function constructorParamatersShouldWork() public {
        //implement logic to test constructor fires correctly

As you can see I call the constructor of the contract I'm testing in beforeEach(). The problem is my contract's constructor() is set up with the following parameters:

constructor(address goodBudWalletAddress, address smokeOutWalletAddress, address[] memory teamMembers) {
//logic in here

The error I get in the beforeEach() function with auto compile is this:

TypeError: Invalid type for argument in function call. Invalid implicit conversion from address[2] memory to address[] memory requested. --> tests/Buds_test.sol:9:119: 
9| ... B34560FF9116CA9E19fc06A6FB5Cf65c0, [0xB4a925BAe55743AcF3Dc65a8de0b9507F0491617, 0x288071244112050c93389A950d02c9E626D611dD]);

Thank you for any help you provide, I greatly appreciate it!

  • the error is saying that you are trying to convert an address (a 20 byte field) to an array of addresses. By the way addresses are casted with address() keyword
    – Nulik
    Jul 17, 2021 at 2:15
  • Please consider changing the header of the post, so it will represent the mistake correctly Jul 17, 2021 at 8:59
  • @nulik So what would be the correct method because my smart contract's constructor has an address array as the 3rd parameter. I tried looking up solidity address casting, the only thing I could find is turning address to address payable. I couldn't even find any function in solidity called address()... Thanks for the help Jul 18, 2021 at 17:47
  • @SeeingProrok I don't know what you mean. What should I change the header to? The header is the exact error I got. Jul 18, 2021 at 17:48

1 Answer 1


It is not possible to cast between fixed size arrays and dynamic size arrays.

You have to create a temporary dynamic array and copy the elements.

address[] memory t = new address[](2);

t[0] = 0xB4a925BAe55743AcF3Dc65a8de0b9507F0491617;
t[1] = 0x288071244112050c93389A950d02c9E626D611dD;

codeTested = new Buds(param1, param2, t);

Your Answer

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

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