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
Parameter
Nachricht
Zeichenkette
ERFORDERLICH
Wird geladen...
Objekt
Objekt
Wird geladen...
commitment
Zeichenkette
Wird geladen...
finalized
Zeichenkette
Wird geladen...
confirmed
Zeichenkette
Wird geladen...
processed
Zeichenkette
Wird geladen...
maxSupportedTransactionVersion
Zahl
Wird geladen...
Rücksendungen
Ergebnis
Wird geladen...
context
Wird geladen...
apiVersion
Wird geladen...
Steckplatz
Wird geladen...
Wert
Wird geladen...
Anfrage
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.host, URL.Port)8https.use_ssl = true910Anfrage = Netto::HTTP::POST.new(URL)11Anfrage[„Content-Type“] = „application/json“12Anfrage.Inhalt = JSON.dump({13„id“: 1,14„jsonrpc“: "2.0",15"method": "getFeeForMessage",16„params“: [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324Antwort = https.Anfrage(Anfrage)25gibt die Antwort aus.read_body26
1require "uri"2require "json"3require „net/http“45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.host, URL.Port)8https.use_ssl = true910Anfrage = Netto::HTTP::POST.new(URL)11Anfrage[„Content-Type“] = „application/json“12Anfrage.Inhalt = JSON.dump({13„id“: 1,14„jsonrpc“: "2.0",15"method": "getFeeForMessage",16„params“: [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324Antwort = https.Anfrage(Anfrage)25gibt die Antwort aus.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;8try {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;8try {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.Connection("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.Connection("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 = 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 = Client("https://docs-demo.solana-mainnet.quiknode.pro/")8print(solana_client.get_fee_for_message(txn.compile_message()))
1use reqwest::header;2use reqwest::Client;3use std::error::Error;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut headers = header::HeaderMap::new();8headers.insert("Content-Type", "application/json".parse().unwrap());910let client = 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 response = client25.post("https://docs-demo.solana-mainnet.quiknode.pro/")26.headers(headers)27.body(json_data)28.send()29.await?;3031let body = response.text().await?;32println!("{}", body);3334Ok(())35}36
1use reqwest::header;2use reqwest::Client;3use std::error::Error;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut headers = header::HeaderMap::new();8headers.insert("Content-Type", "application/json".parse().unwrap());910let client = 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 response = client25.post("https://docs-demo.solana-mainnet.quiknode.pro/")26.headers(headers)27.body(json_data)28.send()29.await?;3031let body = response.text().await?;32println!("{}", body);3334Ok(())35}36
Antwort
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}
Haben Sie noch kein Konto?
Erstellen Sie Ihren Quicknode-Endpunkt in Sekundenschnelle und legen Sie los
Kostenlos loslegen