# Nonce, queue and conflict transactions

### Nonce concept

In blockchain-based systems like Ethereum or Stacks a `nonce` is used as part of the transaction verification process. When a user initiates a transaction, they include a nonce as one of the fields in the transaction data.&#x20;

The nonce is typically an integer value that starts at `0` and is incremented by 1 for each subsequent transaction made by the same sender (multisig Vault). The purpose of the nonce is to ensure that each transaction from a sender is unique and can only be processed once. This prevents double spending, where a user attempts to spend the same amount of cryptocurrency multiple times by creating multiple transactions with the same data. Each transaction with a different nonce is considered a distinct transaction, even if other details of the transaction, such as the recipient or the amount, remain the same. The transaction nonce serves several important purposes:

* **Prevents replay attacks:** By including a nonce in a transaction, the sender can ensure that the transaction cannot be replayed, preventing an attacker from capturing and re-submitting the same transaction multiple times to gain unauthorized access or spend the same funds multiple times.
* **Enforces transaction order:** The nonce also helps to enforce the order of transactions from an account. Transactions must be submitted with consecutive nonces, meaning that a transaction with nonce `n` must be submitted after a transaction with nonce `n-1`. This prevents transactions from being reordered or skipped, ensuring that they are processed in the intended sequence.
* **Ensures transaction uniqueness:** The transaction nonce ensures that each transaction from a sender's account is unique. Even if the transaction details, such as the recipient address or the amount, are the same, transactions with different nonces are considered distinct transactions. This prevents double spending, where the same funds are used for multiple transactions.

### Transaction queue

Only transactions that have **current nonce** — nonce of `last executed transaction +1` — can actually be executed at any given time. Transactions with a higher nonce are staged for execution in the `Queue`.

To view the transaction queue navigate to the **Transactions** section -> **Queue** tab.

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2F4jN29EGdYE19mmOFXKjE%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%203.23.31%20PM.png?alt=media&#x26;token=ae902388-2e1e-4c6b-a553-b497a3feb914" alt=""><figcaption></figcaption></figure>

So whenever a transaction gets executed, the next transaction in the queue will be made available for execution, given it has collected enough signatures.

{% hint style="info" %}
Transactions staged for execution in the queue are available to be signed by the Vault owners in order to reach confirmation threshold in advance. You can sign queued transaction in spite of its order in the queue.
{% endhint %}

Queued transactions are listed under the alert with information which **nonce is expected to be executed first.**&#x20;

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FwJOT1B6FldyeGkhRKUiG%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%203.23.31%20PM.png?alt=media&#x26;token=c22e5559-237b-4a26-b777-60bb037424fe" alt=""><figcaption></figcaption></figure>

### Editing nonce

Creating any transaction the user can **Edit its nonce**.&#x20;

Automatically to any subsequent transaction will be assigned **recommended nonce**.&#x20;

{% hint style="info" %}
**Recommended nonce**:

* Is equal the current nonce, when there are no transactions with the **current nonce** in the **Queue** tab.
* Is higher than current nonce, when there are transactions with the current and subsequent nonce(s) in the Queue tab.

For example:&#x20;

1\) the **last executed** **nonce** of the Vault `2`, the **current nonce** equals `3`, there are no queued transactions with nonce `3` -> **recommended nonce** will be `3`.

2\) the **last executed nonce** of the Vault `2`, the **current nonce** equals `3`, there are queued transactions with nonces `3,4,6` -> **recommended nonce** will be `5`.
{% endhint %}

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2Fxn72gIFmXmDAWO176m5o%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%203.54.20%20PM.png?alt=media&#x26;token=992dd0ec-0e1f-4823-ba3a-c116c145abb8" alt=""><figcaption></figcaption></figure>

Transaction nonce field will guide your with essential hints:

* Edited nonce **cannot be lower than current nonce**, or `last executed transaction +1`.

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2F5zux42xlo1aIAMeRrNGW%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202023-11-03%20%D0%B2%204.48.52%20PM.png?alt=media&#x26;token=71b7c5b3-4262-4d77-b112-0f5ca5ec9ca8" alt="" width="375"><figcaption></figcaption></figure>

* Edited nonce **can be higher than recommended or current nonce**. In this case the user can create a transaction with higher nonce, get all the owner confirmations, but cannot execute the transaction before other transactions with lower nonce are executed. \
  Such transaction (with higher nonce) will be [queued for later execution](#transaction-queue).

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FVKe28KceyrrfUlMp6sXc%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202023-11-03%20%D0%B2%204.49.17%20PM.png?alt=media&#x26;token=64d7a3e7-31e3-4275-bf86-90b0bef3da65" alt="" width="375"><figcaption></figcaption></figure>

* Edited nonce **can be the same as nonce of an already created** but not executed transaction. \
  This will create [conflict transactions](#conflict-transactions).<br>

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FSOPRLMWBV5eplfUlAaBj%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202023-11-03%20%D0%B2%204.49.06%20PM.png?alt=media&#x26;token=4f321a04-dbce-4f19-9673-4185f9152506" alt="" width="375"><figcaption></figcaption></figure>

### Conflict transactions

In case there are transactions with the same nonce that are waiting to be executed, they are conflicting with each other.

{% hint style="info" %}
To create conflict transaction create from scratch any new transaction and assign to it the `same nonce` as an already created transaction has.&#x20;
{% endhint %}

Any conflict transaction can acquire owners’ confirmations independently. **Conflict transactions** displayed in the **Queue** tab with the same nonce and same action buttons (Sign / Execute). After getting all the owners’ confirmations one of the conflict transactions can be executed.

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FiyvOJTiIjodcgQIFW9h8%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%203.23.31%20PM.png?alt=media&#x26;token=c7ada150-8141-4535-bf3f-bbe8070ae222" alt=""><figcaption></figcaption></figure>

Executing one transaction will automatically replace the other(s) from the list of conflict transactions. Replaced, or rejected, conflict transactions are displayed in the **History** tab with `Rejected` status.&#x20;

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FEkrmHq3q7kLEnaHU16d7%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%204.14.52%20PM.png?alt=media&#x26;token=217bbfd0-953c-4316-8c1d-ff23274b3f2e" alt=""><figcaption></figcaption></figure>

The transaction that has already been sent to the blockchain acquires `Processing` status.

To reject this processing transaction and execute another one, you can still create and execute the conflict transaction with the higher gas fee. That means, the execution of the conflict transaction, with the gas fee higher than the processing one has, will be faster.&#x20;

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FnwMJhzeAxwt5xj4mvzlL%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%204.11.31%20PM.png?alt=media&#x26;token=03af495e-df48-40c3-b7bb-d2a62115d707" alt=""><figcaption></figcaption></figure>

Nevertheless, when this transaction is close to its completion, the Processing status is changed to `Finalizing` .

At this stage, creation or execution of the conflict transactions with the same nonce is not possible anymore, the execution process reaches the point of no return.

<figure><img src="https://254144762-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmUskow6Yg0G4jQRE0Lf%2Fuploads%2FzijRB2XfDN6YDM6SI5Dm%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202025-05-30%20%D0%B2%204.11.38%20PM.png?alt=media&#x26;token=1c184352-15ad-4f7b-8341-344396b43c9d" alt=""><figcaption></figcaption></figure>
