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:
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
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:
@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([
fcl.transaction(CODE),
fcl.proposer(fcl.currentUser().authorization),
fcl.payer(fcl.currentUser().authorization),
fcl.limit(100)
])
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
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]
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?