# eth_maxPriorityFeePerGas - Tempo RPC Method

Returns the current suggested priority fee (tip) per gas in wei on Tempo. This is the amount paid directly to validators to incentivize faster transaction inclusion in EIP-1559 compatible blocks.

> **Why Tempo?** Build on a payments-first EVM chain with deterministic settlement and stablecoin-native fees with no native gas token, fees denominated in supported USD stablecoins, and full EVM RPC compatibility.

## When to Use This Method

`eth_maxPriorityFeePerGas` is essential for payment application developers, wallet teams, stablecoin issuers, and treasury automation builders:

- **EIP-1559 Transaction Building** - Get the recommended tip to include in `maxPriorityFeePerGas` when constructing type-2 transactions on Tempo
- **Fee Optimization** - Balance transaction speed against cost by adjusting the priority fee relative to the suggested value
- **Time-Sensitive Transactions** - Increase the tip above the suggested value for DEX swaps, liquidations, or other latency-sensitive operations on merchant settlement, treasury operations, payout automation, and stablecoin-native financial applications
- **Gas Price Estimation** - Combine with `baseFeePerGas` from the latest block to calculate the total `maxFeePerGas` for accurate fee estimation

## Request Parameters

This method accepts no parameters.

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "eth_maxPriorityFeePerGas",
  "params": [],
  "id": 1
}
```

## Response Fields

- `result` (`QUANTITY, required`): Hexadecimal string representing the suggested priority fee per gas in wei

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x3B9ACA00"
}
```

## Error Responses

### Error Response

- Code: `-32601`

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "The method eth_maxPriorityFeePerGas does not exist/is not available"
  }
}
```

## Code Examples

cURL
JavaScript
Python
Go

```bash
curl -X POST https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_maxPriorityFeePerGas",
    "params": [],
    "id": 1
  }'
```

```javascript
// Using fetch
const response = await fetch('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'eth_maxPriorityFeePerGas',
    params: [],
    id: 1
  })
});

const { result } = await response.json();
const priorityFeeWei = BigInt(result);
const priorityFeeGwei = Number(priorityFeeWei) / 1e9;
console.log('Tempo priority fee:', priorityFeeGwei, 'Gwei');

// Using ethers.js
import { JsonRpcProvider, formatUnits } from 'ethers';

const provider = new JsonRpcProvider('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY');
const feeData = await provider.getFeeData();
console.log('Max Priority Fee:', formatUnits(feeData.maxPriorityFeePerGas, 'gwei'), 'Gwei');
console.log('Max Fee Per Gas:', formatUnits(feeData.maxFeePerGas, 'gwei'), 'Gwei');
```

```python
import requests

def get_max_priority_fee():
    response = requests.post(
        'https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY',
        json={
            'jsonrpc': '2.0',
            'method': 'eth_maxPriorityFeePerGas',
            'params': [],
            'id': 1
        }
    )
    result = response.json()['result']
    return int(result, 16)

priority_fee_wei = get_max_priority_fee()
priority_fee_gwei = priority_fee_wei / 1e9
print(f'Tempo priority fee: {priority_fee_gwei} Gwei')

# Using web3.py
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY'))
priority_fee = w3.eth.max_priority_fee
print(f'Max Priority Fee: {w3.from_wei(priority_fee, "gwei")} Gwei')
```

```go
package main

import (
    "context"
    "fmt"
    "log"
    "math/big"

    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, err := ethclient.Dial("https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY")
    if err != nil {
        log.Fatal(err)
    }

    tip, err := client.SuggestGasTipCap(context.Background())
    if err != nil {
        log.Fatal(err)
    }

    gwei := new(big.Float).Quo(new(big.Float).SetInt(tip), big.NewFloat(1e9))
    fmt.Printf("Tempo priority fee: %s Gwei\n", gwei.Text('f', 4))
}
```

## Common Use Cases

### 1. Build an EIP-1559 Transaction

Construct a properly priced type-2 transaction on Tempo:

```javascript
import { JsonRpcProvider, Wallet, parseEther } from 'ethers';

const provider = new JsonRpcProvider('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY');

