waitForTransaction - SDK
Returns a promise which will not resolve until specified transaction hash is mined. If confirmations is 0, this method is non-blocking, and if the transaction has not been mined returns null . Otherwise, this method will block until the transaction has confirmed blocks mined on top of the block in w…
Returns a promise which will not resolve until specified transaction hash is mined.
If confirmations
is 0, this method is non-blocking, and if the transaction has not been mined returns null
. Otherwise, this method will block until the transaction has confirmed blocks mined on top of the block in which it was mined.
Don’t have an API key?
Start using this method in your app today. Get started for free
Description
Returns a promise which will not resolve until the specified transaction hash is mined.
If confirmations
is 0, this method is non-blocking, and if the transaction has not been mined returns null
. Otherwise, this method will block until the transaction has confirmed blocks mined on top of the block in which it was mined.
Parameters
Response
TransactionReceipt
response 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 waitForTransaction
method:
-
Ensuring transaction execution: When sending a transaction to the Ethereum network, there is no guarantee that the transaction will be executed immediately.
waitForTransaction
can be used to ensure that the transaction is mined and executed before moving on to the next step in the program. -
Waiting for contract deployment: When deploying a new smart contract to the Ethereum network, it may take some time for the contract to be deployed and ready for use.
waitForTransaction
can be used to wait for the contract deployment transaction to be confirmed before interacting with the contract. -
Checking transaction status:
waitForTransaction
can be used to check the status of a transaction and ensure that it was successfully mined and confirmed by the network. This is useful for ensuring that funds were successfully transferred, or for verifying that a contract function was executed as expected.