The Solana documentation says
Transactions currently include a fee field that indicates the maximum fee field a slot leader is permitted to charge to process a transaction.
(source: https://docs.solana.com/implemented-proposals/transaction-fees)
But in @solana/web3.js
, the transaction builder SystemProgram.transfer
only takes a from, to and amount. There is a fee calculator interface and a getEstimatedFee
method in the transfer object, but I can't find how to set the maximum.
You don't need to specify a fee because as of now there is no eth-like fee market in Solana where people bid to get their tx included. In future, this is subject to change. To send a transfer transaction:
const transferTransaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: fromKeypair.publicKey,
toPubkey: toKeypair.publicKey,
lamports: lamportsToSend,
})
);
await sendAndConfirmTransaction(connection, transferTransaction, [fromKeypair]);
https://solanacookbook.com/references/basic-transactions.html#how-to-send-sol