Pharos Docs
  • Introduction
    • About Pharos Network
    • Vision & Mision
    • Why Pharos Network
    • Concepts
      • Degree of Parallelism (DP)
  • Architecture
    • Pharos Modular Stack
    • Node Architecture
      • About Pharos Nodes
  • Core Technologies
    • Pharos Consensus
    • Pharos Execution
      • Why A New Blockchain Compute Model
      • Pharos VM
    • Pharos Pipelining
    • Pharos Store
      • Why We Need a Blockchain-Native Store
    • Pharos SPNs
  • Network Overview
    • Pharos Networks
      • Pharos Testnet Information
    • Pharos Gas Model
    • FAQ
  • Node & Validator Guide
    • Validator Requirements
    • Validator Node Deployment
      • Using Docker (Devnet)
      • Using Docker (Testnet)
    • Node Management
    • Rapid Node Initialization
      • Rapid Node Initialization(Testnet)
      • Rapid Node Initialization(Devnet)
    • Pharos Network Snapshots
    • Node Debugging & Configuration
  • Pharos Node Monitoring
  • Developer Guide
    • Foundry
      • Write Your First dApp
      • Write Your First Token
      • Write Your First NFT
      • Write Your First Uniswap Contract
    • Hardhat
      • Write Your First dApp
      • Write Your First Token
      • Write Your First NFT
      • Write Your First Uniswap Contract
    • Rust
    • Interoperability
      • Call EVM From WASM
  • API & SDK
    • JSON-RPC API Methods
  • Resources
    • EVM
    • Solidity
Powered by GitBook
On this page
  • Overview
  • Summary Table
  • Best Practices for Developers
  • Conclusion
Export as PDF
  1. Network Overview

Pharos Gas Model

Understanding Gas Refund and Gas Limit in Pharos Transactions

Overview

When sending a transaction on Ethereum or an EVM-compatible blockchain, it is essential to set an appropriate gas limit to ensure successful execution. One common issue arises when the gas limit is set exactly equal to the gas used, particularly when the transaction involves a gas refund mechanism.

Summary Table

Feature

Details

Opcode pricing

EIP-1559 support

✅ Compatible (base fee + priority fee)

Base fee

Dynamic (will re-calculate per epoch)

Transaction fee model

Charged by gas_limit at inclusion time

Refund logic

Full EVM-style refund tracking supported, but refund does not affect charge

Best Practices for Developers

  • Set a slightly higher gas limit: Allow extra gas beyond the expected execution cost.

    • Example: If you expect 100,000 gas used before refund, set the gas limit to 120,000 to avoid failures.

  • Use Estimation APIs:

    • When sending transactions via Web3 libraries (ethers.js, web3.js), always use estimateGas() and add a buffer.

    • Example (ethers.js):

const estimatedGas = await contract.estimateGas.someFunction();
const gasLimit = estimatedGas.mul(12).div(10); // Adding a 20% buffer
await contract.someFunction({ gasLimit });
  • Monitor Gas Refund Logic:

    • If your contract relies heavily on gas refunds (e.g., clearing storage or SELFDESTRUCT), test transactions with different gas limits to find an optimal value.

  • Check for Out-of-Gas Failures:

    • If a transaction fails unexpectedly despite having enough gas, check whether gas refunds are affecting execution.

    • Debug with debug_traceTransaction or EVM logs.

Conclusion

To prevent transactions from failing due to gas refund issues, always set a gas limit slightly higher than the expected gas usage. This ensures smooth execution and prevents out-of-gas errors caused by refund mechanisms.

By following these best practices, developers can avoid failed transactions and improve the reliability of smart contract interactions.

PreviousPharos Testnet InformationNextFAQ

Last updated 21 days ago

Fully aligned with Ethereum EVM opcode

gas table