You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with transactions in a blockchain context, there is often a need to wait for a transaction to be confirmed by the network before proceeding with further actions. Currently, stacks lacks a straightforward way to wait for a transaction to be mined and achieve a specified number of confirmations.
Solution
I propose adding a waitForTransaction(txHash, confirmations) function to the codebase. This function would operate similarly to ethers.js' waitForTransaction method, allowing us to wait for a transaction identified by txHash to be confirmed by the network a specified number of times (confirmations). The function should:
Accept a txHash (transaction hash) as input.
Optionally accept a confirmations parameter, defaulting to 1 if not provided.
Poll the blockchain at regular intervals to check the transaction status.
Resolve once the transaction has been confirmed the specified number of times.
Reject if the transaction fails or is not confirmed within a reasonable timeframe.
This utility would simplify the handling of transaction confirmations and reduce the likelihood of errors in the transaction flow.
Additional context
For reference, ethers.js provides a similar utility method: provider.waitForTransaction(txHash, confirmations). Implementing a similar function would streamline the development process, especially in scenarios where multiple confirmations are required before proceeding with further logic.
The text was updated successfully, but these errors were encountered:
0x2me
added
the
feature
Brand new functionality. New pages, workflows, endpoints, etc.
label
Aug 22, 2024
Problem
When working with transactions in a blockchain context, there is often a need to wait for a transaction to be confirmed by the network before proceeding with further actions. Currently, stacks lacks a straightforward way to wait for a transaction to be mined and achieve a specified number of confirmations.
Solution
I propose adding a
waitForTransaction(txHash, confirmations)
function to the codebase. This function would operate similarly to ethers.js'waitForTransaction
method, allowing us to wait for a transaction identified bytxHash
to be confirmed by the network a specified number of times (confirmations
). The function should:txHash
(transaction hash) as input.confirmations
parameter, defaulting to 1 if not provided.This utility would simplify the handling of transaction confirmations and reduce the likelihood of errors in the transaction flow.
Additional context
For reference, ethers.js provides a similar utility method:
provider.waitForTransaction(txHash, confirmations)
. Implementing a similar function would streamline the development process, especially in scenarios where multiple confirmations are required before proceeding with further logic.The text was updated successfully, but these errors were encountered: