RPC error InsufficientFundsForRent: Insufficient funds for rent
Last updated:
At a glance
| Property | Value |
|---|---|
| Applies to | Solana JSON-RPC |
| Display string | Transaction results in an account ({account_index}) with insufficient funds for rent |
| Rule | Rent-exempt minimum, or zero |
| Check with | getMinimumBalanceForRentExemption |
| Retryable | Not unchanged |
Cause
Accounts must either hold at least the rent-exempt minimum for their size, or hold nothing. A transfer that leaves a wallet with a few lamports, a new account funded below its minimum, or a transfer of almost all of a balance all break this rule. It looks like an arithmetic problem and is one: the fee, the transfer and the minimum all have to fit into the same balance.
Solution
- Read the account index in the error and map it through the transaction's account list.
- Call
getMinimumBalanceForRentExemptionwith the account's data size. Use 0 for a plain wallet. - To empty a wallet, send everything minus the fee so it ends at exactly zero, or leave at least the minimum.
- For a new account, include the minimum in
createAccount.
Example
{
"err": {
"InsufficientFundsForRent": {
"account_index": 1
}
}
}FAQ
- Can an account hold less than the minimum?
- Not as the result of a new transaction. It can end at zero, which closes it, or at the minimum or above.
- Why did sending my whole balance fail?
- The transfer has to leave enough for the fee and end at exactly zero or above the minimum. A balance that is a little short of either fails.