2

i'd like to know the difference between the below two kinds of errors:

  1. account sequence mismatch, expected N+1, got N: incorrect account sequence
  2. signature verification failed; please verify account number (X), sequence (Y) and chain-id (Z): unauthorized

for #2, assume that the account number and chain-id are correctly provided.

From my experience, #1 means the provided sequence is smaller than expected. while #2 means the provided sequence is larger than expected.

can we say so?

Jack Zhu
  • 558
  • 1
  • 5
  • 11

1 Answers1

0

Only transaction that has the correct sequence can broadcast successfully.

So for #1, the error means the sequence number of this transaction is not match the sequence of the sender account.

For #2, the node uses the public key of the sender account to verify the signature. When verification failed, the node responds to this error. So you can decode the signature to verify that signerInfos (X Y Z) and signedDoc in the signature must match with the info when you sign.

To get sequence of sender account, you can call LCD (REST) or RPC.

Example (Aura Serenity Network):

{
  "account": {
    "@type": "/cosmos.auth.v1beta1.BaseAccount",
    "address": "aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8",
    "pub_key": {
      "@type": "/cosmos.crypto.secp256k1.PubKey",
      "key": "AnoOQm4UTbzswwES5Mo+/LHFbT9653fDecq4Rrc+2jnA"
    },
    "account_number": "20755",
    "sequence": "27"
  }
}
  • RPC: aurad q account aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8 --node https://rpc.serenity.aura.network:443
'@type': /cosmos.auth.v1beta1.BaseAccount
account_number: "20755"
address: aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8
pub_key:
  '@type': /cosmos.crypto.secp256k1.PubKey
  key: AnoOQm4UTbzswwES5Mo+/LHFbT9653fDecq4Rrc+2jnA
sequence: "27"
harisato
  • 326
  • 1
  • 7