Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/protocol/transaction-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ In addition, a transaction has the following fields to ensure its integrity and
Users create transactions and sign them with their private keys. Then, the **transaction and its signature** are broadcast together to the network, where they are validated and processed.

:::tip
Each transaction has exactly one `Signer` and `Receiver`, but can have multiple `Actions`
Each transaction has exactly one `Signer` and `Receiver`, but can have multiple `Actions`.
:::

:::info About nonce values
- When adding a key, the `nonce` is automatically assigned - particularly, it is given the value `block height * 10^6` - so the value in the `ADD_KEY` action is ignored
- A transaction is accepted only if the `nonce` value is in the range of:
- `[(current_nonce_of_access_key + 1) .. (block_height * 10^6)]`
- Once a transaction is accepted, the access key's `nonce` is set to the `nonce` value of the included transaction
:::

---

## Actions

Each transaction can have **one or multiple** `Actions`, which are the actual operations to be performed on the `Receiver` account. There are 9 types of actions that can be performed:

1. `FunctionCall`: to invoke a function on a contract (optionally attaching NEAR to the call)
Expand Down
14 changes: 13 additions & 1 deletion docs/protocol/transaction-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ While creating the `Receipt`, the `signer` gets $NEAR deducted from its balance
If the `signer` and `receiver` coincide - e.g. the `signer` is adding a Key - the `Receipt` is immediately processed in this first block and the transaction is considered final.

#### Block #2: The Receipt is Processed
If the `signer` and `receiver` differs - e.g. the `signer` transfers NEAR to the `receiver` - the `Receipt` is processed in a second block.
If the `signer` and `receiver` differs - e.g. the `signer` transfers NEAR to the `receiver` - the `Receipt` is processed in a second block.

During this process a `FunctionCall` could span a **cross-contract call**, creating one or multiple new `Receipts`.

Expand Down Expand Up @@ -114,3 +114,15 @@ See the examples below for more details.
:::tip
You can check the status of a transaction using the [NearBlocks explorer](https://nearblocks.io/)
:::

---

## Nonce values

The `nonce` is a number that is incremented for each transaction sent by the transaction's `Signer`.
On a valid transaction, the `nonce` value should follow these rules:

- When adding a key, the `nonce` is automatically assigned - particularly, it is given the value `block height * 10^6` - so the value in the `ADD_KEY` action is ignored
- A transaction is accepted only if the `nonce` value is in the range of:
- `[(current_nonce_of_access_key + 1) .. (block_height * 10^6)]`
- Once a transaction is accepted, the access key's `nonce` is set to the `nonce` value of the included transaction
Loading