Expand description
Instruction introspection – stack height and sibling instruction access.
These syscalls are critical for security patterns that no framework wraps:
-
CPI guard: Detect if the current instruction is running inside a CPI call (stack height > 1). Prevents unauthorized composition – e.g., a governance instruction that must be top-level only.
-
Ed25519 signature verification: Check that a previous instruction in the same transaction was to the Ed25519 precompile with specific data. This is how on-chain programs verify off-chain signatures without heavy crypto libraries.
-
Secp256k1 recovery: Same pattern for Ethereum-compatible signatures.
No existing framework (pinocchio, Anchor, Steel, Quasar) wraps these syscalls with ergonomic APIs. Programs that need them write raw unsafe glue every time.
Structs§
- Processed
Instruction - Metadata about a previously processed sibling instruction.
Constants§
- ED25519_
PROGRAM_ ID - Well-known precompile address for Ed25519 signature verification.
- SECP256
K1_ PROGRAM_ ID - Well-known precompile address for Secp256k1 signature recovery.
Functions§
- get_
processed_ instruction - Retrieve a previously processed sibling instruction from the current transaction.
- get_
stack_ height - Get the current instruction stack height.
- is_cpi
- Returns true if the current instruction is running inside a CPI.
- is_
top_ level - Returns true if the current instruction is at the top level (not running inside a CPI).
- require_
cpi - Require that the current instruction IS inside a CPI.
- require_
ed25519_ instruction - Check that a previous sibling instruction was to the Ed25519 precompile.
- require_
secp256k1_ instruction - Check that a previous sibling instruction was to the Secp256k1 precompile.
- require_
top_ level - Require that the current instruction is NOT a CPI call.