eth_maxPriorityFeePerGas - Base

The eth_maxPriorityFeePerGas method returns a suggested max priority fee per gas (tip) for EIP-1559 transactions. On Base, priority fees are typically low since the sequencer processes transactions in order of receipt.

Parameters

  • None

Request

cURL

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_maxPriorityFeePerGas",
    "params": [],
    "id": "getblock.io"
}'

Axios (JavaScript)

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_maxPriorityFeePerGas',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

const priorityFee = parseInt(response.data.result, 16);
console.log('Priority Fee:', priorityFee / 1e9, 'gwei');

Requests (Python)

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_maxPriorityFeePerGas',
        'params': [],
        'id': 'getblock.io'
    }
)

result = response.json()
priority_fee = int(result['result'], 16)
print(f'Priority Fee: {priority_fee / 1e9} gwei')

Rust (reqwest)

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "eth_maxPriorityFeePerGas",
            "params": [],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    println!("Priority Fee: {}", response["result"]);
    Ok(())
}

Response

Example Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0xf4240"
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultstringSuggested max priority fee per gas in wei (hex)

Use Cases

  1. Fee Estimation

    Get suggested priority fee for transactions.

  2. EIP-1559 Transactions

    Set appropriate priority fee.

  3. Cost Optimization

    Balance speed vs cost.

  4. Gas Strategies

    Implement dynamic fee strategies.

Error Handling

Error CodeMessageDescription
-32603Internal errorNode internal failure

Web3 Integration

Ethers.js (v6)

javascriptconst { ethers } = require('ethers');

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

async function getFeeData() {
    const feeData = await provider.getFeeData();
    
    console.log('Gas Price:', ethers.formatUnits(feeData.gasPrice, 'gwei'), 'gwei');
    console.log('Max Fee Per Gas:', ethers.formatUnits(feeData.maxFeePerGas, 'gwei'), 'gwei');
    console.log('Max Priority Fee:', ethers.formatUnits(feeData.maxPriorityFeePerGas, 'gwei'), 'gwei');
    
    return feeData;
}

getFeeData();

Viem

javascriptimport { createPublicClient, http, formatGwei } from 'viem';
import { base } from 'viem/chains';

const client = createPublicClient({
    chain: base,
    transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});

async function getMaxPriorityFee() {
    const { maxFeePerGas, maxPriorityFeePerGas } = await client.estimateFeesPerGas();
    
    console.log('Max Fee:', formatGwei(maxFeePerGas), 'gwei');
    console.log('Priority Fee:', formatGwei(maxPriorityFeePerGas), 'gwei');
    
    return { maxFeePerGas, maxPriorityFeePerGas };
}

getMaxPriorityFee();