Fee Estimator Streaming
stream::fee_estimator::enable
Using this method, you can enable the fee estimation stream. For requesting fee estimates without streaming, use get_eth_estimated_fee_per_gas.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| client_id | integer | ✓ | This ID can be used to access data (e.g. via http://localhost:7783/event-stream?id=1) |
| coin | string | ✓ | The coin or token to enable the fee estimation stream for. |
Response Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| streamer_id | string | – | An identifier for the data stream. This can be used later to disable streaming for the event with stream::disable. |
📌 Examples
{
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","method":"stream::fee_estimator::enable","mmrpc":"2.0","params":{"client_id":1,"coin":"MATIC","config":{"estimate_every":33.4,"estimator_type":"Provider"}}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::fee_estimator::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"coin": "MATIC",
"config": {
"estimate_every": 33.4,
"estimator_type": "Provider"
}
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
{
"mmrpc": "2.0",
"result": {
"streamer_id": "FEE_ESTIMATION:MATIC"
},
"id": null
} Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 at each estimate interval:
data: {"_type":"FEE_ESTIMATION:MATIC","message":{"base_fee":"0.000000281","low":{"max_priority_fee_per_gas":"30","max_fee_per_gas":"30.000000309","min_wait_time":null,"max_wait_time":null},"medium":{"max_priority_fee_per_gas":"32.633147189","max_fee_per_gas":"32.633147519","min_wait_time":null,"max_wait_time":null},"high":{"max_priority_fee_per_gas":"38.9999999","max_fee_per_gas":"39.000000251","min_wait_time":null,"max_wait_time":null},"source":"simple","base_fee_trend":"","priority_fee_trend":"","units":"Gwei"}}
Error Types
| Parameter | Type | Required | Description |
|---|---|---|---|
| CoinNotFound | string | – | The specified coin was not found or is not activated yet |
| CoinNotSupported | string | – | Currently only EVM coins/tokens support fee estimation |
| UnknownClient | string | – | No client has an open connection using this client_id |
| ClientAlreadyListening | string | – | The requested events are already being sent to the client_id |
| InvalidRequest | string | – | Error parsing request or invalid configuration parameters |
Show Error Responses
Error Response (Coin Not Found)
{
"mmrpc": "2.0",
"error": "CoinNotFound",
"error_path": "fee_estimation",
"error_trace": "fee_estimation:42]",
"error_type": "CoinNotFound",
"id": null
}Error (Coin Not Supported)
{
"mmrpc": "2.0",
"error": "CoinNotSupported",
"error_path": "fee_estimation",
"error_trace": "fee_estimation:56]",
"error_type": "CoinNotSupported",
"id": null
}Error (Unknown Client)
{
"mmrpc": "2.0",
"error": "UnknownClient",
"error_path": "fee_estimation",
"error_trace": "fee_estimation:54]",
"error_type": "EnableError",
"error_data": "UnknownClient",
"id": null
}Error (Client Already Listening)
{
"mmrpc": "2.0",
"error": "ClientAlreadyListening",
"error_path": "fee_estimation",
"error_trace": "fee_estimation:54]",
"error_type": "EnableError",
"error_data": "ClientAlreadyListening",
"id": null
}Error (Invalid Request)
{
"mmrpc": "2.0",
"error": "Error parsing request: unknown variant `Complex`, expected `Simple` or `Provider`",
"error_path": "dispatcher",
"error_trace": "dispatcher:122]",
"error_type": "InvalidRequest",
"error_data": "unknown variant `Complex`, expected `Simple` or `Provider`",
"id": null
}