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
| Name | Type | Required | Description |
|---|---|---|---|
| message | string | Yes | |
| config | CommitmentConfig | No |
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"getFeeForMessage","params":["<message>","<config>"],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "getFeeForMessage",
"params": [
"<message>",
"<config>"
],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"getFeeForMessage","params":["<message>","<config>"],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet, devnet, testnet.
- 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.