getFees

Deprecated: This method is deprecated. Use getFeeForMessage and getLatestBlockhash instead.

Returns a recent block hash from the ledger, a fee schedule that can be used to compute the cost of submitting a transaction, and the last slot in which the blockhash will be valid. This method has been deprecated in favor of the combination of getLatestBlockhash and getFeeForMessage, which provide a cleaner separation of concerns and support for the newer fee model.

Parameters

#TypeRequiredDescription
1objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
commitmentstringCommitment level: processed, confirmed, or finalized

Response

Returns an RpcResponse object:

FieldTypeDescription
context.slotu64The slot at which the fees were read
value.blockhashstringA recent blockhash
value.feeCalculator.lamportsPerSignatureu64Fee per signature in lamports
value.lastValidSlotu64Last slot in which the blockhash will be valid
value.lastValidBlockHeightu64Last block height at which the blockhash will be valid

Code Examples

cURL

1curl http://[IP_ADDRESS]:[PORT] -X POST -H "Content-Type: application/json" -d '{
2  "jsonrpc": "2.0",
3  "id": 1,
4  "method": "getFees",
5  "params": []
6}'

TypeScript

1const response = await fetch("http://[IP_ADDRESS]:[PORT]", {
2  method: "POST",
3  headers: { "Content-Type": "application/json" },
4  body: JSON.stringify({
5    jsonrpc: "2.0",
6    id: 1,
7    method: "getFees",
8    params: []
9  }),
10});
11const { result } = await response.json();
12console.log("Blockhash:", result.value.blockhash);

Python

1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4    "jsonrpc": "2.0",
5    "id": 1,
6    "method": "getFees",
7    "params": []
8})
9result = response.json()["result"]
10print(f"Blockhash: {result['value']['blockhash']}")

Rust

1use reqwest::Client;
2use serde_json::json;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let client = Client::new();
7    let res = client.post("http://[IP_ADDRESS]:[PORT]")
8        .json(&json!({
9            "jsonrpc": "2.0",
10            "id": 1,
11            "method": "getFees",
12            "params": []
13        }))
14        .send().await?
15        .text().await?;
16    println!("{}", res);
17    Ok(())
18}

Example Response

1{
2  "jsonrpc": "2.0",
3  "result": {
4    "context": { "slot": 123456789 },
5    "value": {
6      "blockhash": "GJxqhuxcgfn5Tcj6y3f8X4FeCDd2RQ6SnEMo1AAxrPRZ",
7      "feeCalculator": { "lamportsPerSignature": 5000 },
8      "lastValidSlot": 123456939,
9      "lastValidBlockHeight": 150676181
10    }
11  },
12  "id": 1
13}