getMinimumBalanceForRentExemption

The getMinimumBalanceForRentExemption method returns the minimum balance required for an account to be rent-exempt. Rent exemption is a crucial concept in Solana's economic model, determining how much SOL must be held in an account to prevent it from being charged periodic rent fees.

Solana implements a rent mechanism to discourage blockchain state bloat. Accounts must maintain a minimum balance proportional to their data size to be rent-exempt. Accounts with balances below this threshold were historically charged rent (though rent collection is currently disabled), and could eventually be purged from state. In practice, all active accounts should maintain rent-exempt status by holding sufficient lamports based on their data size.

This method is essential when creating new accounts, resizing existing accounts, or validating that accounts have sufficient balance to maintain their state. The rent-exempt minimum is calculated as: 2 years of rent based on the account's data size. Understanding rent exemption is critical for program development, account initialization, and any operation that modifies account data size.

Parameters

parameter
type
description
dataLength
number
The size of the account data in bytes (u64)
config
object
Optional configuration object
config.commitment
string
Level of commitment: 'processed', 'confirmed', or 'finalized' (default: 'finalized')

Return Object

field
type
description
result
number
Minimum balance in lamports required for rent exemption for an account of the specified data length

Request Example

Request

Response Example

Response

Tip: SPL Token accounts are 165 bytes and require ~0.002 SOL for rent exemption. Program accounts and custom data structures have different sizes. Always fund new accounts with at least the rent-exempt minimum plus any balance needed for their purpose. The formula is approximately: 19.055441478439427 lamports per byte per year * 2 years.


Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?