Skip to content
SummaryAn instruction has 3 fields: program_id (which program to invoke), accounts (AccountMeta list with is_signer/is_writable flags), and data (byte array of data that the program interprets).

​Instruction structure

An Instruction consists of three fields:
  • program_id: The ID of the program being invoked.
  • accounts: An array of account metadata
  • data: A byte array with additional data to be used by the instruction.
Instruction struct

​Program ID

The instruction’s program_id is the public key address of the program that contains the instruction’s execution logic. The runtime uses this field to route the instruction to the correct program for processing.

​Account metadata

The instruction’s accounts array is an ordered list of AccountMeta structs. Metadata must be provided for each account the instruction interacts with. The validator uses this metadata to determine which transactions can run in parallel. Transactions that write to different accounts can execute in parallel. The diagram below depicts a transaction that contains a single instruction. The instruction’s accounts array contains metadata for two accounts.
Each entry in an instruction's accounts list is an AccountMeta: an address plus signer and writable flags.Each entry in an instruction's accounts list is an AccountMeta: an address plus signer and writable flags.
Each entry in an instruction's accounts list is an AccountMeta: an address plus signer and writable flags.
Each AccountMeta has three fields:
  • pubkey: The account’s public key address
  • is_signer: Set to true if the account must sign the transaction
  • is_writable: Set to true if the instruction modifies the account’s data
To know which accounts an instruction requires, including which must be writable, read-only, or sign the transaction, you must refer to the implementation of the instruction, as defined by the program.
AccountMeta

​Data

The instruction’s data field is a byte array that tells the program which function to invoke and supplies the arguments for that function. The data typically begins with a discriminator or index byte(s) that identifies the target function, followed by the serialized arguments. The encoding format is defined by each program (for example, Borsh serialization or a custom layout). Common encoding conventions:
  • Core programs (System, Stake, Vote): Use a Bincode-serialized enum variant index followed by serialized arguments.
  • Anchor programs: Use an 8-byte discriminator (the first 8 bytes of the SHA-256 hash of "global:<function_name>") followed by Borsh-serialized arguments.
The runtime does not interpret the data field. It is passed as-is to the program’s process_instruction entrypoint.

​Compiled instruction

When instructions are serialized into a transaction message, they become CompiledInstruction structs that replace all public keys with compact integer indices into the message’s account_keys array.

​Example: SOL transfer instruction

The example below shows the structure of a SOL transfer instruction.
The Rust tabs on this page use the 2.x Solana crates. Install the dependencies with (tested with Rust 1.89 and 1.98):
The code below shows the output from the previous code snippets. The format will differ between SDKs, but notice that each instruction contains the same three pieces of required information: program_id, accounts, data.
The examples below show how to manually build the transfer instruction. (The Expanded Instruction tab is functionally equivalent to the Instruction tab.)
In practice, you usually don’t have to construct an Instruction manually. Most programs provide client libraries with helper functions that create the instructions for you. If a library isn’t available, you can manually build the instruction.