Documentation index

getMinimumBalanceForRentExemption

Returns the minimum balance required to make an account rent exempt for a given data size. On Solana, accounts must maintain a minimum SOL balance proportional to their data size to avoid being purged by the runtime. This method is essential when creating new accounts, as you need to know exactly how much SOL to fund them with to ensure they persist indefinitely.

Parameters

#TypeRequiredDescription
1usizeYesAccount data length in bytes
2objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
commitmentstringCommitment level: processed, confirmed, or finalized

Response

Returns a single value:

FieldTypeDescription
resultu64Minimum lamports required for rent exemption

Code Examples

cURL

Terminal
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getMinimumBalanceForRentExemption",
  "params": [
    165
  ]
}'

TypeScript

TypeScript
const response = await fetch("http://88.216.36.108:7999", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "getMinimumBalanceForRentExemption",
    params: [
      165
    ]
  }),
});
const { result } = await response.json();
console.log("Rent-exempt minimum:", result / 1e9, "SOL");

Python

Python
import requests

response = requests.post("http://88.216.36.108:7999", json={
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getMinimumBalanceForRentExemption",
    "params": [
        165
    ]
})
result = response.json()["result"]
print(f"Rent-exempt minimum: {result / 1e9} SOL")

Rust

Rust
use reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    let res = client.post("http://88.216.36.108:7999")
        .json(&json!({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "getMinimumBalanceForRentExemption",
            "params": [
                165_usize
            ]
        }))
        .send().await?
        .text().await?;
    println!("{}", res);
    Ok(())
}

Example Response

JSON
{
  "jsonrpc": "2.0",
  "result": 2039280,
  "id": 1
}