Skip to content

fix(demo): read nonce and estimate fees at pre-confirmed block - #907

Open
avi-starkware wants to merge 1 commit into
mainfrom
avi/demo-preconfirmed-nonce
Open

fix(demo): read nonce and estimate fees at pre-confirmed block#907
avi-starkware wants to merge 1 commit into
mainfrom
avi/demo-preconfirmed-nonce

Conversation

@avi-starkware

@avi-starkware avi-starkware commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

The deposit flow submits dependent account transactions (approve, then the proof invocation) and only waits for PRE_CONFIRMED between them, but the RPC provider used the default latest block tag for nonce reads and fee estimation. A pre-confirmed transaction is not yet in latest, so the follow-up transaction was built with a stale nonce and sporadically failed estimateFee:

Invalid transaction nonce of contract at address 0x…
Account nonce: 0x40; got: 0x3f

Account.getNonce() and fee estimation both fall back to the provider's default block tag (BlockTag.LATEST in starknet.js v10), which lags a merely pre-confirmed tx — so the next tx reads a nonce that becomes stale the instant the earlier tx is accepted. Intermittent because it depends on when the approve crosses pre-confirmed→accepted relative to the deposit's nonce fetch and estimate.

Fix

Pin the provider's default block tag to PRE_CONFIRMED in createProvider (demo/src/starknet.ts) so nonce reads and fee estimates use the same state the flow already waits for (WAIT_OPTIONSPRE_CONFIRMED).

Verification

  • tsc --noEmit, eslint, and prettier clean on the changed file.
  • Demo redeployed from this branch: loads and connects (Discovery / RPC / Proving healthy).

🤖 Generated with Claude Code


This change is Reviewable

The deposit flow submits dependent account transactions (approve, then the proof invocation) and only waits for PRE_CONFIRMED between them, but the RPC provider used the default `latest` block tag for nonce reads and fee estimation. A pre-confirmed transaction is not yet in `latest`, so the follow-up transaction was built with a stale nonce and sporadically failed estimateFee with "Invalid transaction nonce ... Account nonce: N; got: N-1".

Pin the provider's default block tag to PRE_CONFIRMED so nonce reads and fee estimates match the state the flow already waits for.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

Copy link
Copy Markdown

Deploy preview for starknet-privacy-demo ready!

✅ Preview
https://starknet-privacy-demo-h96m3o6jw-keep-starknet-strange.vercel.app

Built with commit 9ba15e4.
This pull request is being automatically deployed with vercel-action

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@Yoni-Starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on avi-starkware).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants