0

I have declared the following interface:

interface Test {
    function airDropMultiple(
        address[] calldata recipients,
        uint[] calldata tokenAmount
    )
        external
        returns (bool);
}

I am attempting to call it like this:

Test(ContractAddress).airDropMultiple(
    [testWalletAddress[4], testWalletAddress[3]],
    [10**18, 10**19]
);

I am receiving the following compiler error:

Invalid implicit conversion from address[2] memory to address[] memory requested.

How I can call this interface from this contract to target contract?

1 Answer 1

0

The general error:

Invalid implicit conversion from type[N] memory to type[] memory requested.

Occurs when trying to send a static array to a function which expects a dynamic array.

In order to fix it in your specific case, you should do something like:

address[] memory recipients = new address[](2);
uint[] memory tokenAmounts = new uint[](2);
(recipients[0], recipients[1]) = (testWalletAddress[4], testWalletAddress[3]);
(tokenAmounts[0], tokenAmounts[1]) = (10**18, 10**19);
Test(ContractAddress).airDropMultiple(recipients, tokenAmounts);

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.