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!