I am trying to execute read function from a contract which requires 2 argument:
unit256
address[] (2 addresses are required here)
However, no matter how I try to input the second argument, I am always getting - "Error: invalid value for array"
I have also found similar unresolved question on StackOverflow, where the same error is caused there because an array of unit is required as input.
Additional info:
my code:
final contractAddress = '0x60aE616a2155Ee3d9A68541Ba4544862310933d4';
const jason_abi = '{
"type":"function"
"name":"getAmountsOut",
"stateMutability":"view",
"inputs":[
{"internalType":"uint256","name":"amountIn","type":"uint256"},
{"internalType":"address[]","name":"path","type":"address[]"}
],
"outputs":[
{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}
],
}';
const human_abi = ["function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts)"];
final wavax = EthUtils.getAddress("0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7");
final mim = EthUtils.getAddress("0x130966628846bfd36ff31a822705796e8cb8c18d");
final contract = Contract(contractAddress, human_abi, provider!);
await contract.call('getAmountsOut', [1, [wavax, mim]]).then((value) {
print("unclaimed rewards - ${value.toString()}");
}); // <--- Gives me the error, maybe because this inner list is interpreted as tuple?
Ways I have tried to input before opening the issue are:
using EthUtils.arrayify
using jsify
using JsArray.from()
directly pasting the contracts without checksum from EthUtils
using EthUtils to parse the 1
In my specific case the function is from TraderJoeRouter on Avalanche Chain.
Contract of the router - "0x60aE616a2155Ee3d9A68541Ba4544862310933d4", function name - "getAmountsOut"
The bug:
I am trying to execute read function from a contract which requires 2 argument:
However, no matter how I try to input the second argument, I am always getting - "Error: invalid value for array"
I have also found similar unresolved question on StackOverflow, where the same error is caused there because an array of unit is required as input.
Additional info:
my code:
Ways I have tried to input before opening the issue are:
In my specific case the function is from TraderJoeRouter on Avalanche Chain. Contract of the router - "0x60aE616a2155Ee3d9A68541Ba4544862310933d4", function name - "getAmountsOut"