[英]How to specify max fee in @solana/web3.js Transaction
The Solana documentation says Solana 文档说
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 ) (来源: 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.但是在
@solana/web3.js
中,事务构建器SystemProgram.transfer
只需要一个 from、to 和 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.转账对象中有一个费用计算器接口和一个
getEstimatedFee
方法,但是我找不到如何设置最大值。
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.您不需要指定费用,因为到目前为止,在 Solana 中没有类似 eth 的费用市场,人们竞标将他们的 tx 包括在内。 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 https://solanacookbook.com/references/basic-transactions.html#how-to-send-sol
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.