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
Parameters
bericht
tekenreeks
VERPLICHT
Bezig met laden...
object
object
Bezig met laden...
commitment
tekenreeks
Bezig met laden...
finalized
tekenreeks
Bezig met laden...
confirmed
tekenreeks
Bezig met laden...
processed
tekenreeks
Bezig met laden...
maxSupportedTransactionVersion
getal
Bezig met laden...
Retourzendingen
resultaat
Bezig met laden...
context
Bezig met laden...
apiVersion
Bezig met laden...
slot
Bezig met laden...
waarde
Bezig met laden...
Verzoek
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'
1vereisen "uri"2vereisen "json"3vereisen "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.nieuw(url.host, url.poort)8https.use_ssl = true910verzoek = Netto::HTTP::POST.nieuw(url)11verzoek["Content-Type"] = "application/json"12verzoek.tekst = JSON.dump({13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324antwoord = https.verzoek(verzoek)25geeft het antwoord weer.read_body26
1vereisen "uri"2vereisen "json"3vereisen "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.nieuw(url.host, url.poort)8https.use_ssl = true910verzoek = Netto::HTTP::POST.nieuw(url)11verzoek["Content-Type"] = "application/json"12verzoek.tekst = JSON.dump({13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324antwoord = https.verzoek(verzoek)25geeft het antwoord weer.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
Antwoord
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}
Heb je nog geen account?
Maak binnen enkele seconden je Quicknode-eindpunt aan en ga aan de slag
Ga gratis aan de slag