Cross-Program Invocations (CPIs) are a crucial part of the Solana blockchain, allowing programs to interact with each other. When no Program Derived Address (PDA) signing is required, the official Solana documentation provides guidance on using the invoke function for these interactions.
Key Takeaways
- The invoke function is used for CPIs without PDA signers.
- Signer and writable privileges extend from the caller to the callee.
- Examples are provided in both Anchor and Native Rust.
Using the Invoke Function
When performing CPIs on Solana without requiring PDA signers, the invoke function is utilized. This function calls the invoke_signed function with an empty signers_seeds array, indicating that no PDAs are needed for signing. This setup allows the signer and writable privileges to extend from the calling program to the callee, facilitating seamless interactions between programs.
Implementation Examples
The documentation provides examples of implementing CPIs without PDA signers using both Anchor and Native Rust. In Anchor, developers can use the CpiContext and system_instruction::transfer functions to execute a SOL transfer between accounts. Alternatively, in Native Rust, the process involves creating and invoking a transfer instruction directly. These examples demonstrate the flexibility and options available for developers working with Solana’s CPI capabilities. For more detailed guidance, explore our Solana guides.




