0

So I'm trying to call Comptroller's function enterMarkets(address[] calldata cTokens) returns (uint[] memory). The problem that I have is if I call the function with my array of markets, it gives me the error, TypeError: Type address[1] memory is not implicitly convertible to expected type address[] memory.

I understand that the function expects an address array of an undefined length, but every method I can think of to pass an array to the function gives me the same error. For example, the following methods return the same error:

address[] memory markets = [address(cdaitoken)];
comptroller.enterMarkets(markets);
comptroller.enterMarkets([address(cdaitoken)]);
3

Solution if anyone's curious:

address[] memory markets = new address[](1)
markets[0] = address(cdaitoken)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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