Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Instruction dispatch – tag-based routing with zero allocation.

Hopper uses a 1-byte or 2-byte tag at the start of instruction data to route to handler functions. The dispatch! macro generates an efficient match statement.

§Dispatch variants

  • hopper_dispatch!, Standard: receives (program_id, accounts, data)
  • hopper_dispatch_lazy!, Lazy: receives LazyContext, parses accounts on-demand
  • hopper_dispatch_8!, 8-byte discriminator (Anchor/Quasar compatible)

Constants§

EVENT_CPI_PREFIX
Event CPI prefix. Programs should check for this at dispatch entry and return Ok(()) to allow self-CPI events to pass through.

Functions§

dispatch_instruction
Read a 1-byte dispatch tag from instruction data.
dispatch_instruction_8
Read an 8-byte discriminator (Anchor/Quasar compatible).
dispatch_instruction_u16
Read a 2-byte dispatch tag (for programs with >256 instructions).