Overview page background
How to Calculate Rent for Solana Programs

How to Calculate Rent for Solana Programs

Daniel Idowu headshot

Written by Daniel Idowu

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on 2023-01-253 min read

Program executions on the Solana blockchain begin with a transaction. The blockchain consists of a network of computer systems that duplicates and distributes a digital ledger of transactions across the entire network. Each block on the chain comprises a number of transactions, and each participant's ledger receives a copy of each new transaction that takes place on the blockchain. 

Storing all of this data in separate accounts is not free and incurs some expenses. In this article, we will guide you on the concept of rent on Solana and how you can calculate it.

What is rent on Solana?

Rent is the fee every Solana account pays to store data on the blockchain, and is denominated in Lamports, or the smallest unit of SOL which are used for micropayments. Rent fees are calculated based on the size of the account's storage. The higher the rent, the greater the amount of data stored.

Since Solana node clusters must actively maintain this data, a time and space-based fee is needed to keep an account, and consequently its data, alive on the blockchain. All Solana accounts must keep their Lamport balances high enough to qualify for rent exemption and to stay on the Solana blockchain. Accounts that are found to contain a low amount of Lamports are removed from the network by the garbage collector.

When are rent fees collected?

Rent fees are usually collected at the end of each epoch. An epoch is the period of time during which the leading validator is still capable of generating blocks of transactions. The Solana Explorer contains the data for the most recent and preceding epochs.  Rent is also paid when accounts are referenced by a transaction.

At the conclusion of each slot, a percentage of the rent that accounts have collected is destroyed, and the remainder is paid to the vote accounts. The account will be deallocated and the data deleted if there is not enough money in it to cover the rent. It's also crucial to remember that brand-new accounts have to be rent-free.

Rent is also very important because validators on the network must keep a working copy of this state in memory; the network charges a time-and-space-based fee for this resource consumption. This is because Accounts on Solana may have an owner-controlled state (Account::data) that is distinct from the account's balance (Account::lamports).

How to calculate rent for a Solana program?

Using the Solana rent command from the Solana CLI provides a simple approach to estimate rent costs. You can view the rent per byte, per epoch, and the minimum amount required for an account to be rent-exempt by entering the size (in bytes) of your account.

According to the rent regime, accounts have Account::rent epoch of the current epoch or the current epoch + 1 and rent is owed for one epoch's worth of time.

Account::rent epoch is simply adjusted to current epoch if the account is in the exempt regime.

If the account is non-exempt, Rent::due() is used to determine how much rent is owed by this account. This calculation is based on the difference between the next epoch and Account::rent epoch. These steps will show you how to calculate rental price for a Solana program.

Step 1: Create new program

First, navigate to your terminal and create a new folder using cargo, this is where our main file will be stored.

Open the src/main and replace with the code snippet here

Step 2: Calculate the rent cost 

The size of the file should be 906 bytes, we can calculate the rent by simply running:

solana rent 906

You should see the following:

Output from the Solana Rent command in terminal
Output from the Solana Rent command in terminal

Finally, there is no matching transaction for rent deductions because rent collection occurs in accordance with protocol-level account modifications, such as the rent distribution to validators.

Therefore, rent collection is largely invisible and may only be implicitly observed by a recent transaction or by timing specified by the account address prefix.

How to Redeem Solana Storage Fees

To reclaim Solana storage fees, developers and everyday Solana users can close accounts to receive their storage fees back. The simplest way to redeem Solana rent fees is using a consumer friendly tool like Sol Incinerator (https://sol-incinerator.com/) to close unused program accounts in your wallet.


The rent cost is currently set at the genesis, but it is planned to become dynamic in the future, reflecting the current cost of the underlying hardware storage. Therefore, it is widely believed that as technology progresses and hardware costs fall, so will the rent fee costs.

Overview cards background graphic
Section background image

Build blockchain magic with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.