Free lesson · On-chain markets
Transaction gas in a reporting currency
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Gas is a resource charge paid in the chain’s native asset. Dollar cost depends on both the paid gas price and native-asset value.
Symbols, units & horizon
- G: gas units actually used
- g: effective gas price in gwei per gas
- 10^-9: native token per gwei
- P_N: USD/native token price at accounting time
- C_USD: execution-gas cost USD
When and why to use this
Compare on-chain routes in net dollars and include reverted attempts in research accounting.
Gas is a resource charge paid in the chain’s native asset. Dollar cost depends on both the paid gas price and native-asset value.
Use actual gas used, not the maximum gas limit, when accounting for a completed transaction. Under a simple execution-gas model multiply gas used by effective gas price.
This example excludes additional data-availability or layer-specific fees; record them as separate charges when applicable. A reverted transaction may still consume paid execution resources, so failed attempts belong in strategy costs.
Transaction gas in a reporting currency
- Multiply gas units by gwei per gas to get gwei paid.
- Convert gwei into native-token units using 10^-9.
- Multiply by native-token dollar price and add other fee types separately.
150,000 gas at 20 gwei is .003 native tokens. At $2,000/native token the execution-gas bill is $6.
Apply it in a strategy
- Compare on-chain routes in net dollars and include reverted attempts in research accounting.
- Record the input timestamp, executable quantity, currency and horizon. Reconcile the result with a cash-flow or state table.
- Stress this failure condition: Gas limit is not actual gas used, and execution gas may be only one part of total network fees.
Research deliverable
Build and explain a transaction gas in a reporting currency worksheet. Compare on-chain routes in net dollars and include reverted attempts in research accounting.
Evidence boundary: Synthetic arithmetic and scenarios illustrate mechanics. They are not historical returns, a paper replication, or evidence of an executable edge. Research sources and their access limitations are recorded at the end of this module.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
# Python 3.10+; standard library unless NumPy is imported below.
# Inputs and outputs use the units defined in this lesson. Synthetic teaching example.
def gas_dollars(gas_used,gwei,native_usd):
if min(gas_used,gwei,native_usd)<0: raise ValueError("Nonnegative gas inputs required")
return gas_used*gwei*1e-9*native_usd
print(gas_dollars(150000,20,2000))Continue learning
On-Chain Markets: Data, Oracles and Execution — all lessons- Raw token amounts and economic event types
- Transaction gas in a reporting currency
- Minimum output and ordering risk
- Time-weighted reference prices
- Stale oracle health versus executable collateral value
- Bridge fragmentation and capital lock-up
- Inclusion, finality and conditional loss scenarios
- A reproducible on-chain economics study
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations