Sign in

Lamports, rent, and account lifecycle

Suggest an edit

Every account on Solana costs something to keep on the chain. The cost works the way a security deposit at an apartment works: you pay it up front, the chain holds it while the account exists, and you get it back when the account closes.

One SOL is divided into one billion smaller units called lamports, and everything on the chain is measured in lamports: balances, fees, storage deposits, validator rewards. The base fee for one transaction signature is five thousand lamports, or 0.000005 SOL, and the storage deposit for a typical token account is around two million lamports, or 0.00204 SOL.

Rent is a deposit that stays locked while the bytes are in use

Every byte of data on the chain has to be held in memory by every validator on the network. Holding data has a cost, and the chain charges for it. The name for that charge is rent.

On Ethereum storage is paid for at the moment of the write. The writer pays gas once, and the value then has to be held by every full node until something overwrites it. Clearing the value later returns only part of that gas. Solana ties the payment to the lifetime of the data. Each account holds a deposit in lamports that stays locked for as long as the bytes are occupied and comes back in full when the account is closed, so whoever receives the refund has a reason to close an account that is no longer used.

Solana originally also let an account pay a small amount each epoch out of its lamports balance until it ran out and got deleted. That mode was deprecated, and only the deposit remains. Every account on Solana today is rent-exempt, meaning it holds a minimum lamport balance proportional to its size that stays locked for as long as the account exists. When a developer says "rent" they mean this one-time deposit rather than an ongoing fee.

The deposit covers roughly two years of that per-epoch rent, which comes to about 6,960 lamports per byte, counted over the account's data plus 128 bytes of overhead. An empty wallet costs about 890,000 lamports. A 165-byte token account costs about 2,040,000 lamports. A 200-kilobyte program account costs about 1.4 SOL.

Rent deposit sizes for an empty wallet, a token account, and a deployed programThe diagram compares three accounts: an empty wallet (0 bytes, about 890,880 lamports), a token account (165 bytes, about 2,039,280 lamports), and a deployed program (about 200,000 bytes, about 1.4 SOL). A formula box below shows the deposit equals (account size in bytes plus 128 overhead) times about 6,960 lamports per byte, and notes the deposit is refunded when the account closes. The deposit scales with the size of the account an empty wallet 0 bytes deposit needed: ~890,880 lamports ≈ 0.00089 SOL just the bookkeeping overhead, since the data is empty a token account 165 bytes deposit needed: ~2,039,280 lamports ≈ 0.00204 SOL enough room for mint, owner, amount, plus the overhead a deployed program ~200,000 bytes (200 KB) deposit needed: ~1,400,000,000 lamports ≈ 1.4 SOL code is big, so the storage cost is significant The math required deposit = (account size in bytes + 128 overhead) × ~6,960 lamports/byte 128 is fixed per account, the rate per byte is fixed by the network Bigger account, bigger deposit. The deposit is fully refundable when the account closes.

An account is created, held for free, and closed for a refund

Creating an account takes one instruction from the System Program. That instruction does three things in one step: it allocates the right number of bytes for the account's data, transfers the rent-exempt deposit from a payer into the account's lamports field, and assigns ownership to a target program.

Holding an account does not cost anything. As long as the rent-exempt deposit is in place, the account stays on the chain indefinitely, with no further fee and no expiration.

Closing an account is two operations packed into one. The owner program zeros out the data field and transfers the entire lamports balance out to a recipient address you specify. Once the balance hits zero, the runtime considers the account uninitialized, and an account can be created at the same address again.

Account lifecycle: create, hold, and close, with the lamport deposit refundedThree steps show an account's life: creating it makes Alice pay about 2,040,000 lamports, holding it has no ongoing fees, and closing it drains the lamports back to a recipient, usually Alice. A summary box shows the net storage cost is zero, since the deposit paid at creation equals the amount refunded at closing. The life of an account: create, hold, close 1. Create payer: Alice's wallet action: allocate bytes, deposit lamports, assign owner Alice pays ~2,040,000 lamports 2. Hold state: the account exists, read and written by its owner program fees: none ongoing the lamports sit on the account 3. Close action: zero the data, drain the lamports to a recipient recipient: usually Alice Alice gets back ~2,040,000 lamports Net cost to Alice paid at create: +2,040,000 lamports refunded at close: -2,040,000 lamports net storage cost: 0 lamports The deposit is a hold rather than a payment. It only costs Alice if the account is never closed. This refund pattern is how applications give users their deposits back when they exit.

Size accounts, choose who pays, and close them when done

Size. Every account is sized at creation, and when you decide how big an account should be, you decide its cost. By the formula above, a 10,000-byte account costs about thirty times more than a 200-byte one. There is no penalty for using small accounts, so most production programs keep their accounts as small as the data they need to store. An account also cannot grow without bound. Its data is capped at ten megabytes, and growing it later takes a deliberate call that pays additional deposit for the new bytes.

Who pays. The deposit comes from one of the accounts listed in the transaction, marked as the payer. Your program does not pay out of its own balance. Choosing the payer is a design decision. The team can pre-create an account for every user and pay for all of them, or the program can create the account on a user's first action, funded by that user. Almost always it is the user whose action triggered the creation, since the user is the one who benefits from the new account existing. Tokens raise the same question. A wallet needs a separate token account for each token it holds, so the first time a wallet receives a given token, either the sender or the recipient has to lock about 2,040,000 lamports for the new account.

Close. When you want to clean up after a user, you close the account and send its lamports back to them, so their net storage cost is zero. The Anchor framework you'll be using has a close constraint that does this in one line. Programs that skip cleanup leave unused accounts on the chain and force their users to pay for storage they no longer need. A closed account can be brought back. Anyone can send lamports to its address later in the same transaction, and the runtime then keeps the account alive. Account closure and realloc shows the attack this allowed and how the close constraint prevents it.

For every account your program creates, decide who pays the deposit and who receives it when the account closes.