Send SOL
Send native SOL and estimate transaction fees on Solana.
This guide explains how to send native SOL, estimate transaction fees, and use dynamic fee rates.
BigInt Usage: Always use BigInt (the n suffix) for monetary values to avoid precision loss with large numbers.
On Solana, values are expressed in lamports (1 SOL = 10^9 lamports). Fees are calculated based on the recent blockhash and instruction count.
Send Native SOL
Use account.sendTransaction() to transfer SOL to a recipient address.
const result = await account.sendTransaction({
to: 'publicKey', // Recipient's base58-encoded public key
value: 1000000000n // 1 SOL in lamports
})
console.log('Transaction hash:', result.hash)
console.log('Transaction fee:', result.fee, 'lamports')Estimate Transaction Fees
Use account.quoteSendTransaction() to get a fee estimate before sending.
const quote = await account.quoteSendTransaction({
to: 'publicKey',
value: 1000000000n
})
console.log('Estimated fee:', quote.fee, 'lamports')Quote or Send a TransactionMessage
Use a prebuilt TransactionMessage when you need custom instructions or a durable nonce flow.
If the transaction message already includes a recent blockhash or durable nonce lifetime, WDK preserves it. If it does not, WDK fetches the latest blockhash before quoting or sending. When you set feePayer, it must match the wallet address.
const quote = await account.quoteSendTransaction(txMessage)
console.log('Estimated fee:', quote.fee, 'lamports')
const result = await account.sendTransaction(txMessage)
console.log('Transaction hash:', result.hash)Use Dynamic Fee Rates
Retrieve current fee rates using wallet.getFeeRates(). Rates are calculated based on the recent blockhash and compute unit prices.
const feeRates = await wallet.getFeeRates()
console.log('Normal fee rate:', feeRates.normal, 'lamports')
console.log('Fast fee rate:', feeRates.fast, 'lamports')Complete Example
async function sendSOLTransfer(account, wallet) {
const solBalance = await account.getBalance()
const transferAmount = 1000000000n // 1 SOL
if (solBalance < transferAmount) {
throw new Error('Insufficient SOL balance')
}
const quote = await account.quoteSendTransaction({
to: '11111111111111111111111111111112',
value: transferAmount
})
console.log('Estimated fee:', quote.fee, 'lamports')
const result = await account.sendTransaction({
to: '11111111111111111111111111111112',
value: transferAmount
})
console.log('Transaction hash:', result.hash)
console.log('Fee paid:', result.fee, 'lamports')
return result
}Next Steps
To transfer SPL tokens instead of native SOL, see Transfer SPL Tokens.