-
-
In Starknet, similar to Ethereum, every contract has a nonce, which is sequential. When a transaction is sent from an account, the transaction’s nonce must match the account’s nonce. The account’s nonce is incremented after the transaction is executed, whether or not the transaction is reverted.
-
-
-
-
-
-
- |
-
-
- In Starknet, only the nonce of account contracts, that is, those adhering to the above structure, can be non-zero.
-
-
- In contrast, in Ethereum, regular smart contracts, known as Contract Accounts, as opposed to Externally Owned Accounts can increment their nonce by deploying smart contracts, that is, executing the CREATE and CREATE2 opcodes.
-
-
- For more information on accounts in Ethereum, see Ethereum Accounts in the Ethereum documentation.
-
- |
-
-
-
-
-
A nonce serves two important roles:
-
-
-
--
-
It guarantees transaction hash uniqueness, which is important for a good user experience.
-
--
-
It provides replay protection to the account. Because the signature refers to a particular nonce, a malicious party cannot replay the transaction.
-
-
-
-
-
While Starknet currently determines the sequential nonce structure at the protocol level, in the future, Starknet will consider a more flexible design, extending account abstraction to nonce management, also referred to as nonce abstraction.
-
-