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

Incorrect nonce set while building transaction with makeUnsignedContractCall #1489

Closed
bilalanees98 opened this issue May 2, 2023 · 2 comments · Fixed by #1704
Closed

Incorrect nonce set while building transaction with makeUnsignedContractCall #1489

bilalanees98 opened this issue May 2, 2023 · 2 comments · Fixed by #1704
Assignees
Labels
enhancement Iterations/refactor on existing features/infrastructure/tests
Milestone

Comments

@bilalanees98
Copy link

What version of Stacks.js are you using?

v6.5.0

Describe the bug

Nonce set by stacks.js is wrong, resulting in a BadNonce error on broadcast.

How to reproduce

Assuming we have a fresh account with funds and nonce = 0.
1- Build a contract call transaction for any contract without setting the nonce in txOptions
2- broadcast the transaction.
3- Wait 3-5 mins
4- Build another contract call transaction with same account again without setting the nonce in txOptions.
5- broadcast 2nd tx.
6- BadNonce/ConflictingNonceInMempool error gets thrown.

Expected behavior

Possible next nonce should be used and the broadcast should complete without an error.

Investigation

Instead I think the possible next nonce value should be fetched from this endpoint: https://api.testnet.hiro.so/extended/v1/address/ST3QJKVMNZJ897FBDJT7YRQR0AJAS77C6N04SVV51/nonces.
As this endpoint takes into consideration both on-chain data and txs in mempool.

Furthermore, this change needs to be reflected across all builder fns including sponsorTransaction fn

@bilalanees98 bilalanees98 added the bug Unwanted or unintended logic causing harm label May 2, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools May 2, 2023
@janniks
Copy link
Collaborator

janniks commented May 3, 2023

Great issue write-up -- thanks! 🙏
Yes, I agree. We'll prioritize this 👍

@janniks janniks self-assigned this May 3, 2023
@smcclellan smcclellan added enhancement Iterations/refactor on existing features/infrastructure/tests and removed bug Unwanted or unintended logic causing harm labels May 3, 2023
@smcclellan smcclellan moved this from 🆕 New to 🔖 To do in DevTools May 3, 2023
@smcclellan smcclellan added this to the Q3-2023 milestone Jul 25, 2023
@janniks
Copy link
Collaborator

janniks commented Sep 18, 2023

Since this would be sort of a breaking change (since the new endpoint requires an API, not just a Stacks node) I'll add this to an upcoming refactor of Stacks.js (Network and API clients)

@smcclellan smcclellan modified the milestones: Q3-2023, Q1-2024 Jan 16, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in DevTools Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Iterations/refactor on existing features/infrastructure/tests
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants