<<<<<<< HEAD
Real-time gas price tracker and fee estimator for Optimism L2 network.
Real-time gas price tracker and fee estimator for Optimism L2 network. Monitor L1 data fees, L2 execution costs, and get accurate transaction cost predictions.
- Real-time Gas Monitoring: Track L1 and L2 gas prices updated every block
- Fee Estimation: Calculate accurate transaction costs including L1 data fees
- Historical Data: Access gas price history and statistics
- REST API: Easy-to-use endpoints for integration
- Optimism-Specific: Built specifically for OP Stack chains with proper L1 fee calculation
API is live at: https://op-gas-tracker-production.up.railway.app
https://op-gas-tracker-production.up.railway.app
GET /Returns API information and available endpoints.
Example Response:
{
"name": "OP Gas Tracker",
"version": "1.0.0",
"status": "running",
"message": "Gas tracker API is operational",
"endpoints": {
"health": "/health",
"current": "/gas/current (coming soon)",
"history": "/gas/history (coming soon)",
"stats": "/gas/stats (coming soon)"
}
}GET /healthReturns service health status.
Example Response:
{
"status": "ok",
"uptime": 125.39,
"timestamp": "2025-05-25T15:30:00.000Z"
}GET /gas/currentReturns current gas price information (demo data for now).
Example Response:
{
"message": "This endpoint will return current gas prices",
"l1BaseFee": "30.5",
"l2GasPrice": "0.001",
"timestamp": 1716742200000
}# Get API status
curl https://op-gas-tracker-production.up.railway.app/
# Check health
curl https://op-gas-tracker-production.up.railway.app/health
# Get current gas prices
curl https://op-gas-tracker-production.up.railway.app/gas/current// Get current gas prices
fetch('https://op-gas-tracker-production.up.railway.app/gas/current')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));import requests
# Get API status
response = requests.get('https://op-gas-tracker-production.up.railway.app/')
data = response.json()
print(data)const axios = require('axios');
async function getGasPrice() {
try {
const response = await axios.get('https://op-gas-tracker-production.up.railway.app/gas/current');
console.log(response.data);
} catch (error) {
console.error('Error:', error);
}
}
getGasPrice();- โ Basic API structure
- โ Health monitoring endpoints
- โ Live deployment on Railway
- ๐ Real-time gas price tracking (in progress)
- ๐ Historical data storage (planned)
- ๐ WebSocket support (planned)
- ๐ Multi-chain support (planned)
Optimism uses a unique fee model where users pay both:
- L2 execution fee: For computation on L2
- L1 data fee: For posting transaction data to Ethereum
This tool helps developers and users understand and optimize their transaction costs on Optimism.
# Clone the repository
git clone https://github.com/serayd61/op-gas-tracker.git
cd op-gas-tracker
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start# Run in development mode with hot reload
npm run devGET /gas/currentResponse:
{
"timestamp": 1703123456789,
"l1BaseFee": "35.5",
"l2GasPrice": "0.001",
"overhead": "188",
"scalar": "684000",
"estimatedL1DataFee": "0.000542",
"totalEstimatedFee": "0.000563"
}GET /gas/historyReturns last hour of gas price data (5-second intervals).
GET /gas/statsResponse:
{
"current": { ... },
"average": {
"l2GasPrice": "0.0012",
"l1DataFee": "0.000523"
},
"min": {
"l2GasPrice": "0.001",
"l1DataFee": "0.000421"
},
"max": {
"l2GasPrice": "0.0015",
"l1DataFee": "0.000651"
}
}GET /gas/estimate?to=0x...&data=0x...Query Parameters:
to: Target address (optional)data: Transaction data in hex (optional)
Create a .env file:
# RPC URL (optional, defaults to public endpoint)
RPC_URL=https://mainnet.optimism.io
# Server port (optional, defaults to 3000)
PORT=3000
# Update interval in ms (optional, defaults to 12000)
UPDATE_INTERVAL=12000src/
โโโ index.ts # Main server and API routes
โโโ gas-tracker.ts # Core gas tracking logic
โโโ types.ts # TypeScript interfaces
โโโ utils.ts # Helper functions
Optimism's L1 data fee formula:
L1_data_fee = (tx_data_size + overhead) * l1_base_fee * scalar / 10^decimals
This tool automatically calculates this for you!
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add WebSocket support for real-time updates
- Create web dashboard UI
- Add support for other OP Stack chains (Base, Zora, etc.)
- Implement gas price predictions
- Add transaction batching optimizer
- Create npm package for easy integration
This project is licensed under the MIT License - see the LICENSE file for details.
serayd61
- GitHub: @serayd61
- Project: OP Stack Bridge Dashboard
Real-time gas price tracker for Optimism L2
4eae2e3d863c7d6d63d9572cbbbf231c4f0301ea
This project was created to address a real need in the Optimism ecosystem - transparent and accessible gas price monitoring. As part of my commitment to the OP Stack community, I'm continuously working on improvements and new features.
- Integration with multiple OP Stack chains (Base, Zora, Mode)
- Advanced analytics and predictions
- Developer SDK for easy integration
- Mobile app companion
Supporting the Optimism Collective ๐ดโจ