Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsPlasmaJSON-RPC APITransaction Methods

eth_maxPriorityFeePerGas - Plasma RPC Method

Get the suggested priority fee (tip) per gas for EIP-1559 transactions on Plasma. Essential for gas estimation, fee optimization, and time-sensitive transaction pricing.

Plasma RPC endpoint: endpoint URLs, plans and pricing.

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

Why Plasma? Build on an EVM Layer 1 for stablecoin payments with PlasmaBFT consensus and Reth execution with 1 second blocks, XPL gas, full EVM JSON-RPC, and debug plus txpool on Dwellir.

When to Use This Method

eth_maxPriorityFeePerGas is essential for payment app developers, wallet teams, and teams shipping Solidity contracts for dollar transfers:

  • EIP-1559 Transaction Building - Get the recommended tip to include in maxPriorityFeePerGas when constructing type-2 transactions on Plasma
  • 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 stablecoin transfers, payment apps, and wallets that need 1 second confirmation
  • Gas Price Estimation - Combine with baseFeePerGas from the latest block to calculate the total maxFeePerGas for accurate fee estimation
JSON-RPC request
{
  "jsonrpc": "2.0",
  "method": "eth_maxPriorityFeePerGas",
  "params": [],
  "id": 1
}

Code Examples

Common Use Cases

1. Build an EIP-1559 Transaction

Construct a properly priced type-2 transaction on Plasma:

JavaScript
import { JsonRpcProvider, Wallet, parseEther } from 'ethers';

const provider = new JsonRpcProvider('https://api-plasma-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 Plasma:

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

Error Handling

Common errors and solutions:

Error CodeDescriptionSolution
-32601Method not foundThe node may not support EIP-1559 - fall back to eth_gasPrice
-32603Internal errorRetry with exponential backoff
-32005Rate limit exceededImplement rate limiting and caching client-side
JavaScript
async function getSafePriorityFee(provider, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      const feeData = await provider.getFeeData();
      if (feeData.maxPriorityFeePerGas !== null) {
        return feeData.maxPriorityFeePerGas;
      }
      // Fallback: derive from legacy gas price
      const gasPrice = await provider.send('eth_gasPrice', []);
      return BigInt(gasPrice);
    } catch (error) {
      if (error.code === -32601) {
        // EIP-1559 not supported - use legacy gas price
        const gasPrice = await provider.send('eth_gasPrice', []);
        return BigInt(gasPrice);
      }
      if (i === maxRetries - 1) throw error;
      await new Promise(r => setTimeout(r, Math.pow(2, i) * 1000));
    }
  }
}

Related Methods

  • eth_gasPrice - Get the legacy gas price
  • eth_feeHistory - Get historical fee data for trend analysis
  • eth_estimateGas - Estimate gas units required for a transaction
  • eth_getBlockByNumber - Get block details including baseFeePerGas

eth_gasPrice

Get current gas price on Plasma. Essential for transaction cost estimation for stablecoin transfers, payment apps, and wallets that need 1 second confirmation.

eth_feeHistory

Get historical gas fee data on Plasma including base fees and priority fee percentiles. Essential for gas price prediction, fee estimation UIs, and network congestion monitoring.

On this page

When to Use This MethodCode ExamplesCommon Use Cases1. Build an EIP-1559 Transaction2. Dynamic Fee Strategy3. Priority Fee MonitorBest PracticesError HandlingRelated Methods