Got Error when send All balance from wallet,when i try send all sol balance using Phantom wallet its success, but when i try to send using solana/web3 i got this error : "failed to send transaction: Transaction simulation failed: Transaction results in an account (0) with insufficient funds for rent",

here mycode :

   let tx = new Transaction({
        feePayer: senderaddress.publicKey,
        recentBlockhash: (await sol_connection.getLatestBlockhash()).blockhash,
          fromPubkey: senderaddress.publicKey,
          toPubkey: new PublicKey(req.body.toaddress),
          lamports: req.body.amountSOL * LAMPORTS_PER_SOL - fees ,
    let txhash = await sol_connection.sendTransaction(tx, [senderaddress]);

1 Answer 1


Its a bit hard to see without the full code.

But it should be

amountInLamports - 5000

I would log all the values and double check they are correct.

If you are using the wallet adapter it maybe that your wallet automatically adds priority fee instructions. You can try send the transaction with preflight checks disabled and then look at the transaction in the solana explorer to see what is actually happening.

You can prevent a wallet to add priority fee instruction by adding an additional signature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.