suiboxer.xyz

Why your aptos transaction expired before being committed

Your Aptos transaction expired because it was submitted with an expiration timestamp that passed before the network included it in a block. Unlike Ethereum or Sui, where transactions remain pending indefinitely unless explicitly cancelled, Aptos assigns each transaction a hard deadline. If the validator set does not execute and commit the transaction before that deadline, the system discards it entirely.

How aptos transaction expiration works

Every Aptos transaction includes an expiration_timestamp_secs field. This is a Unix timestamp (seconds since epoch) that you set when constructing the transaction. The Aptos blockchain will not execute the transaction after this time, regardless of whether it was accepted into the mempool earlier.

When a validator receives a transaction, it checks two things before execution:

  1. Whether the transaction is already expired at the current validator's clock time.
  2. Whether the transaction's sequence number matches the sender's account state.

If the transaction passes both checks, the validator attempts to execute it within the current block. If the block fills or the validator cannot sequence the transaction before the expiration time, the transaction is dropped.

Common reasons for expiration

1. expiration timestamp set too short

The most frequent cause is setting the expiration timestamp too close to the submission time. If you set it 10 or 20 seconds into the future, a brief network delay or a congested mempool can cause the transaction to expire before a validator picks it up.

What to do: Set the expiration timestamp at least 60 - 120 seconds from the current time. For applications that must tolerate network congestion, consider 300 seconds (5 minutes) as a safer default.

2. Network Congestion

When many users submit transactions simultaneously, validators may not process your transaction within its expiration window. This happens during popular NFT mints, token launches, or periods of high DeFi activity.

Aptos uses Block STM for parallel execution, but the mempool still has capacity limits. If the mempool is full, new transactions may be rejected or delayed.

3. incorrect sequence number

Each Aptos account has a sequence number that increments with every committed transaction. If you submit a transaction with a stale sequence number - for example, after a previous transaction committed but your client did not update the sequence - the validator rejects it. The rejection itself does not cause expiration, but the retry loop often uses the same expiration timestamp, which may have already passed.

Check: Always fetch the current sequence number from the chain before constructing a new transaction.

4. gas price too low

Aptos uses a gas unit price model. If you set a gas price that is too low relative to the current network demand, validators may prioritize other transactions with higher gas prices. Your transaction sits in the mempool until it expires.

Check: Use the Aptos REST API endpoint /v1/estimate_gas_price to get a recommended gas price. The response includes deprioritized_gas_estimate, prioritized_gas_estimate, and gas_estimate. The gas_estimate value is typically sufficient for normal conditions.

How to Detect and Handle Expiration

Step 1: Check the Transaction Response

When you submit a transaction via the Aptos SDK or REST API, the response includes a hash. Poll for the transaction status using that hash. If the transaction expired, the API returns a TransactionExpired error or a status of Expired.

Step 2: Increment the Sequence Number

After an expiration, your account's sequence number does not change - the transaction was never committed. You must reuse the same sequence number for the replacement transaction. Do not increment it.

Common mistake: Many SDKs auto-increment the sequence number after a submission attempt. If you reuse the same SDK instance, it may skip the expired sequence number, causing all subsequent transactions to fail with a sequence number mismatch.

Step 3: Set a New Expiration Timestamp

The expired transaction's timestamp is now in the past. Set a new expiration_timestamp_secs at least 60 seconds from the current time.

Step 4: optionally adjust gas price

If the network is congested, increase the gas unit price. You do not need to change the max_gas_amount (the maximum gas units you are willing to spend), only the price per unit.

Differences from Sui

Sui does not use transaction expiration timestamps. A Sui transaction remains in the transaction queue until it is executed or explicitly removed by the sender. This means a Sui transaction with a low gas price can wait indefinitely, whereas an Aptos transaction with a low gas price will eventually expire and require resubmission.

This design choice means that on Aptos, you must actively monitor for expiration and resubmit. Automated retry logic in your application is more important than on Sui.

Best practices for avoiding expiration

Not financial advice. suiboxer.xyz publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.

Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.

Back to sui & aptos