Trying to figure out the exact lamports needed to make a "wallet" (account created by a SOL transfer) rent exempt. There are lots of contradictory information on this topic, some sources say the SystemProgram owned account is 0 bytes, but when experimenting with get minimum rent exemption RPC for zero bytes and trying to withdrawal all but that amount minus 5000 lamports, the transaction will fail due to leaving the balance below rent exemption. Other sources say the data storage of a SystemProgram account is not 0 bytes but haven't found any information on the exact size of the account.
2 Answers
Hello took me a bit and some help to figure out. From the amount the rent costs you can calculate that the size of the account must be 128 Bytes
solana rent 128 = 0.00089088 SOL
These 128 calculate as follows:
// Stored meta: write_version_obsolete: 8, data_len: 8, pubkey: 32 = 48
// Accountmeta: lamports: 8 rent_epoch:8 exec_flag: 1 owner_key: 32 = 49
// Hash: 32 = 32
// 48 + 49 + 32 = 129
But the bool for exec_flag needs actually 8 byte because of some padding. So you get 136 bytes. But the rent cost is actually 128. So looks like you can get 8 bytes for free \o/
If you want to close an accounts you need to transfer all the lamports out. So if you are also the feepayer that would be 84088 otherwise 89088.
-
Are you saying an account is exempt from rent if the data size <= 8 bytes? Because I actually need to store exactly 8 bytes in a PDA (hundreds of them). Commented May 13 at 12:59
-