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:
Maximum amount of gas you’re willing to consume
Maximum total gas price you’re willing to pay (base + priority)
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 Type | Recommended Buffer |
| Simple transfers | 10% |
| Token transfers | 15% |
| Complex contracts | 20% |
| DeFi interactions | 25% |
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
| Operation | Typical Gas | With Buffer |
| ETH transfer | 21,000 | 25,000 |
| ERC-20 transfer | 65,000 | 78,000 |
| ERC-20 approve | 45,000 | 54,000 |
| Uniswap swap | 150,000 | 180,000 |
| NFT mint | 200,000 | 240,000 |
Setting Max Fee Per Gas
The maxFeePerGas is the absolute maximum you’re willing to pay per gas unit.
Recommended Strategy
Get Current Base Fee
const feeData = await provider.getFeeData();
const currentBaseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
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
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
Low Priority
Standard Priority
High Priority
When to use: Non-urgent transactionsconst priorityFee = 0n; // or 1 gwei minimum
- Speed: May take several blocks
- Cost: Minimal
- Use case: Batch operations, non-time-sensitive transfers
When to use: Normal transactionsconst priorityFee = await provider.send('eth_maxPriorityFeePerGas', []);
- Speed: Usually next block
- Cost: Average
- Use case: Regular transfers, most dApp interactions
When to use: Urgent transactionsconst recommendedFee = await provider.send('eth_maxPriorityFeePerGas', []);
const priorityFee = BigInt(recommendedFee) * 2n; // 2x recommended
- Speed: Very likely next block
- Cost: Higher
- Use case: MEV protection, arbitrage, time-sensitive operations
Legacy vs EIP-1559 Transactions
EIP-1559 (Recommended)
Legacy
Type 2 Transactions
Modern transaction type with better fee market:const tx = await signer.sendTransaction({
to: '0x...',
value: ethers.parseEther('1.0'),
maxFeePerGas: ethers.parseUnits('2', 'gwei'),
maxPriorityFeePerGas: ethers.parseUnits('1', 'gwei'),
});
Advantages:
- More predictable fees
- Better UX (only pay actual base fee)
- Automatic refunds for overpayment
Type 0 Transactions
Old-style transactions with single gas price:const tx = await signer.sendTransaction({
to: '0x...',
value: ethers.parseEther('1.0'),
gasPrice: ethers.parseUnits('2', 'gwei'),
});
Note: Still supported but EIP-1559 is preferred
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
| Parameter | Value | Notes |
| Average Base Fee | ~1 gwei | Much lower than Ethereum |
| Block Time | ~2 seconds | Faster than Ethereum’s 12 seconds |
| Block Gas Limit | 30M | Same as Ethereum |
| Max Base Fee Change | 12.5% per block | EIP-1559 standard |
// 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:
- Setting gasLimit too low → Transaction fails
- Setting maxFeePerGas too low → Transaction stuck in mempool
- Not adding buffer to estimates → Transaction may fail
- Using stale fee data → Overpaying or stuck transactions
Next Steps