Skip to main content

Overview

Transactions are cryptographically signed instructions from accounts that update the state of the Starknet network. Starknet supports only three types of transactions, with each type going through the same lifecycle to receive its execution and finality statuses. Every transaction that was executed successfully is issued a receipt, which includes its statuses, as well as other information about it. Additional information

Transaction types

Starknet supports the following types of transactions:
The L1HandlerTransaction type is also a valid transaction type within Starknet, be it cannot be broadcast through the Starknet API like other transaction types, as it was specifically designed for internal Starknet operations (particularly, handling messages from L1 to L2).The DEPLOY transaction type existed in Starknet for deploying account before being replaced by DEPLOY_ACCOUNT. DEPLOY only had one version (v0) and is now unsupported by Starknet.
Each transaction type is versioned, with versions increasing when the fields that comprise the transaction change, either with the addition of a new field or the removal of an existing field. The following table summarizes the current, deprecated, and unsupported versions of each transaction type:
Do not submit a transaction that uses an unsupported transaction type, as it cannot be included in a proof, and therefore cannot become part of a Starknet block.Sending transaction that use deprecated versions is still supported, but support will be removed in an upcoming Starknet release.

Transaction lifecycle

The high-level steps in the Starknet transaction lifecycle are as follows:
  1. Transaction submission: A transaction is submitted to a sequencer by a full node.
  2. Mempool validation: The sequencer’s mempool performs preliminary validation of the transaction, such as ensuring that its invoker’s balance exceeds the transaction’s max_fee value, assuring the transaction’s calldata length is within the legal limit, and more. If the transaction is invalid, it does not proceed.
  3. Sequencer validation: The sequencer performs preliminary validation of the transaction before executing it to ensure that the transaction is still valid. If the transaction is invalid, it does not proceed.
  4. Execution: The sequencer batches all transactions that passed the preliminary validation into a block, and applies them to the state sequentially. If a transaction fails during execution, it is included in the block with as reverted.
  5. Proof generation and verification: The prover uses the Starknet operating system to computes the proof for the correct execution of all transactions in the block, and transmits it to the L1 verifier, which verifies it. At this point, the L1 state is updated to include the transaction.

Mempools

Up to and including Starknet v0.13.5, transactions were received and ordered by the sequencer in a first-in-first-out (FIFO) fashion. Starting from Starknet v0.14.0, each sequencer will instead maintain a mempool, decouping the transaction order of arrival from the transaction ordering in blocks, for which they are can decide their own policy. The introduction of mempools will have the following implications on how transactions are processed:
  • Nonces: Transactions with a nonce greater than the sender’s current nonce + xx will be rejected by the mempool, where:
    • A sender’s current nonce is the sender’s nonce in the latest finalized state at the time the transaction is received
    • X is 200 for INVOKE and DEPLOY_ACCOUNT transactions and x=0x = 0 for DECLARE transactions (i.e., no declares with future nonces)
  • Fee escalation: A transaction in the mempool can be replaced by a transaction sent from the same account with the same nonce and both tip and max_l2_gas_price increased by at least 10%. If the transaction was submitted with zero tip, it can still be replaced by another transaction with zero tip.
    There are unlikely edge cases in which a transaction is not replaced despite submitting a valid transaction to replace it, such as the existing transaction entering a block while the new one is still processed in the gateway.
  • Transaction time-to-live (TTL): Transactions that cannot be included in a block and have exceeded their TTL, currently configured to be 5 mins, are periodically evicted from the mempool
  • DECLARE transactions time-to-mature (TTM): Before being inserted into the mempool, DECLARE transactions are sent to a “waiting room” until they exceed their TTM, where TTM < TTL but is still TBD. While in the “waiting room”, DECLARE transactions can’t be replaced, and transactions sent with the same nonce as a transaction in the “waiting room” by the same account are rejected

Transaction statuses

Since Starknet version 0.14.0, the finality statuses are the following:

State implications of reverted transactions

When a transaction is marked as REVERTED, the following state implications occur:

Transaction receipt

A transaction receipt can be obtained by using the Starknet API’s starknet_getTransactionReceipt endpoint and contains the following fields: The following is an example of a transaction receipt: