getMinimumBalanceForRentExemption
Returns minimum balance required to make account rent exempt.
Common use cases
| Account creation cost calculation | Calculate required SOL before creating any on-chain account. Prevents 'InsufficientFundsForRent' errors by ensuring sufficient funds for both transaction fees and rent exemption. |
| Stake account funding | Determine minimum balance needed for stake accounts (typically 200 bytes). Essential for staking operations where accounts must remain rent-exempt throughout delegation lifecycle. |
| Token mint and account setup | Calculate rent for token mints and associated token accounts. Token-2022 extensions increase account size, requiring accurate size calculation before creation. |
Parameters
length (usize, required)
The Account's data length
config (object, optional)
Configuration object containing the following fields:
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getMinimumBalanceForRentExemption",
"params": [
50,
{
"commitment": "processed"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getMinimumBalanceForRentExemption",
"params": [
50,
{
"commitment": "processed"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getMinimumBalanceForRentExemption",
"params": [
50,
{
"commitment": "processed"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": 500,
"id": 1
}
Response Fields
Return value: u64
Minimum lamports required in the Account to remain rent free
FAQ and Troubleshooting
Why does this return different values for the same data length over time?
Rent parameters in the rent sysvar can change through governance. The calculation includes lamports-per-byte-year and exemption threshold, which may be adjusted. Cache results carefully and refresh periodically.
What data length should I use for a standard SOL account?
Use 0 for system-owned accounts that only hold SOL. Token accounts use 165, stake accounts use 200 (StakeStateV2.size_of()). Check program-specific constants for custom accounts.
Why am I getting 'InsufficientFundsForRent' errors?
Your fee payer lacks funds to cover both the transaction fee AND the rent-exempt minimum for new accounts. Call this method before creating accounts, then ensure fee payer balance >= (rent_exemption + transaction_fee).
Does the commitment parameter affect the returned value?
Minimally. Rent parameters come from the rent sysvar which changes infrequently through governance. Most applications omit commitment or use finalized for consistency with production account creation.
How does this relate to the old rent collection system?
Solana no longer collects recurring rent. All accounts must be rent-exempt (balance >= minimum) or they are purged. This method calculates the threshold for exemption, not an ongoing payment.
Related Methods
getAccountInfo
Returns account details including lamports balance and data length. Use together to verify an account meets rent exemption requirements after creation.
getBalance
Returns account SOL balance in lamports. Compare with getMinimumBalanceForRentExemption result to validate sufficient funds before account creation transactions.
getStakeMinimumDelegation
Returns minimum lamports for stake delegation. Use both methods when creating stake accounts: rent exemption minimum + stake minimum delegation.
getFeeForMessage
Calculates transaction fee for a message. Total required balance = getFeeForMessage + getMinimumBalanceForRentExemption for all new accounts in transaction.
getMultipleAccounts
Fetches multiple account states including data lengths. Batch calculate rent requirements by mapping data lengths through getMinimumBalanceForRentExemption.