Transaction Anatomy
Key Elements
Important
Transaction Anatomy
Solana transactions consist of two major parts in the following order:
- A compact array of signatures.
- A message that contains a compact array of account addresses, a recent blockhash and a compact array of instructions.
Signatures
For each signature in the compact array, the Solana verifies two conditions:
- The number of signatures must match the first 8 bits of the message header.
- Each signature is validated against the corresponding public key at the same index in the account addresses array.
Message Layout
1. Header
- Number of required signatures in the transaction (8 bits).
- Number of read-only accounts requiring signatures (8 bits).
- Number of read-only accounts not-requiring signatures (8 bits).
2. Accounts
- Addresses that require signatures with read-write access.
- Addresses that require signatures with read-only access.
- Addresses that do not require signatures with read-write access.
- Addresses that do not require signatures with read-only access.
3. Recent blockhash
-
- Ensures transaction lifetime
Transaction is deemed invalid if the blockhash is older than 150 blocks (approximately 1 minute).
-
- Prevents transaction replay
By tying each transaction to a unique recent blockhash, Solana ensures that identical transactions cannot be processed more than once.
4. Instructions with the following anatomy:
- Program ID index.
- Compact-array of account address indices.
- Compact-array of opaque 8-bit data (what operations to perform and any additional data).