CPI to the System Program
The System Program handles account creation, assignment, allocation, and lamport transfers. Most programs CPI to it for rent payment and SOL movement.
Search across all documentation pages
The System Program handles account creation, assignment, allocation, and lamport transfers. Most programs CPI to it for rent payment and SOL movement.
invoke(
&system_instruction::transfer(from.key, to.key, amount),
&[from.clone(), to.clone()],
)?;When to reach for this:
let rent = Rent::get()?;
let lamports = rent.minimum_balance(space);
invoke(
&system_instruction::create_account(payer.key, new.key, lamports, space as u64, owner),
&[payer.clone(), new.clone(), system_program.clone()],
)?;What this demonstrates:
| IX | Purpose |
|---|---|
| transfer | Move lamports |
| create_account | Allocate + assign |
| allocate | Add space |
| assign | Change owner (restricted) |
use solana_program::system_program;InsufficientFundsForRent; the runtime enforces rent exemption at creation. (Rent collection/reaping is no longer active, so the failure is up front, not later.) Fix: Fund Rent::get()?.minimum_balance(space).| Alternative | Use When | Don't Use When |
|---|---|---|
| Client creates account | Simpler program | PDA flows |
| Anchor init | Abstracts | Native |
| transfer_with_seed | Derived addresses | PDA preferred |
11111111111111111111111111111111
Yes.
Transfer all lamports out.
Rare - security sensitive.
create for new keys.
invoke_signed.
Rent::get() in program.
Allowed but pointless.
From account signer.
Multiple CPIs ok.
Match system_instruction helpers.
Test rent math.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 19, 2026