Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a waitForTransactionFunction #1738

Open
0x2me opened this issue Aug 22, 2024 · 0 comments
Open

Add a waitForTransactionFunction #1738

0x2me opened this issue Aug 22, 2024 · 0 comments
Labels
feature Brand new functionality. New pages, workflows, endpoints, etc.

Comments

@0x2me
Copy link

0x2me commented 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 by txHash to be confirmed by the network a specified number of times (confirmations). The function should:

  1. Accept a txHash (transaction hash) as input.
  2. Optionally accept a confirmations parameter, defaulting to 1 if not provided.
  3. Poll the blockchain at regular intervals to check the transaction status.
  4. Resolve once the transaction has been confirmed the specified number of times.
  5. 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.

@0x2me 0x2me added the feature Brand new functionality. New pages, workflows, endpoints, etc. label Aug 22, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Aug 22, 2024
@0x2me 0x2me changed the title Add a waitForTransactionFUnction Add a waitForTransactionFunction Aug 22, 2024
@andresgalante andresgalante moved this from 🆕 New to 📋 Backlog in DevTools Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Brand new functionality. New pages, workflows, endpoints, etc.
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant