getWeb3TokensByChainByAddress method

Future<Balances?> getWeb3TokensByChainByAddress(
  1. String chain,
  2. String address
)

Reads an address's native balance on a chain.

Reads an address's native balance on a chain. ERC-20 positions are NOT enumerated here: eth_getBalance answers the native one, but "every token this address holds" is an indexer question — there is no RPC call that answers it, and walking a token list would return a number that silently omits whatever the list missed. explorer owns the indexer relationship; this returns the balance the chain itself can prove.

Parameters:

  • String chain (required): Chain is the registry id.

  • String address (required): Address is the account, 0x-prefixed.

Implementation

Future<Balances?> getWeb3TokensByChainByAddress(String chain, String address,) async {
  final response = await getWeb3TokensByChainByAddressWithHttpInfo(chain, address,);
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Balances',) as Balances;

  }
  return null;
}