services
Get a key

library / Blockchain ideas / BI0031

Account storage cost calculator

Storing 1 kB, 10 kB and 100 kB in one Solana account costs a refundable deposit of about 0.0057, 0.0515 and 0.5087 SOL. You get the formula, a main.ts that reads the exact figure from the RPC, and the write fees on top.

By Carbium · Developer tools · BI0031 · updated 2026-11-22

01

Who uses it

Anyone about to put data in an account asks this before writing program code. A game team wants the price of one save slot per player. A registry builder wants the price of one record times a million records. A hackathon team wants to know whether a 100 kB document on chain costs cents or a whole SOL, and which figure goes on their pitch deck.

The calculator answers in one command. It asks the node for the figure instead of carrying a constant, so it stays right if the cluster's rent rate changes, and it prints the write fees next to the deposit so the total is on one screen.

02

The short answer

Solana charges for storage as a deposit. An account has to hold enough lamports to be rent exempt, and the minimum is 5,080 lamports for each byte of data plus the same rate on 128 bytes of account overhead. One SOL is 1,000,000,000 lamports. Here 1 kB is 1,000 bytes.

Data sizeDeposit in lamportsDeposit in SOL
0 bytes650,2400.00065024
1,000 bytes5,730,2400.00573024
10,000 bytes51,450,2400.05145024
100,000 bytes508,650,2400.50865024
1 MiB5,327,416,3205.32741632
10 MiB53,268,311,04053.26831104

The 128-byte overhead is why 1 kB costs more than 1,000 times the per-byte rate: 1,000 bytes at 5,080 is 5,080,000 lamports, and the overhead adds 650,240. The overhead matters less as the account grows, and by 100 kB it is about 0.1% of the total.

$The deposit stays in the account and comes back when the account is closed, to whatever address the closing instruction names. Data you delete later has cost you the transaction fees and nothing else.
03

What else adds up

The deposit is the large part, and it is not the only cost. A legacy or v0 transaction is capped at 1,232 bytes. After signatures, the account list and the instruction header, one write carries roughly 1,000 bytes of your data. A 100 kB account therefore takes about 100 write transactions on top of the one that creates it.

CostAmountComes back
Rent-exempt deposit5,080 lamports per data byte plus 650,240Yes, when the account closes
Base fee5,000 lamports per signatureNo
Priority feeOptional, set per transactionNo

At 5,000 lamports each, 100 writes cost about 500,000 lamports, or 0.0005 SOL. Against the 0.50865024 SOL deposit that is under 0.1%. Priority fees are extra and depend on how busy the network is; priority fee per compute unit shows how to read the current ones.

Size also decides how the account is built. A program that creates an account through CPI, such as a PDA, can start it at 10 KiB at most, so a 100 kB account of that kind is created small and grown by realloc in steps of up to 10 KiB per instruction, about ten of them. A top-level System Program createAccount can allocate up to 10 MiB in one instruction. The ceiling for any account is 10 MiB, which is why the calculator refuses larger sizes.

04

The build

The calculator is one file that needs @solana/kit and what Node 24 ships. It is read-only: no signing, no wallet, nothing sent.

  1. Read sizes in bytes from the command line, defaulting to 1,000, 10,000 and 100,000, and refuse anything above 10 MiB.
  2. Call getMinimumBalanceForRentExemption once per size on https://services.carbium.sh, with the key in the x-api-key header. The calls run together and each one is caught on its own, so a failed size prints its error and the rest still print.
  3. Compute the same figure locally as (128 + size) * 5080 and print match or differs beside the RPC answer.
  4. Print lamports, SOL, the number of 1,000-byte writes and the base fees for them.
