How to resolve sequence number error on Testnet

Hi. I’m currently testing a modified version of KittyItems Demo Dapp on Testnet.
But after the upgrade of Cadence in Testnet a few days ago, all transactions are failing with errors.

Error message:

invalid proposal key: public key 1 on account 9d239100a57905c0 has sequence number 1, but given 0

How can I resolve this error?
Could this be because there is a pending transaction?

I am using js sdk (@onflow/fcl 0.0.67) and Blocto Wallet to simply send a single transaction, like bellow:

transaction {
  execute {

Some details of the failed transactions:

Hi avcd.

It’s hard to give you a concrete answer without knowing how you construct/send your transaction, but I can give you some guidance and maybe it helps.

The most likely scenario is that you are using the same sequence number for two different transactions. The sequence number on a key on an account changes every time a transaction is submitted (and doesn’t fail), where that key is the proposer for the transaction. Or in other words, if you are doing

tx.SetProposalKey(key.Address, key.Index, key.SequenceNumber)

then you (successfully) submit that transaction, you need to increment your sequence number ey.SequenceNumber += 1. Or alternatively you can also get the new sequence number for the account key by doing something like:

      const account = await this.getAccount(address);
      const key = account.keys[keyIndex];
      const sequenceNum = key.sequenceNumber

Since you are starting from KittyItems demo, this is the part of the code that usually fetches the current sequence number: kitty-items/flow.ts at 08ee4014a1f8b07fdd6aa2096d9a729898dcf119 · onflow/kitty-items · GitHub

Also here is a link to account key sequence numbers docs: Accounts, Keys & Signing - Flow Documentation

Let me know if that helped with debugging your problem.

1 Like

@TheOneSock Thank you for the detailed explanation. It helps me understand.

I’m trying to figure out how to reproduce the problem, but I also encountered this problem when I send the first transaction only once with a new account. So maybe this is a problem with Testnet (or Blocto).

I am sending a transaction with the following code, would you tell me how to set a custom sequence number here if you know?

import * as fcl from '@onflow/fcl'
import * as t from '@onflow/types'

await fcl.send([

Hm Interesting… as far as I know this should work, but in not experienced with the js-skd. I think we need to summon @qvvg.

1 Like

Cadence upgrade requires some changes be done to the kitty-items app that I haven’t gotten to yet. It’s high on my list of things to deal with.

Your code looks correct and you shouldn’t need to change anything. Will have a look into things on our end. In the mean time do you think you could make an issue here: Issues · onflow/flow-js-sdk · GitHub

1 Like

I understand the situation about KittyItems. Thanks.

Can you please check if you can send any transactions on testnet?
It seems that tx is not sealed.
This might be a problem with the whole testnet.

Hey @avcd this issue arrives when multiple transactions are sent one after another without waiting for the previous transaction to complete.
As mentioned the nonce needs to change for each transaction sent.
The loop goes like this:
-> read last nonce (0), send transaction [ transaction pending, so nonce is still 0]
-> read last nonce(0), send transaction; [new transaction pending with nonce 0, meanwhile last transaction was executed, so on chain nonce is now 1, as this transaction was sent with nonce 0 it will be rejected]

1 Like

Hey @daniel Thanks for the reply.
I now understand why this error is occurring.
The root cause seems to be that the testnet transactions are not being sealed.
Can Flow team solve this?

Hi everyone.
Transactions on Testnet are now sealed properly.
With that, the issue has been resolved. Thanks for your comments.

But I’m curious as to why the transaction was not sealed :thinking: