1

I'm encountering an issue while trying to execute a transaction on the Solana Devnet. The error message I'm receiving is:

Transaction simulation failed: Transaction results in an account (1) with insufficient funds for rent.

Here's the code I'm using:

const suppliedToPubkey = process.argv[2] || null;

if (!suppliedToPubkey) {
  console.log(`Please provide a public key to send to`);
  process.exit(1);
}

const senderKeypair = getKeypairFromEnvironment("SECRET_KEY");

console.log(`suppliedToPubkey: ${suppliedToPubkey}`);

const toPubkey = new PublicKey(suppliedToPubkey);

const connection = new Connection("https://api.devnet.solana.com", "confirmed");

console.log(
  `✅ Loaded our own keypair, the destination public key, and connected to Solana`
);
const transaction = new Transaction();

const LAMPORTS_TO_SEND = 5000;

const sendSolInstruction = SystemProgram.transfer({
  fromPubkey: senderKeypair.publicKey,
  toPubkey,
  lamports: LAMPORTS_TO_SEND,
});

transaction.add(sendSolInstruction);

const signature = await sendAndConfirmTransaction(connection, transaction, [
  senderKeypair,
]);

console.log(
  `💸 Finished! Sent ${LAMPORTS_TO_SEND} to the address ${toPubkey}. `
);
console.log(`Transaction signature is ${signature}!`);

I have verified that the sender address has sufficient funds (5 SOL) on the Devnet. However, I'm still encountering this error even though the transaction is finalized.

Could anyone provide insights into what might be causing this issue? Any help would be greatly appreciated. Thank you!

3 Answers 3

2

In SOLANA, every account that holds SOL must be Initialised before it can receive SOL. If you try to send SOL to an address with a completely empty wallet (0 SOL), the transaction will fail because the account hasn't been initialised with a minimal balance required to be considered "rent-exempt."

Fund the Recipient's Account: Ensure that the recipient account has at least the minimum required SOL balance to become rent-exempt. This can be done by sending a small amount of SOL to the recipient account before the main transaction.

1

I wanted to update you that I have successfully resolved the issue I was facing with the transaction simulation failure on the Solana Devnet. After some investigation, I discovered that the problem was with the destination wallet rather than the sender wallet or the code itself.

The root cause of the issue was that the destination wallet address I was using initially might have had insufficient funds or other issues that prevented the transaction from going through. To address this, I created a new wallet on the Devnet and sent the transaction to this new wallet. This time, the transaction went through without any problems.

So, if anyone else encounters a similar issue where transaction simulation fails with an error message about insufficient funds for rent, I recommend double-checking the destination wallet's balance and ensuring that it is properly set up to receive the transaction.

Thank you to everyone who offered assistance and suggestions along the way. I hope this solution proves helpful to others facing similar challenges.

1

I too was facing the exact same issue ... got me literally 2 days to figure out that the address we are sending the sol also needs to have some sol in it. With complete empty wallet of the receiver (0.0 sol) we cannot transfer sol to that address. But this sounds kind of strange as to the signer (in out case , we the sender) only needs to have balance as he is the first n only signer in the signers array of sendAndConfirmTransaction() method. If anyone knows why is it so, please let me know.

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.