Solana apps often feel like one simple action: swap a token, mint an NFT, stake SOL, or claim a reward. Behind the screen, that action may involve several programs talking to each other. This is where Cross-Program Invocation, usually shortened to CPI, becomes important.
What is CPI?
A Solana program is smart contract code deployed on-chain. CPI means one program calls another program during the same transaction. Instead of every app rebuilding the same features, programs can compose with existing building blocks such as token transfers, escrow logic, lending pools, or decentralized exchange routes.
CPI is one reason Solana apps can be fast and composable: a transaction can coordinate multiple on-chain programs in one flow.
A simple example
Imagine a Nobunaga-themed game where a player buys an in-game item with a token. The game program may not move tokens by itself. Instead, it can call the Solana Token Program through CPI to transfer the payment, then update the player inventory inside the game program.
- The wallet signs one transaction.
- The game program checks the purchase rules.
- The game program invokes the Token Program.
- The token transfer happens.
- The game state is updated if everything succeeds.
If any required step fails, the transaction fails, helping keep the action atomic.
Why beginners should care
- Composability: CPI lets DeFi, gaming, NFTs, and wallet tools connect like Lego blocks.
- Efficiency: Developers can rely on trusted programs instead of duplicating common logic.
- Risk awareness: A transaction may touch more programs than the app interface shows.
- Security checks: Good apps verify which accounts and programs are allowed before making CPI calls.
What to check before signing
For normal users, the key habit is to review wallet prompts carefully. If a transaction asks for broad token permissions, unknown program access, or a transfer you did not expect, pause. CPI itself is not dangerous; it is a tool. The risk comes from poorly written programs, malicious interfaces, or users signing actions they do not understand.
In short, CPI is Solana's way for programs to cooperate inside one transaction. For beginners, understanding this idea makes on-chain activity less mysterious and helps explain why wallet simulation, trusted apps, and careful signing matter.