Rent & Rent-Exemption
Solana accounts must hold enough lamports to be rent-exempt - a one-time deposit based on data size. Without it, accounts cannot persist on-chain.
Search across all documentation pages
Solana accounts must hold enough lamports to be rent-exempt - a one-time deposit based on data size. Without it, accounts cannot persist on-chain.
solana rent 200const rent = await rpc.getMinimumBalanceForRentExemption(200n).send();When to reach for this:
init payer transfers in Anchor programsuse anchor_lang::prelude::*;
#[derive(Accounts)]
pub struct InitConfig<'info> {
#[account(
init,
payer = payer,
space = 8 + Config::INIT_SPACE,
)]
pub config: Account<'info, Config>,
#[account(mut)]
pub payer: Signer<'info>,
pub system_program: Program<'info, System>,
}
#[account]
#[derive(InitSpace)]
pub struct Config {
pub admin: Pubkey,
pub fee_bps: u16,
}import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://api.devnet.solana.com");
const space = 8 + 32 + 2; // discriminator + fields
const minBalance = await rpc.getMinimumBalanceForRentExemption(BigInt(space)).send();
console.log("Rent-exempt minimum:", minBalance, "lamports");What this demonstrates:
init transfers at least the rent-exempt minimum from payer to new account| Account Type | Bytes | Approx Rent (lamports) |
|---|---|---|
| Empty wallet | 0 | ~890,880 |
| SPL Token Account | 165 | ~2,039,280 |
| Anchor small struct | 8 + 40 | ~1,500,000+ |
Exact values change with cluster parameters - always query RPC.
space in Anchor - init fails or truncates data. Fix: use InitSpace derive or manual calculation with max string/vec lengths.close constraint.getMinimumBalanceForRentExemption in clients.| Alternative | Use When | Don't Use When |
|---|---|---|
solana rent CLI | Quick terminal estimates | On-chain program logic |
| RPC rent query | Dynamic client UI cost display | Inside BPF (use sysvar or fixed buffer) |
| State compression | Millions of small records | Hot mutable state |
Funding an account with enough lamports to cover ~2 years of storage rent upfront. The account then persists without ongoing rent charges.
space = 8 + sizeof serialized fields (with max lengths for String/Vec). Query RPC for exact lamports.
Yes. Close the account and lamports return to a destination you specify.
Legacy behavior could garbage-collect; modern practice requires rent-exempt at creation. Underfunded inits fail.
Yes. Rent scales linearly with data size in bytes.
The payer signer in init - typically the user or protocol treasury.
Yes. Deployed programs hold lamports for their program data account size.
Growing data may require additional lamports transferred to maintain rent-exemption.
Rent sysvar holds calculation parameters. Rarely read directly in modern programs.
Common UX pattern for ATAs and PDAs. Budget treasury accordingly.
Same formula; amounts are identical for the same data size.
No. Only data size and cluster rent parameters matter.
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 16, 2026