Published on

Everything you wanted to know about Solana Rent but was afraid to ask

Authors

Rent is an important concept that you must understand as a Seahorse and Solana developer. Fortunately it’s not too hard to get to grips with and with this post I hope to cover pretty much everything you need to know as a beginner.

So what is rent?

Well, it’s a minimum balance of SOL that a Solana account must hold, usually it’s very low because the required rent is proportional to the amount of data the account stores on the network. If you’ve done a token swap on Solana already, then you’ve paid rent to set up the token account, probably without realizing.

Let’s look at the example below. Here on the block explorer we can see there are many moving parts to this transaction. Focus on lines 4 and 5, these are marked in bright green which means the SOL in these accounts is increasing.

all about rent 1

These are 2 new accounts being created as part of the transaction. The SOL transferred to them is ◎0.00851904 and ◎0.00162864 respectfully. These small amounts are rent, which is the minimum amount of SOL the accounts must hold. The amounts are different because one of the accounts holds 1096 bytes of data and the other holds 106 bytes of data.

Why do we need rent?

Solana enforces rent to encourage efficient use of storage and help prevent state bloat. It’s also a sybil defense mechanism as you can’t just freely spam a billion accounts on Solana without incurring significant cost. The trad-fi metaphor would be a bank asking its customers to maintain a minimum account balance.

Can I get the rent back?

Yes, rent is refundable! If an account is closed and removed from the network, the data is deleted from the chain and the rent is refunded to the account owner by default. Remember every single account on Solana must have an owner.

Several teams have built front-ends to help users reclaim rent from their empty token accounts. Active users. Two popular options are Sol-Incinerator and Step Finance’s Account Tools. Some wallets may also have the service built in to ‘burn’ NFTs and reclaim the rent.

As rent is necessary to create a new account on Solana, you will need to know how much rent to pay in advance. The easiest way to do this is through the command line with the Solana CLI.

solana rent 90

This calculates the rent needed for an account with 90 bytes of data. It should log something like the following to the console.

Rent-exempt minimum: 0.00151728 SOL

As you can see rent is both very cheap and very expensive. Very cheap in absolute terms as for most fungible and non-fungible token mint accounts rent will be a tiny fraction of a SOL. Very expensive for storage per byte, given all we are storing are relatively tiny bits of data on the blockchain. Storage on blockchains in general tends to be VERY expensive, Solana is no exception.

You may already have noticed deploying even simple programs on devnet can cost multiple SOL. This is because programs need more storage. To close a program and reclaim the rent you can run the following command on the CLI. Replace ADDRESS with the public address of your program.

solana program close ADDRESS