Solana Web3 Transaction を試していたときに発生したエラー。
現象
Solana Web3 Transaction をそのまま実行すると以下のエラー。
% node create_manually_transaction.js
payer_balance => 100000000000000
Transaction simulation failed: Transaction leaves an account with data with a lower balance than rent-exempt minimum
Program 11111111111111111111111111111111 invoke [1]
Program 11111111111111111111111111111111 success
/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/node_modules/@solana/web3.js/lib/index.cjs.js:6817
throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
^
SendTransactionError: failed to send transaction: Transaction simulation failed: Transaction leaves an account with data with a lower balance than rent-exempt minimum
at Connection.sendEncodedTransaction (/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/node_modules/@solana/web3.js/lib/index.cjs.js:6817:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/node_modules/@solana/web3.js/lib/index.cjs.js:6772:20)
at async Connection.sendTransaction (/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/node_modules/@solana/web3.js/lib/index.cjs.js:6762:12)
at async Object.sendAndConfirmTransaction (/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/node_modules/@solana/web3.js/lib/index.cjs.js:2977:21)
at async main (/Users/user/Documents/Programming/Blockchain/solana-anchor-react-minimal-example/js/solana/create_manually_transaction.js:35:3) {
logs: [
'Program 11111111111111111111111111111111 invoke [1]',
'Program 11111111111111111111111111111111 success'
]
}
原因
詳細はわからなかったが、Solanaにはrent費用があり、定期的に回収にくるが、払えないとデータが消える? 一定額以上を払うとrent免除になるが、そのミニマム費用が足りていない?
対応
payerだけでなく、以下のようにtoAccountにもAirdropして解決。
let toAccount = web3.Keypair.generate();
let airdropSignatureToAccount = await connection.requestAirdrop(
toAccount.publicKey,
web3.LAMPORTS_PER_SOL
);
await connection.confirmTransaction(airdropSignatureToAccount);