Serge Tyatin
Serge Tyatin

Reputation: 197

NearProtocol transaction commit, how to avoid InvalidNonce error reponce

In same cases, there is an error on transaction commit like

{"code"=>-32000,
     "data"=>{"TxExecutionError"=>{"InvalidTxError"=>{"InvalidNonce"=>{"ak_nonce"=>58108599002462, "tx_nonce"=>58108599002462}}}},
     "name"=>"HANDLER_ERROR",

In the error response, the ak_nonce is equal to tx_nonce The question what is wrong with nonce ? How do avoid this error?

Thank you

Upvotes: 1

Views: 199

Answers (1)

As you already marked, a cause of the error is really comes from tx_nonce and ak_nonce equality.

From NEAR Protocol spec:

Transaction nonce must be account[access_key].nonce + 1

I think, the problem appears owning to time, spent between getting last ak_nonce from blockchain and sending new signed transaction to blockchain.

As a result, workaround may be to increase ak_nonce not by one, but, for example, by ten. account[access_key].nonce + 10

Upvotes: 1

Related Questions