Rent calculator
How many lamports an account needs to be rent exempt, from its data size. Same result as getMinimumBalanceForRentExemption, without an RPC call.
(128 + 165) × 3480 × 2 = 2,039,280 lamports = 0.00203928 SOL
How Solana rent works
Every account must hold enough SOL to be rent exempt: a deposit proportional to its size that is returned when the account is closed. Rent is no longer collected over time; accounts that fall below the threshold are simply rejected by the runtime with insufficient funds for rent.
The formula
minimum = (128 + data_len) × 3480 lamports/byte-year × 2 years
= (128 + data_len) × 6960 lamportsThe 128-byte overhead covers the account metadata (lamports, owner, executable flag, rent epoch). A zero-byte wallet therefore needs 890,880 lamports (≈0.00089 SOL) and a 165-byte token account needs 2,039,280 lamports (≈0.00204 SOL). Those are the two numbers you will see most often.
Sizing Anchor accounts
Anchor prefixes every account with an 8-byte discriminator, so space = 8 + size_of_struct. Use #[derive(InitSpace)] and 8 + MyAccount::INIT_SPACE to avoid counting bytes by hand. Getting this wrong produces AccountDataTooSmall or ConstraintSpace.
Token-2022 accounts
Extensions add bytes. A Token-2022 mint with metadata, or a token account with several extensions, needs more than the classic 82 or 165 bytes. Use getMintLen([...extensions]) from@solana/spl-token to compute the exact size, then plug it in here.