Search code examples
flutterdartethereumetherscan

The entire Ethercan API call being printed in Flutter


I am trying to just get the "result" part of the API call response, but the entire call is being printed anyway.

final balance = await etherscan.tokenBalance(address: myAddress, contractAddress: getAddresses());

print(balance.result); 

This is the response:

I/flutter ( 6425): api_url: https://api-rinkeby.etherscan.io
I/flutter ( 6425): query: {
I/flutter ( 6425):   "module": "account",
I/flutter ( 6425):   "action": "tokenbalance",
I/flutter ( 6425):   "apiKey": "*******",
I/flutter ( 6425):   "tag": "latest",
I/flutter ( 6425):   "contractaddress": "0x01BE23585060835E02B77ef475b0Cc51aA1e0709",
I/flutter ( 6425):   "address": "********"
I/flutter ( 6425): }
I/flutter ( 6425): response: {
I/flutter ( 6425):   "status": "1",
I/flutter ( 6425):   "message": "OK",
I/flutter ( 6425):   "result": "70000000000000000000"
I/flutter ( 6425): }
I/flutter ( 6425): 70000000000000000000

Thanks a lot in advance!


Solution

  • The print looks like to be the last line of the log (where you just see the number) the other one looks like an internal log from the package, for any change did you used this package?

    https://pub.dev/packages/etherscan_api

    if yes did you initialized like you can see in the readme?

    final eth = EtherscanAPI(
        apiKey: 'YourApiKey', // Api key
        chain: EthChain.ropsten, // Network/chain
        enableLogs: true // Enable Logging
      );
    

    Maybe the enableLogs: true property is what is causing the logs to show, if this is the case please try to change it to false!