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
| # | Type | Required | Description |
|---|---|---|---|
| 1 | usize | Yes | Account data length in bytes |
| 2 | object | No | Configuration object |
Configuration object fields:
| Field | Type | Description |
|---|---|---|
commitment | string | Commitment level: processed, confirmed, or finalized |
Response
Returns a single value:
| Field | Type | Description |
|---|---|---|
result | u64 | Minimum lamports required for rent exemption |
Code Examples
cURL
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
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
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
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
{
"jsonrpc": "2.0",
"result": 2039280,
"id": 1
}