tokenTx method

Future<EtherScanMintedTokenTxModel> tokenTx({
  1. required String? address,
  2. String? contractAddress,
  3. Object startblock = 0,
  4. String endblock = 'latest',
  5. int page = 1,
  6. int offset = 100,
  7. EtherSort sort = EtherSort.asc,
})

Get a list of "ERC20 - Token Transfer Events" by Address

address - Account address

startblock - start looking here

endblock - end looking there

page - Page number

offset - Max records to return

sort - Sort asc/desc

contractAddress - Address of ERC20 token contract (if not specified lists transfers for all tokens)

Example

var txlist = eth.tokenTx(
  address: '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae',
  contractAddress: '0x5F988D968cb76c34C87e6924Cc1Ef1dCd4dE75da'
);

(Returns up to a maximum of the last 10000 transactions only)

Implementation

Future<EtherScanMintedTokenTxModel> tokenTx({
  required String? address,
  String? contractAddress,
  Object startblock = 0,
  String endblock = 'latest',
  int page = 1,
  int offset = 100,
  EtherSort sort = EtherSort.asc,
}) async {
  const module = 'account';
  const action = 'tokentx';

  var query = {
    'module': module,
    'action': action,
    'startblock': startblock,
    'endblock': endblock,
    'page': 'page',
    'offset': offset,
    'sort': sort.str,
    'address': address,
    'apiKey': apiKey
  };

  if (contractAddress != null) {
    query.putIfAbsent('contractaddress', () => contractAddress);
  }

  return (await get(query)).fold(
    (l) => EtherScanMintedTokenTxModel.empty(),
    (r) => EtherScanMintedTokenTxModel.fromJson(r),
  );
}