Parameters
- messagestringREQUIRED
The transaction message encoded as base64
- objectobject
The configuration object with the following fields:
- commitmentstring
The level of commitment required for the query. The options include:
- finalizedstring
The node will query the most recent block the cluster has recognized as finalized
- confirmedstring
The node will query the most recent block that has been voted on by the supermajority of the cluster
- processedstring
The node will query its most recent block. Note that the block may not be complete
- maxSupportedTransactionVersioninteger
The maximum transaction version to return, as a JSON integer.
Returns
- result
Null if the transaction message is not found otherwise RpcResponse JSON object with the following fields:
- context
The information about the current state of the program
- apiVersion
The version of the Solana RPC API to use
- slot
An integer representing the slot for which to retrieve the fee calculator
- value
(u64 | null) The fee corresponding to the message at the specified blockhash
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 = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324response = https.request(request)25puts response.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 = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"id": 1,14"jsonrpc": "2.0",15"method": "getFeeForMessage",16"params": [17"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",18{19"commitment": "processed"20}21]22})2324response = https.request(request)25puts response.read_body26
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/");4const { blockhash } = await solana.getLatestBlockhash();5const payer = new web3.PublicKey("6dJw4BELW3gqDYRoVFohivS1Fp1yZGeXwHQhMhsEAPsf");6const YOUR_TRANSACTION = new web3.Transaction({7recentBlockhash: blockhash,8feePayer: payer,9}).add(10web3.SystemProgram.transfer({11fromPubkey: payer,12toPubkey: payer,13lamports: 1000,14})15);16const YOUR_MESSAGE = YOUR_TRANSACTION.compileMessage();17console.log(await solana.getFeeForMessage(YOUR_MESSAGE));18})();
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/");4const { blockhash } = await solana.getLatestBlockhash();5const payer = new web3.PublicKey("6dJw4BELW3gqDYRoVFohivS1Fp1yZGeXwHQhMhsEAPsf");6const YOUR_TRANSACTION = new web3.Transaction({7recentBlockhash: blockhash,8feePayer: payer,9}).add(10web3.SystemProgram.transfer({11fromPubkey: payer,12toPubkey: payer,13lamports: 1000,14})15);16const YOUR_MESSAGE = YOUR_TRANSACTION.compileMessage();17console.log(await solana.getFeeForMessage(YOUR_MESSAGE));18})();
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();
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
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'getFeeForMessage',7[8"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",9{10"commitment": "processed"11}12],13undefined,14'https://docs-demo.solana-mainnet.quiknode.pro/'15)1617console.log(result)
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'getFeeForMessage',7[8"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",9{10"commitment": "processed"11}12],13undefined,14'https://docs-demo.solana-mainnet.quiknode.pro/'15)1617console.log(result)
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"getFeeForMessage",8[9"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",10{11"commitment": "processed"12}13],14endpoint_url="https://docs-demo.solana-mainnet.quiknode.pro/",15)16print(result)1718asyncio.run(main())
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"getFeeForMessage",8[9"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",10{11"commitment": "processed"12}13],14endpoint_url="https://docs-demo.solana-mainnet.quiknode.pro/",15)16print(result)1718asyncio.run(main())
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6method: "getFeeForMessage",7params: [8"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",9{10"commitment" => "processed"11}12],13endpoint_url: "https://docs-demo.solana-mainnet.quiknode.pro/"14)1516puts result
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6method: "getFeeForMessage",7params: [8"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",9{10"commitment" => "processed"11}12],13endpoint_url: "https://docs-demo.solana-mainnet.quiknode.pro/"14)1516puts result
1use quicknode_sdk::{QuicknodeSdk, SdkFullConfig};23#[tokio::main]4async fn main() -> Result<(), Box<dyn std::error::Error>> {5let qn = QuicknodeSdk::new(&SdkFullConfig::keyless())?;6let result = qn7.rpc8.call(9"getFeeForMessage",10Some(serde_json::json!([11"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",12{13"commitment": "processed"14}15])),16None,17Some("https://docs-demo.solana-mainnet.quiknode.pro/".into()),18)19.await?;2021println!("{result}");22Ok(())23}
1use quicknode_sdk::{QuicknodeSdk, SdkFullConfig};23#[tokio::main]4async fn main() -> Result<(), Box<dyn std::error::Error>> {5let qn = QuicknodeSdk::new(&SdkFullConfig::keyless())?;6let result = qn7.rpc8.call(9"getFeeForMessage",10Some(serde_json::json!([11"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",12{13"commitment": "processed"14}15])),16None,17Some("https://docs-demo.solana-mainnet.quiknode.pro/".into()),18)19.await?;2021println!("{result}");22Ok(())23}
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}