Skip to main content

Module introspect

Module introspect 

Source
Expand description

Instruction introspection – stack height and sibling instruction access.

These wrappers support security patterns based on transaction and call-stack introspection:

  • 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.

Hopper wraps these syscalls behind small typed helpers so programs do not need to repeat raw unsafe glue at every call site.

Structs§

ProcessedInstruction
Metadata about a previously processed sibling instruction.

Constants§

ED25519_PROGRAM_ID
Well-known precompile address for Ed25519 signature verification.
SECP256K1_PROGRAM_ID
Well-known precompile address for Secp256k1 signature recovery.
SECP256R1_PROGRAM_ID
Well-known precompile address for Secp256r1 (P-256) signature verification (SIMD-0075). This is the precompile that backs passkey / WebAuthn signature checks on Solana.

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_secp256r1_instruction
Check that a previous sibling instruction was to the Secp256r1 (P-256) precompile, the verification path for passkeys / WebAuthn.
require_top_level
Require that the current instruction is NOT a CPI call.