I am using web3dart with flutter for calling a smart contract view function from my android application. The call errs: Invalid argument: Instance of '_BigIntImpl'. The Solidity function requires String input like so:
function getIndividualCustomer(string memory _customer) public view returns (uint256 individualSellCount,
uint256 individualSellAmount,
uint256 individualBuyCount,
uint256 individualBuyAmount,
uint256 individualTransactionsPostEntry,
uint256 individualAccruedDividend,
address individualPayAddress) {
return (customers[_customer].individualSellCount,
customers[_customer].individualSellAmount,
customers[_customer].individualBuyCount,
customers[_customer].individualBuyAmount,
customers[_customer].individualTransactionsPostEntry,
customers[_customer].individualAccruedDividend,
customers[_customer].individualPayAddress);
}
The function was tested fine from Remix. Now I am integrating it with my flutter application like so:
QuerySnapshot addressesSnapshot = await fetchDocuments();
final contract = await fetchContract();
for (var doc in addressesSnapshot.docs) {
final id = (doc.data() as Map<String, dynamic>)['id'];
final function = contract.function('getIndividualCustomer');
List<dynamic> paramList = [];
paramList.add(id);
try {
final result = await client.call(
contract: contract,
function: function,
params: [id],
);
// Update the document with the returned data
await doc.reference.update({
'userSellCount': result[0],
'userTotalSellAmount': result[1],
'userBuyCount': result[2],
'userTotalBuyAmount': result[3],
'userTotalTransactionsPostEntry': result[4],
'userTotalAccruedDividend': result[5],
'userAccount': result[6],
});
debugPrint(
'getIndividualCustomer call was successful for id: $id');
} catch (e) {
debugPrint(
'getIndividualCustomer call failed for id: $id. Error: $e');
}
}
}
The function is expected to retrieve details of input string memory _customer
.
In my case the input argument "id" is a UID of the form say, 9UlY5QpsmONa5bw1ZAV3yAdTwNL2.
params
of web3dart call
is a List which take a list of input arguments. I have ensured that id
is a string by checking its runtimeType
and put it in a List. I have even tried with hardcoded literals. So my only argument is a string and nothing indicative of a BigInt.
However, every time I get the same error: Invalid argument: Instance of '_BigIntImpl'