Solana
Solana
Solana
Free tier covers personal projects. Pay-as-you-go scales without a card.
getFeeForMessage asks a Solana node what a specific transaction message will cost to land, pricing it against a recent blockhash and returning the answer in lamports (1 SOL = 1,000,000,000 lamports). You pass the base64-encoded message — the part of the transaction that the fee is calculated from — and the node replies with the exact lamport charge for that message, or null if the blockhash it was built on has already expired. Call it through the TheRPC Solana endpoint at https://solana.therpc.io/YOUR_API_KEY.
getFees flow: build the message, price it per-message here, and pair it with getRecentPrioritizationFees for any priority surcharge.| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | message | string | Yes | Base64-encoded transaction message. |
| 2 | config | object | No | Options: commitment, minContextSlot. |
| Type | Description |
|---|---|
| object | RpcResponse wrapping a u64 fee in lamports, or null if the blockhash has expired. |
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | A param is missing, of the wrong type, or malformed (e.g. a non-base58 pubkey or a bad config field). |
-32603 | Internal error | The node hit an internal error serving the request — retry, and reduce the requested range/encoding if it persists. |
Invalid params (-32602) response.null value in the wrapped result means the blockhash the message references has expired. Fetch a fresh one with getLatestBlockhash, rebuild the message, and price it again.