Instruction Introspection

Summary

The Instructions sysvar (Sysvar1nstructions1111111111111111111111111) lets a program read all top-level instructions in the current transaction by index or relative offset. CPI inner instructions are not accessible.

Instructions sysvar

Programs can inspect all top-level instructions in the current transaction via the Instructions sysvar (Sysvar1nstructions1111111111111111111111111). This lets a program inspect the other instructions in the same transaction, for example to verify that a specific instruction is in the same transaction as the instruction it's executing.

The Instructions sysvar only contains top-level instructions from the transaction message. Inner instructions invoked via CPI are not accessible through this sysvar.

The instructions sysvar is not accessed through the normal Sysvar trait. Instead, it is accessed through free functions in the solana_instructions_sysvar crate.

The sysvar data is serialized with a custom binary layout:

OffsetSizeDescription
02num_instructions (u16, little-endian)
22 * NByte offsets for each instruction (u16 each)
variesvariesSerialized instruction data
last 2 bytes2Current instruction index (u16, little-endian)

Each serialized instruction contains: the number of accounts (u16), the accounts as 33-byte entries (1 flag byte + 32-byte pubkey), the program ID (32 bytes), the data length (u16), and the raw data bytes.

Key functions:

Is this page helpful?

सामग्री तालिका

पृष्ठ संपादित करें

द्वारा प्रबंधित

© 2026 सोलाना फाउंडेशन। सर्वाधिकार सुरक्षित।
जुड़े रहें