WithdrawExcessLamports: rent back without closing

The token instruction that moves only the SOL above the rent minimum out of a token account or mint. The account and its tokens stay.

Updated

WithdrawExcessLamports is an instruction of Solana’s token programs. It moves the SOL that a token account or mint holds above its rent-exempt minimum to another address. The account stays open, its tokens do not move, and the minimum it needs stays in place.

Why it exists

Token accounts used to hold exactly their minimum, so there was nothing to withdraw. Two things changed that. Anyone can send SOL to any address, including a token account, and before this instruction those lamports were stuck until the account was closed. And SIMD-0437 lowers the minimum itself, so every token account opened at the old price now holds more than it needs:

  2,039,280  held            (128 + 165) × 6,960
− 1,488,440  minimum today   (128 + 165) × 5,080
=   550,840  withdrawable    lamports

Closing the account would return everything, but only works when it is empty. For accounts that still hold tokens you want to keep, withdrawing the excess is the only way to get that SOL.

Where it is available

Token-2022 has had the instruction for years. The classic SPL Token program got it with p-token (SIMD-0266), the rewrite that replaced its implementation on mainnet on May 13, 2026 (epoch 971). Both use the same instruction number and account order, so one code path serves both programs.

The instruction

#AccountRole
0SourceThe token account, mint or multisig with excess. Writable.
1DestinationReceives the excess, usually the owner’s wallet. Writable.
2AuthoritySigns: the owner of a token account, the mint authority of a mint, or a multisig’s signers.

Instruction data: a single byte, 38. The program computes the amount itself; you cannot ask for more.

Why it is safe to sign

  • It cannot move tokens. The instruction only touches lamports; the token balance is not an input.
  • It cannot take too much. The program reads the current minimum and withdraws only what lies above it. The account stays rent-exempt.
  • It needs your signature. Only the account’s authority can withdraw, and the destination is part of what you sign.

That said, read every transaction before signing it, on any site: the instruction is safe, but a transaction can contain other instructions too. How to check a transaction before you sign shows what to look for.

Limits

  • Wrapped SOL accounts are rejected (NativeNotSupported): their lamports are the token balance. Unwrap them instead (wrapped SOL).
  • Mints need their mint authority to sign. Most holders cannot withdraw a mint’s excess; the creator of a token whose authority is still set can.
  • Other programs’ accounts, from stake accounts to DeFi positions, are outside the token programs and need their own instruction.

Using it

Solana’s guide shows how to build the instruction yourself with the token program libraries. The UNRENT scanner does it for every account of a wallet: it computes the excess from the live minimum, packs the withdrawals and the closes into as few transactions as possible, simulates them and hands them to your wallet. What you sign lists the exact instructions.

Sources

Keep reading