How to Calculate Account Creation Cost

Keeping accounts alive on Solana incurs a data storage cost called rent. For the calculation, you need to consider the amount of data you intend to store in the account. Rent can be reclaimed in full if the account is closed.

import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("http://localhost:8899");
const space = 1500n; // bytes
const lamports = await rpc.getMinimumBalanceForRentExemption(space).send();
console.log("Minimum balance for rent exemption:", lamports);
Click to execute the code.

Is this page helpful?