TriportRPC

getFeeForMessage

Last updated:

`getFeeForMessage` quotes the fee, in **lamports**, that the cluster will charge to land a given transaction message. You pass a compiled, base-64-encoded message (the transaction *without* its signatures), and the node computes the fee against a recent fee schedule and the blockhash embedded in the message.

Use this to show users an estimated cost before they sign and submit a transaction. The fee depends on the message contents (number of signatures, any compute-budget instructions) and on the network's current fee state, so quote it close to submission time rather than caching it.

The blockhash inside the message must still be valid. If it has expired, the node cannot price the message and `value` comes back `null` — re-fetch a recent blockhash, rebuild the message, and call again.

Parameters

getFeeForMessage parameters
NameTypeRequiredDescription
messagestringYes
configCommitmentConfigNo

Returns

getFeeForMessage return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"getFeeForMessage","params":["<message>","<config>"]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "getFeeForMessage",
  "params": [
    "<message>",
    "<config>"
  ],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"getFeeForMessage","params":["<message>","<config>"],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet, devnet, testnet.
  3. Credit cost: 1 per call.

FAQ

What does getFeeForMessage do?
Returns the fee, in lamports, that the network will charge to process a particular Solana message.
How many credits does getFeeForMessage cost?
getFeeForMessage costs 1 credit(s) per call on Triport by default.
Is getFeeForMessage available over WebSocket?
getFeeForMessage is an HTTP JSON-RPC method.