# eth_maxPriorityFeePerGas - Base

> Example code for the eth_maxPriorityFeePerGas JSON-RPC method. Complete guide on how to use eth_maxPriorityFeePerGas JSON-RPC in GetBlock Web3 documentation.

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

#### cURL

```bash
curl --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

#### Axios (JavaScript)

```javascript
const 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');
```

#### Request

#### Requests (Python)

```python
import 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

#### Rust (reqwest)

```rust
use 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

| Parameter | Type | Description |
| --- | --- | --- |
| jsonrpc | string | JSON-RPC protocol version ("2.0") |
| id | string | Request identifier matching the request |
| result | string | Suggested max priority fee per gas in wei (hex) |

## Use Cases

### Fee Estimation

Get suggested priority fee for transactions.

### EIP-1559 Transactions

Set appropriate priority fee.

### Cost Optimization

Balance speed vs cost.

### Gas Strategies

Implement dynamic fee strategies.

## Error Handling

| Error Code | Message | Description |
| --- | --- | --- |
| -32603 | Internal error | Node internal failure |

## Web3 Integration

#### Ethers.js

#### Ethers.js (v6)

```javascript
const { 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

#### Viem

```javascript
import { 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();
```
