objective: try to get price from pancakeswap i created the abi and feed it with two contract addresss that i want the price from but i get this error| Unhandled Exception: type '_BigIntImpl' is not a subtype of type 'List' of 'data'

I think in the parameters i feed in the wrong TYPE when i call contract PS: i also try EthereumAddress as TYPE but does not work Your help is most appreciated

here is my code:

final pancakeSwapContract = '0x10ED43C718714eb63d5aA57B78B54704E256024E';
late Client httpClient;
late Web3Client ethereumClient;
late String _abiCode;
late Credentials _credentials;
String pancakeSwapConAddress = "0x10ED43C718714eb63d5aA57B78B54704E256024E";

String ethereumClientUrl = 'https://bsc-dataseed1.binance.org';
final bnbTokenAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
final tokenAddres = '0xC75aa1Fa199EaC5adaBC832eA4522Cff6dFd521A';
void initState() {
   httpClient = Client();
   ethereumClient = Web3Client(ethereumClientUrl, httpClient);
Future<DeployedContract> getContract() async {
 String abi = await rootBundle.loadString("assets/abi/pancakeSwapAbi.json");
 String pancakeSwapConAddress ="0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase();
 DeployedContract contract = DeployedContract(
 ContractAbi.fromJson(abi, 'pancakeSwapAbi'),
return contract;
Future<void> calcBNBPrice() async {
 const bNBTokenAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"; //BNB
 const uSDTokenAddress = "0x55d398326f99059fF775485246999027B3197955"; //USDT
 // final EthereumAddress add1 = EthereumAddress.fromHex(bNBTokenAddress);
 // final EthereumAddress add2 = EthereumAddress.fromHex(uSDTokenAddress);
 DeployedContract contract = await getContract();
 getThePriceContract = contract.function("getAmountsOut");
 List<dynamic> gettingThePrice = await ethereumClient.call(
 contract: contract,
 function: getThePriceContract,
 params: [
final List<dynamic> convertResponse = gettingThePrice.first as List<dynamic>;


      "inputs": [
        {"internalType": "uint256", "name": "amountIn", "type": "uint256"},
        {"internalType": "address[]", "name": "path", "type": "address[]"}
      "name": "getAmountsOut",
      "outputs": [
        {"internalType": "uint256[]", "name": "amounts", "type": "uint256[]"}
      "stateMutability": "view",
      "type": "function"

1 Answer 1


In ABI-file we have two types: uint256 - is BigInt in Flutter; address[] - array of EthereumAddresses.

   "inputs": [
                "internalType": "uint256",
                "name": "amountIn",
                "type": "uint256" <--
                "internalType": "address[]",
                "name": "path",
                "type": "address[]" <--

So, in arguments we need to write something like this:

params: <dynamic>[
    [EthereumAddress.fromHex(tokens[0].address), EthereumAddress.fromHex(tokens[1].address)],

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.