getTransactionsForAddress method

  1. @override
Future<TransactionsResponse> getTransactionsForAddress(
  1. EthereumAddress address,
  2. {EthereumAddress? tokenAddress,
  3. BlockNum? fromBlock,
  4. BlockNum? toBlock,
  5. DateTime? fromTime,
  6. DateTime? toTime,
  7. int page = 1,
  8. int pageSize = 20}
)
override

Retrieves transactions for a specific address.

Given the address, this method returns a TransactionsResponse containing information about transactions related to the address. Additional parameters like fromBlock, toBlock, fromTime, toTime, page, and pageSize can be specified for more targeted results.

Implementation

@override
Future<TransactionsResponse> getTransactionsForAddress(
  EthereumAddress address, {
  EthereumAddress? tokenAddress,
  BlockNum? fromBlock,
  BlockNum? toBlock,
  DateTime? fromTime,
  DateTime? toTime,
  int page = 1,
  int pageSize = 20,
}) async {
  return TransactionsResponse.fromJson(await _restClient
      .get<Map<String, dynamic>>('/account/txs', queryParameters: {
    'address': address.hex,
    'chain_id': _chain.chainId,
    if (tokenAddress != null) 'contract_address': tokenAddress.hex,
    if (fromBlock != null) 'from_block': fromBlock.toBlockParam(),
    if (toBlock != null) 'to_block': toBlock.toBlockParam(),
    if (fromTime != null) 'from_timestamp': fromTime.millisecondsSinceEpoch,
    if (toTime != null) 'end_timestamp': toTime.millisecondsSinceEpoch,
    'page': page,
    'limit': pageSize,
  }));
}