Skip to content

Rent

Rent

Rent is the mechanism Solana uses to keep account data active. In Solana, storing account data requires paying rent to prevent unlimited blockchain state growth. However, in the current implementation, accounts do not need to pay rent on an ongoing basis as long as their balance meets the "rent-exempt" threshold.

Rent Mechanism

Rent Calculation Rent is calculated based on the storage space occupied by the account:

Rent = Account Size (bytes) x Per-byte Rent Rate x Time

Per-byte Rate - Currently approximately 0.00000348 SOL/byte/epoch - 1 epoch is approximately 2-3 days - The rate can be adjusted through governance

Rent Exemption When an account balance reaches a certain threshold, rent is permanently waived:

Rent-exempt Balance = Account Size x Per-byte Rent x 2 years

For example, a 165-byte account requires approximately 0.00114 SOL to be rent-exempt.

Current Status

Mandatory Rent Exemption Since 2021, Solana requires all new accounts to meet the rent-exempt threshold: - Sufficient SOL must be deposited when creating an account - Non-exempt accounts cannot be created - Existing non-exempt accounts are gradually reclaimed

This simplifies development, as developers do not need to worry about rent collection.

Account Creation

Calculating the Rent-Exempt Amount

let rent = Rent::get()?;
let space = 165; // Account size
let lamports = rent.minimum_balance(space);

Creating an Account

invoke(
    &system_instruction::create_account(
        payer.key,
        new_account.key,
        lamports, // Rent-exempt balance
        space as u64,
        program_id,
    ),
    &[payer, new_account],
)?;

Closing Accounts

Recovering SOL When closing an account, the rent-exempt SOL can be recovered:

**destination.lamports() += source.lamports();
**source.lamports() = 0;

This is an important way for programs to optimize storage costs.

Comparison with Other Chains

Chain Storage Cost Model
Solana One-time payment (rent exemption)
Ethereum Gas fee + permanent storage
Near Staked token locked storage
Arweave One-time payment for permanent storage

Storage Optimization

1. Compress Data Use compact data structures:

#[account]
pub struct CompactData {
    pub value: u32,  // Instead of u64
    pub flag: bool,  // 1 byte
}

2. Use PDAs Consolidate multiple user data entries into a single account.

3. Close Unused Accounts Recover rent promptly.

4. Zero-copy Use zero-copy for large data to avoid copying overhead:

#[account(zero_copy)]
pub struct LargeData {
    pub data: [u64; 1000],
}

  • Lamports: The smallest unit of SOL, where 1 SOL = 1,000,000,000 lamports
  • Epoch: A time period in Solana, approximately 2-3 days
  • AccountsDB: The database that stores all account data
  • State Rent: A similar rent concept proposed by Ethereum (not implemented)