getTransaction method

Future<TransactionResponse?> getTransaction(
  1. String hash
)

Returns the TransactionResponse with hash or null if the transaction is unknown.

If a transaction has not been mined, this method will search the transaction pool.

Various backends may have more restrictive transaction pool access (e.g. if the gas price is too low or the transaction was only recently sent and not yet indexed) in which case this method may also return null.


final transaction = await provider!.getTransaction(
    '0x4e04def628cfd0c7786febaef8fbe832fc30eae54a4fba25bf46022c439ab39d');

print(transaction); // Transaction: 0x4e04def6 from 0x1dFCD06a with value 0 and data 0x876cb21700000...
print(transaction != null); // true
print(transaction is TransactionResponse); // true

Implementation

Future<TransactionResponse?> getTransaction(String hash) async {
  final response =
      await call<_TransactionResponseImpl?>('getTransaction', [hash]);
  if (response != null) return TransactionResponse._(response);
}