This example contains two separate Quasar programs that work together:
lever/— A program with onchainPowerStatusstate and aswitch_powerinstruction that toggles a boolean.hand/— A program that calls the lever program'sswitch_powervia CPI.
Each program is a separate Quasar workspace. Build them independently:
cd lever && quasar build
cd hand && quasar buildThe hand program must be built after the lever, since its tests load the lever's compiled .so file.
cd lever && cargo test
cd hand && cargo testThe hand tests load both programs into QuasarSvm and verify that the CPI correctly toggles the lever's power state.
Quasar doesn't have a declare_program! equivalent for importing arbitrary program instruction types (unlike Anchor). Instead, the hand program:
- Defines a marker type (
LeverProgram) that implements theIdtrait with the lever's program address - Uses
Program<LeverProgram>in the accounts struct for compile-time address + executable validation - Builds the CPI instruction data manually using
BufCpiCall, constructing the lever's wire format directly
This is lower-level than Anchor's CPI pattern but gives full control and works with any program.