main.ts
// BI0031 · Account storage cost calculator// https://carbium.sh/library/blockchainideas/account-storage-cost-calculator// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";const apiKey = process.env.CARBIUM_KEY;if (!apiKey) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const client = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": apiKey },  }),);const LIMIT = 10 * 2 ** 20; // largest account the runtime allowsconst OVERHEAD = 128n; // account bytes counted in the rentconst RATE = 5080n; // lamports per byte for a rent-exempt account, as the cluster reports itconst BYTES_PER_WRITE = 1000; // data one write transaction carries, roughlyconst FEE_PER_SIGNATURE = 5000n; // lamportsfunction toSol(lamports: bigint): string {  const frac = String(lamports % 1_000_000_000n).padStart(9, "0");  return `${lamports / 1_000_000_000n}.${frac}`;}async function priceOne(size: number): Promise<string> {  try {    const onChain = await client.getMinimumBalanceForRentExemption(BigInt(size)).send();    const writes = BigInt(Math.ceil(size / BYTES_PER_WRITE));    const expected = (OVERHEAD + BigInt(size)) * RATE;    const verdict = expected === onChain ? "match" : `differs (${expected})`;    const fees = toSol(writes * FEE_PER_SIGNATURE);    return [size, onChain, toSol(onChain), writes, fees, verdict].join(" | ");  } catch (err) {    return `${size} | failed: ${err instanceof Error ? err.message : String(err)}`;  }}const given = process.argv.slice(2);const sizes = (given.length ? given : ["1000", "10000", "100000"]).map(Number);const invalid = sizes.filter((n) => !Number.isInteger(n) || n < 0 || n > LIMIT);if (invalid.length > 0) {  console.error(`Sizes are whole bytes from 0 to ${LIMIT}; rejected: ${invalid.join(", ")}`);  process.exit(1);}console.log("bytes | deposit lamports | deposit SOL | writes | write fees SOL | formula");const lines = await Promise.all(sizes.map(priceOne));console.log(lines.join("\n"));

run: CARBIUM_KEY=<YOUR_KEY> node main.ts 1000 10000 100000

Sizes go in as bigint because kit types the argument that way, and the answer comes back as a bigint, so sums stay exact and the SOL string is built with integer division. The call leaves commitment out, so kit fills in confirmed. The rent rate is a cluster setting, so the figure does not depend on the commitment you pick.

A JSON-RPC request can also carry a batch of up to 100 calls. A sweep over many sizes can go out as one POST that way. For a handful of sizes the kit client's one call per request is fine.

05

What to add next

  • Size from a struct: sum the field widths of your account layout and pass the total, so the calculator prices your own data type.
  • Cost per user: multiply the deposit by an expected account count and show the total a program would lock up.
  • A check against a live account: getAccountInfo returns its lamports and data length, so you can confirm an existing account holds the minimum for its size. It is an account read at 10 cells, 0.5 req/s on Free and 15 on Dev.
  • A dollar column from a price you trust, since the SOL figures here move in dollars as SOL does.
  • A form: serve the table from a small HTTP route with a size field, and call the RPC once per request.
06

Where it ends

  • The figure holds only at the moment of the call.
  • The deposit is not the whole bill. Fees, priority fees and any other accounts your program creates, such as a token account per user, are priced on their own sizes.
  • The write count is an estimate. The data per transaction depends on how many accounts and signers the instruction lists.
  • Growth is not modeled. Reallocating an account to a larger size needs the difference topped up, and shrinking leaves the surplus lamports in the account until a program moves them.
  • The calculator prices accounts on chain only. It does not price compressed or off-chain storage, and it does not turn SOL into dollars.
  • It reads no existing account and no history.
07

When it goes wrong

what goes wrongwhat to do
Every call answers 401.The key is unknown at the door. Attach the whole key in CARBIUM_KEY, with no prefix cut off and no trailing space.
The RPC figure differs from the local formula.Trust the RPC. The cluster's rent rate changed since the constant in the code was set, so update RATE to the new figure.
The deposit looks too high for the data.The call adds the 128-byte overhead itself, so pass only the bytes of your data, without the 128 added.
The typecheck fails on the size argument.kit takes the size as a bigint. Wrap a number with BigInt(n) before the call, as the code does.
A size over 10 MiB is rejected before any call.The runtime caps one account at 10 MiB. Split the data across several accounts and price each one on its own size.
A size typed with units, such as 10kB, is rejected before any call.Sizes are whole bytes. Write 10000 for 10 kB or 10485760 for 10 MiB.
08

Questions

Do I pay this every year?

No. The deposit is paid once, when the account is funded, and closing the account returns it. The only cost that is spent is the transaction fees you pay to write.

Why does 1 kB cost more than 1,000 times the per-byte rate?

Every account counts 128 bytes of overhead in its rent. At 5,080 lamports per byte that adds 650,240 lamports to any account, however small its data.

Can I store 100 kB in one transaction?

No. A legacy or v0 transaction is capped at 1,232 bytes, so the data goes in over about 100 writes. A program-owned account that a program creates or grows by realloc moves in steps of up to 10 KiB per instruction.

Does the calculator need a funded wallet?

No. It only reads the rent minimum, so it needs your Carbium key and nothing else. It signs nothing and sends nothing.