async function buildEIP1559Transaction(privateKey, to, valueEth) {
  const wallet = new Wallet(privateKey, provider);

  // Get current fee data
  const feeData = await provider.getFeeData();
  const latestBlock = await provider.getBlock('latest');
  const baseFee = latestBlock.baseFeePerGas;

  // Set maxPriorityFeePerGas from the suggestion
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;

  // maxFeePerGas = 2 * baseFee + maxPriorityFeePerGas (buffer for base fee increases)
  const maxFeePerGas = baseFee * 2n + maxPriorityFeePerGas;

  const tx = await wallet.sendTransaction({
    to,
    value: parseEther(valueEth),
    type: 2,
    maxPriorityFeePerGas,
    maxFeePerGas
  });

  console.log('Sent with priority fee:', Number(maxPriorityFeePerGas) / 1e9, 'Gwei');
  return tx;
}
```

### 2. Dynamic Fee Strategy

Adjust priority fees based on transaction urgency:

```javascript
async function getFeeByUrgency(provider, urgency = 'standard') {
  const feeData = await provider.getFeeData();
  const basePriorityFee = feeData.maxPriorityFeePerGas;

  const multipliers = {
    low: 0.8,       // Willing to wait
    standard: 1.0,  // Normal speed
    fast: 1.5,      // Faster inclusion
    urgent: 2.0     // Next-block target
  };

  const multiplier = multipliers[urgency] || 1.0;
  const adjustedFee = BigInt(Math.ceil(Number(basePriorityFee) * multiplier));

  const block = await provider.getBlock('latest');
  const maxFeePerGas = block.baseFeePerGas * 2n + adjustedFee;

  return {
    maxPriorityFeePerGas: adjustedFee,
    maxFeePerGas
  };
}

// Usage
const fees = await getFeeByUrgency(provider, 'fast');
console.log('Priority fee:', Number(fees.maxPriorityFeePerGas) / 1e9, 'Gwei');
console.log('Max fee:', Number(fees.maxFeePerGas) / 1e9, 'Gwei');
```

### 3. Priority Fee Monitor

Track priority fee changes over time on Tempo:

```javascript
async function monitorPriorityFee(provider, interval = 12000) {
  let previousFee = null;

  setInterval(async () => {
    const feeData = await provider.getFeeData();
    const currentFee = feeData.maxPriorityFeePerGas;
    const feeGwei = Number(currentFee) / 1e9;

    if (previousFee !== null) {
      const change = Number(currentFee - previousFee) / Number(previousFee) * 100;
      const direction = change > 0 ? 'UP' : change < 0 ? 'DOWN' : 'STABLE';
      console.log(`Priority fee: ${feeGwei.toFixed(4)} Gwei (${direction} ${Math.abs(change).toFixed(1)}%)`);
    } else {
      console.log(`Priority fee: ${feeGwei.toFixed(4)} Gwei`);
    }

    previousFee = currentFee;
  }, interval);
}
```

## Best Practices

- Use `eth_feeHistory` with percentile rewards for a more accurate priority fee estimate than the node's suggestion alone
- The suggested priority fee is the minimum for timely inclusion -- multiply by 1.5-2x for faster confirmation on congested networks
- Fall back to `eth_gasPrice` if `eth_maxPriorityFeePerGas` returns method not found (-32601) on non-EIP-1559 nodes
- For L2 chains, the priority fee is typically much lower than L1 -- never reuse L1 gas parameters on L2
- Cache with a short TTL (12 seconds, one block time) since priority fees change with each block

## Related Methods

- [`eth_gasPrice`](https://www.dwellir.com/docs/tempo/eth_gasPrice) - Get the legacy gas price
- [`eth_feeHistory`](https://www.dwellir.com/docs/tempo/eth_feeHistory) - Get historical fee data for trend analysis
- [`eth_estimateGas`](https://www.dwellir.com/docs/tempo/eth_estimateGas) - Estimate gas units required for a transaction
- [`eth_getBlockByNumber`](https://www.dwellir.com/docs/tempo/eth_getBlockByNumber) - Get block details including `baseFeePerGas`
