1

(Not token) I'm trying to move all the SOL that I receive in my SOL wallet, but I get an error: Transaction results in an account (0) with insufficient funds for rent

While I know what rent is, and that you need to have a minimum balance to be rent exempt, I have seen wallets completely drain their SOL balance (so they have 0 left) and I have looked at their instructions on solana explorer and it was nothing but a normal transfer. So what am I missing?

I'm using solana and solders on python to construct, sign & broadcast the transaction with this code:

    def send_transaction(
        cls,
        sender,
        receiver,
        amount,
        keypair.
        *args,
        **kwargs,
    ):
        # signature fee
        amount -= 5000
        transaction = Transaction().add(
            transfer(
                TransferParams(
                    from_pubkey=sender_key,
                    to_pubkey=receiver_key,
                    lamports=int(amount),
                )
            )
        )
        receipt = cls.client.send_transaction(transaction, keypair)

1 Answer 1

1

Okay first of all I think its nice if you would add compute unit price, and compute unit limit. But even then first you have to build a transaction and try to move 18446744073709551615 lamports. Obviously you wouldn't had that much SOL so it would error out in the simulation. But the simulation with it's error logs what we need. The logs of the simulation will be something like this:

 "Program ComputeBudget111111111111111111111111111111 invoke [1]",
 "Program ComputeBudget111111111111111111111111111111 success",
 "Program ComputeBudget111111111111111111111111111111 invoke [1]",
 "Program ComputeBudget111111111111111111111111111111 success",
 "Program 11111111111111111111111111111111 invoke [1]",
 "Transfer: insufficient lamports 44994092, need 18446744073709551615",
 "Program 11111111111111111111111111111111 failed: custom program error: 0x1",

Then you should make a regex like Transfer: insufficient lamports (\d+), so you can capture the 44994092 value from the logs which will be transferable. And then you can build up your real transaction with the exact value you just captured from the error logs. That should go trough. I know it's painful, but the other method would be if another wallet would be the fee payer, but that can raise other kind of errors.

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.