Skip to main content

Overview

Setting the right gas parameters ensures your transactions are processed efficiently and cost-effectively on Paxeer Network.

Gas Parameters

EIP-1559 transactions on Paxeer Network use these gas parameters:
gasLimit
uint256
required
Maximum amount of gas you’re willing to consume
maxFeePerGas
uint256
required
Maximum total gas price you’re willing to pay (base + priority)
maxPriorityFeePerGas
uint256
required
Maximum tip you’re willing to pay to the sequencer

Setting Gas Limit

The gas limit is the maximum amount of gas your transaction can consume.

Best Practices

Always estimate gas before setting the limit:
const gasEstimate = await provider.estimateGas(tx);
const gasLimit = gasEstimate * 120n / 100n; // Add 20% buffer
Add 10-20% buffer to handle minor variations:
Transaction TypeRecommended Buffer
Simple transfers10%
Token transfers15%
Complex contracts20%
DeFi interactions25%
While unused gas is refunded, setting the limit too high:
  • Requires more PAX in your wallet upfront
  • May trigger wallet warnings
  • Can indicate poorly optimized contracts

Common Gas Limits

OperationTypical GasWith Buffer
ETH transfer21,00025,000
ERC-20 transfer65,00078,000
ERC-20 approve45,00054,000
Uniswap swap150,000180,000
NFT mint200,000240,000

Setting Max Fee Per Gas

The maxFeePerGas is the absolute maximum you’re willing to pay per gas unit.
1

Get Current Base Fee

const feeData = await provider.getFeeData();
const currentBaseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
2

Add Buffer for Base Fee Increases

// Base fee can increase up to 12.5% per block
// For 5 blocks safety: 1.125^5 ≈ 1.8
const maxBaseFee = currentBaseFee * 2n; // 100% buffer
3

Add Priority Fee

const priorityFee = feeData.maxPriorityFeePerGas;
const maxFeePerGas = maxBaseFee + priorityFee;

Example Implementation

async function calculateOptimalMaxFee() {
  const feeData = await provider.getFeeData();
  
  // Current fees
  const currentBaseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
  const priorityFee = feeData.maxPriorityFeePerGas;
  
  // Add 100% buffer to base fee
  const maxBaseFee = currentBaseFee * 2n;
  
  // Calculate max fee per gas
  const maxFeePerGas = maxBaseFee + priorityFee;
  
  return {
    maxFeePerGas,
    maxPriorityFeePerGas: priorityFee,
  };
}

// Usage
const fees = await calculateOptimalMaxFee();
const tx = await signer.sendTransaction({
  to: '0x...',
  value: ethers.parseEther('1.0'),
  maxFeePerGas: fees.maxFeePerGas,
  maxPriorityFeePerGas: fees.maxPriorityFeePerGas,
});

Setting Priority Fee

The priority fee (tip) incentivizes the sequencer to include your transaction faster.

Priority Levels

When to use: Non-urgent transactions
const priorityFee = 0n; // or 1 gwei minimum
  • Speed: May take several blocks
  • Cost: Minimal
  • Use case: Batch operations, non-time-sensitive transfers

Legacy vs EIP-1559 Transactions

Complete Transaction Example

SendOptimizedTransaction.ts
import { ethers } from 'ethers';

async function sendOptimizedTransaction(to: string, value: bigint) {
  const provider = new ethers.JsonRpcProvider('https://public-rpc.paxeer.app/rpc');
  const signer = await provider.getSigner();

  // 1. Estimate gas
  const tx = { to, value };
  const gasEstimate = await provider.estimateGas(tx);
  const gasLimit = gasEstimate * 120n / 100n; // 20% buffer

  // 2. Get fee data
  const feeData = await provider.getFeeData();
  
  // 3. Calculate optimal fees
  const currentBaseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
  const maxBaseFee = currentBaseFee * 2n; // 100% buffer
  const priorityFee = feeData.maxPriorityFeePerGas;
  const maxFeePerGas = maxBaseFee + priorityFee;

  // 4. Estimate cost
  const estimatedCost = gasLimit * (currentBaseFee + priorityFee);
  
  console.log('Transaction Details:');
  console.log('- Gas Limit:', gasLimit.toString());
  console.log('- Max Fee:', ethers.formatUnits(maxFeePerGas, 'gwei'), 'gwei');
  console.log('- Priority Fee:', ethers.formatUnits(priorityFee, 'gwei'), 'gwei');
  console.log('- Estimated Cost:', ethers.formatEther(estimatedCost), 'PAX');

  // 5. Send transaction
  const txResponse = await signer.sendTransaction({
    to,
    value,
    gasLimit,
    maxFeePerGas,
    maxPriorityFeePerGas: priorityFee,
  });

  console.log('Transaction sent:', txResponse.hash);
  
  // 6. Wait for confirmation
  const receipt = await txResponse.wait();
  
  // 7. Calculate actual cost
  const actualCost = receipt.gasUsed * receipt.gasPrice;
  console.log('Actual Cost:', ethers.formatEther(actualCost), 'PAX');
  
  return receipt;
}

Network-Specific Considerations

Paxeer Network Specifics

ParameterValueNotes
Average Base Fee~1 gweiMuch lower than Ethereum
Block Time~2 secondsFaster than Ethereum’s 12 seconds
Block Gas Limit30MSame as Ethereum
Max Base Fee Change12.5% per blockEIP-1559 standard

Fee Estimation Formula

// Minimum balance needed
const minBalance = (gasLimit × maxFeePerGas) + value;

// Likely actual cost (optimistic)
const likelyCost = (gasLimit × currentBaseFee) + (gasUsed × priorityFee);

// Maximum possible cost (pessimistic)
const maxCost = gasLimit × maxFeePerGas;

Error Prevention

Common mistakes to avoid:
  1. Setting gasLimit too low → Transaction fails
  2. Setting maxFeePerGas too low → Transaction stuck in mempool
  3. Not adding buffer to estimates → Transaction may fail
  4. Using stale fee data → Overpaying or stuck transactions

Next Steps