getTransaction - SDK
Returns the transaction 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 an…
Returns the transaction 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.
Don’t have an API key?
Start using this method in your app today. Get started for free
Description
Returns the transaction 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.
Parameters
Response
TransactionResponse
object parameters
Example Request and Response
Prerequisite: You will need to install the Alchemy SDK before making requests with it.
The commands for installing it using npm or yarn are given below:
Request
Response
Use Cases
Here are some potential use cases for the getTransaction
method:
-
Transaction status: You can use
getTransaction
to check the status of a transaction by its hash. If the transaction has been mined and confirmed, you will be able to see the block number and other details. If the transaction has not yet been mined, you can usegetTransactionReceipt
to get the current status. -
Transaction details: You can use
getTransaction
to retrieve the details of a transaction, including the sender and recipient addresses, the amount transferred, and the gas used. This information can be useful for auditing purposes or to reconcile your own records. -
Debugging: If you are experiencing issues with a transaction, you can use
getTransaction
to retrieve the details and identify the source of the problem. For example, if a transaction is failing due to insufficient gas, you can usegetTransaction
to confirm the gas limit and adjust it as needed.
Related Methods
Here are the methods related to getTransaction
:
- sendTransaction - Submits transaction to the network to be mined.
- waitForTransaction - Returns a promise which will not resolve until specified transaction hash is mined.