getFeeForMessage RPC Method
Please note that this method is only available in solana-core v1.9 or newer. Please use getFees for solana-core v1.8
参数
消息
字符串
必填
正在加载...
对象
对象
正在加载...
承诺
字符串
正在加载...
已最终确定
字符串
正在加载...
已确认
字符串
正在加载...
已处理
字符串
正在加载...
maxSupportedTransactionVersion
数字
正在加载...
退货
结果
正在加载...
上下文
正在加载...
apiVersion
正在加载...
插槽
正在加载...
值
正在加载...
请求
1curl https://docs-demo.solana-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4-d '5{6"id":1,7"jsonrpc":"2.0",8"method":"getFeeForMessage",9"params":[10"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",11{12"commitment":"processed"13}14]15}16'
1curl https://docs-demo.solana-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4-d '5{6"id":1,7"jsonrpc":"2.0",8"method":"getFeeForMessage",9"params":[10"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",11{12"commitment":"processed"13}14]15}16'
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)11请求["Content-Type"] = "application/json"12请求.请求体 = JSON.dump({13"id": 1,14“jsonrpc”: "2.0",15"method": "getFeeForMessage",16“params”: [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324回复 = https.请求(请求)25返回响应.read_body26
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)11请求["Content-Type"] = "application/json"12请求.请求体 = JSON.dump({13"id": 1,14“jsonrpc”: "2.0",15"method": "getFeeForMessage",16“params”: [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324回复 = https.请求(请求)25返回响应.read_body26
1import { createSolanaRpc, GetFeeForMessageApi, Rpc, TransactionMessageBytesBase64 } from "@solana/kit";23async function getFeeForMessageExample() {45const rpc: Rpc<GetFeeForMessageApi> = createSolanaRpc("https://docs-demo.solana-mainnet.quiknode.pro/");67const message: TransactionMessageBytesBase64 = "AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA" as TransactionMessageBytesBase64;8试一试 {9const feeResult = await rpc.getFeeForMessage(message, { commitment: 'processed' }).send();10console.log("Fee for message:", feeResult);11} catch (error) {12console.error("Error:", error);13}14}1516getFeeForMessageExample();
1import { createSolanaRpc, GetFeeForMessageApi, Rpc, TransactionMessageBytesBase64 } from "@solana/kit";23async function getFeeForMessageExample() {45const rpc: Rpc<GetFeeForMessageApi> = createSolanaRpc("https://docs-demo.solana-mainnet.quiknode.pro/");67const message: TransactionMessageBytesBase64 = "AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA" as TransactionMessageBytesBase64;8试一试 {9const feeResult = await rpc.getFeeForMessage(message, { commitment: 'processed' }).send();10console.log("Fee for message:", feeResult);11} catch (error) {12console.error("Error:", error);13}14}1516getFeeForMessageExample();
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.连接(“https://docs-demo.solana-mainnet.quiknode.pro/”);4const YOUR_TRANSACTION = new Transaction();5const YOUR_MESSAGE = YOUR_TRANSACTION.compileMessage();6console.log(await solana.getFeeForMessage(YOUR_MESSAGE));7})();8
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.连接(“https://docs-demo.solana-mainnet.quiknode.pro/”);4const YOUR_TRANSACTION = new Transaction();5const YOUR_MESSAGE = YOUR_TRANSACTION.compileMessage();6console.log(await solana.getFeeForMessage(YOUR_MESSAGE));7})();8
1from solana.rpc.api import Client2from solana.keypair import Keypair3from solana.system_program import TransferParams, transfer4from solana.transaction import Transaction5sender, receiver = Keypair.from_seed(bytes(PublicKey(1))), Keypair.from_seed(bytes(PublicKey(2)))6txn = Transaction().add(transfer(TransferParams(from_pubkey=sender.public_key, to_pubkey=receiver.public_key, lamports=1000)))7solana_client = 客户端(“https://docs-demo.solana-mainnet.quiknode.pro/”)8print(solana_client.get_fee_for_message(txn.compile_message()))
1from solana.rpc.api import Client2from solana.keypair import Keypair3from solana.system_program import TransferParams, transfer4from solana.transaction import Transaction5sender, receiver = Keypair.from_seed(bytes(PublicKey(1))), Keypair.from_seed(bytes(PublicKey(2)))6txn = Transaction().add(transfer(TransferParams(from_pubkey=sender.public_key, to_pubkey=receiver.public_key, lamports=1000)))7solana_client = 客户端(“https://docs-demo.solana-mainnet.quiknode.pro/”)8print(solana_client.get_fee_for_message(txn.compile_message()))
1使用 reqwest::header;2使用 reqwest::客户端;3使用 std::error::错误;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut 头文件 = header::HeaderMap::new();8标题.插入("Content-Type", "application/json".parse().unwrap());910let 客户端 = Client::new();11let json_data = r#"12{13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22}23"#;24let 响应 = 客户端25.帖子(“https://docs-demo.solana-mainnet.quiknode.pro/”)26.标题(标题))27.正文(json_data)28.发送()29.await?;3031let 正文 = 响应.text().await?;32println!("{}", body);3334好的(())35}36
1使用 reqwest::header;2使用 reqwest::客户端;3使用 std::error::错误;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut 头文件 = header::HeaderMap::new();8标题.插入("Content-Type", "application/json".parse().unwrap());910let 客户端 = Client::new();11let json_data = r#"12{13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22}23"#;24let 响应 = 客户端25.帖子(“https://docs-demo.solana-mainnet.quiknode.pro/”)26.标题(标题))27.正文(json_data)28.发送()29.await?;3031let 正文 = 响应.text().await?;32println!("{}", body);3334好的(())35}36
回复
1{2“jsonrpc”: "2.0",3"result": {4"context": {5"apiVersion": "2.1.21",6"slot": 3355018187},8"value": null9},10"id": 111}
1{2“jsonrpc”: "2.0",3"result": {4"context": {5"apiVersion": "2.1.21",6"slot": 3355018187},8"value": null9},10"id": 111}