What Is Instruction in Solana?
An instruction is the smallest unit of execution on Solana. Each instruction invokes one program and specifies which accounts the program may read or write. A transaction contains one or more instructions, executed in order.
Instruction fields
| Field | Description |
|---|---|
programId | The program to invoke |
keys | Array of account metadata — address, isSigner, and isWritable for each account |
data | Byte array passed to the program (instruction arguments, typically serialized with Borsh or custom encoding) |
Account metadata
Each account in the keys array is marked as:
- Signer — the transaction must include a signature from this account’s keypair
- Writable — the program may modify this account’s data or lamport balance
These flags enable the runtime to schedule transactions in parallel when they don’t share writable accounts.
Multiple instructions
A transaction can contain up to approximately 50–60 instructions (limited by the 1232-byte transaction size limit and the 1,400,000 compute unit budget). All instructions in a transaction execute atomically — if any instruction fails, the entire transaction is reverted.
Instruction data encoding
Native programs use custom binary formats. Anchor programs use an 8-byte discriminator (SHA-256 hash of the instruction name) followed by Borsh-serialized arguments. The discriminator prevents calling the wrong instruction handler.
FAQ
What happens if one instruction in a transaction fails? The entire transaction fails atomically. No state changes from any instruction are applied, but the transaction fee is still charged.
Can instructions in different transactions run in parallel? Yes. The Solana runtime uses the account metadata to identify non-conflicting transactions and execute them in parallel on the Sealevel engine.
Updated: