Skip to content
pxlvrePublic

About

simulate, track, and optimise gas costs across EVM chains

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

21 Commits

Folders and files

Repository files navigation

boltzmann

Boltzmann Logo

boltzmann: gas and fee analytics for EVM chains

License Rust Build Status

Overview

Boltzmann is a REST API built with Rust, axum, and alloy-rs that provides insights into gas and fee costs for EVM blockchain transactions. Whether you're building a DeFi application, optimizing transaction timing, or simply want to understand gas dynamics, Boltzmann gives you the data you need to make informed decisions.

Key Features

  • Transaction Simulation: Simulate any EVM transaction (P2P transfers, ERC-20, NFTs, smart contract interactions, blob transactions)
  • Multi-Speed Analysis: Compare costs across different confirmation speeds (slow, average, fast)
  • EIP Support: Full compatibility with EIP-1559, EIP-3198, and EIP-4844
  • Multi-Currency Pricing: Get costs in native ETH or fiat currencies (USD, EUR, CHF, etc.)
  • Real-time Subscriptions: Monitor gas costs continuously with customizable intervals
  • Historical Analytics: Track gas price trends and optimize transaction timing
  • Multi-Chain Support: Works across all EVM-compatible networks

πŸ—οΈ Architecture

Boltzmann follows a domain-driven design with a modular Rust architecture:

boltzmann/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ domains/                 # Business logic domains
β”‚   β”‚   β”œβ”€β”€ crypto/             # Cryptocurrency price providers
β”‚   β”‚   β”‚   β”œβ”€β”€ coingecko.rs    # CoinGecko integration
β”‚   β”‚   β”‚   β”œβ”€β”€ coinmarketcap.rs # CoinMarketCap integration  
β”‚   β”‚   β”‚   └── mod.rs          # Core crypto types
β”‚   β”‚   └── gas/                # Gas price oracles
β”‚   β”‚       └── price/          # Gas price providers
β”‚   β”‚           β”œβ”€β”€ etherscan.rs # Etherscan gas oracle
β”‚   β”‚           β”œβ”€β”€ alloy.rs    # Alloy RPC gas oracle
β”‚   β”‚           └── mod.rs      # Gas oracle types
β”‚   β”œβ”€β”€ api/                    # HTTP layer
β”‚   β”‚   └── routes/             # API route handlers
β”‚   β”‚       β”œβ”€β”€ crypto.rs       # Crypto price endpoints
β”‚   β”‚       β”œβ”€β”€ gas.rs          # Gas price endpoints
β”‚   β”‚       └── mod.rs          # Router setup
β”‚   β”œβ”€β”€ core/                   # Core application
β”‚   β”‚   β”œβ”€β”€ config.rs           # Configuration management
β”‚   β”‚   β”œβ”€β”€ server.rs           # Server initialization
β”‚   β”‚   └── mod.rs              # Core module root
β”‚   β”œβ”€β”€ main.rs                 # Application entry point
β”‚   └── lib.rs                  # Library root
β”œβ”€β”€ assets/                     # Project assets
β”œβ”€β”€ Dockerfile                  # Container configuration
β”œβ”€β”€ docker-compose.yml          # Container Compose setup
β”œβ”€β”€ Cargo.toml                  # Package configuration
β”œβ”€β”€ .env                        # Environment variables
└── README.md

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client Apps   β”‚    β”‚   Boltzmann     β”‚    β”‚  External APIs  β”‚
β”‚                 β”‚    β”‚      API        β”‚    β”‚                 β”‚
β”‚  β€’ Web Apps     │◄──►│                 │◄──►│  β€’ CoinGecko    β”‚
β”‚  β€’ Mobile Apps  β”‚    β”‚  β€’ Gas Oracle   β”‚    β”‚  β€’ CoinMarketCapβ”‚
β”‚  β€’ DeFi Dapps   β”‚    β”‚  β€’ Simulator    β”‚    β”‚  β€’ RPC Nodes    β”‚
β”‚  β€’ Trading Bots β”‚    β”‚  β€’ Subscriptionsβ”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‘ API Endpoints

Health Check

GET /api/v1/health

Check if the API server is running.

Response:

Boltzmann API is running

Cryptocurrency Prices

GET /api/v1/price/prices

Get current ETH prices from multiple providers.

Query Parameters:

  • amount (optional): Number of ETH tokens (default: 1)
  • currency (optional): Target currency - USD, EUR, CHF, CNY, GBP, JPY, CAD, AUD (default: USD)

Example:

curl "http://localhost:3000/api/v1/price/prices?amount=5&currency=EUR"

Gas Price Estimates

GET /api/v1/gas/prices

Get current Ethereum gas price estimates.

Query Parameters:

  • provider (optional): Gas oracle provider - "etherscan" or "alloy" (default: etherscan)

Example:

curl "http://localhost:3000/api/v1/gas/prices?provider=alloy"

🚧 Planned Features (Coming Soon)

The following advanced features are planned for future releases:

  • Transaction Simulation: POST /api/v1/simulate - Simulate EVM transactions
  • Batch Operations: POST /api/v1/simulate/batch - Multiple transaction simulation
  • Subscriptions: Real-time monitoring with webhooks
  • Historical Data: Gas price trends and analytics
  • Multi-Chain: Support for Polygon, Arbitrum, and other EVM chains

πŸ› οΈ Installation & Setup

Prerequisites

  • Podman & Podman Compose (recommended)
  • OR Docker & Docker Compose (alternative)
  • OR Rust 1.75+ for local development

🐳 Quick Start with Podman (Recommended)

# Clone the repository
git clone https://github.com/pxlvre/boltzmann.git
cd boltzmann

# Create environment file from template
cp .env.example .env

# Edit .env with your API keys (see Configuration section below)
vim .env

# Start with Podman Compose
podman-compose up -d

# Check if it's running
curl http://localhost:3000/api/v1/health

πŸ¦€ Local Development Setup

# Clone the repository
git clone https://github.com/pxlvre/boltzmann.git
cd boltzmann

# Create environment file
cp .env.example .env

# Configure your environment variables (see below)
vim .env

# Build and run
cargo build --release
cargo run

🐳 Container Commands

Podman (Recommended)

# Build the image
podman build -t boltzmann-api .

# Run with Podman Compose (recommended)
podman-compose up -d

# Run standalone container
podman run -p 3000:3000 \
  -e COINMARKETCAP_API_KEY=your_key \
  -e COINGECKO_API_KEY=your_key \
  -e ETHERSCAN_API_KEY=your_key \
  -e ETHEREUM_RPC_URL=your_rpc_url \
  boltzmann-api

# View logs
podman-compose logs -f boltzmann-api

# Stop services
podman-compose down

Docker (Alternative)

# Build the image
docker build -t boltzmann-api .

# Run with Docker Compose
docker-compose up -d

# Run standalone container
docker run -p 3000:3000 \
  -e COINMARKETCAP_API_KEY=your_key \
  -e COINGECKO_API_KEY=your_key \
  -e ETHERSCAN_API_KEY=your_key \
  -e ETHEREUM_RPC_URL=your_rpc_url \
  boltzmann-api

# View logs
docker-compose logs -f boltzmann-api

# Stop services
docker-compose down

βš™οΈ Configuration

Create a .env file with the following environment variables:

# Server Configuration
HOST=127.0.0.1         # Use 0.0.0.0 for Docker
PORT=3000

# API Keys (at least one price provider required)
COINMARKETCAP_API_KEY=your-coinmarketcap-key    # Get from: https://coinmarketcap.com/api/
COINGECKO_API_KEY=your-coingecko-key           # Get from: https://www.coingecko.com/en/api

# Gas Price Providers
ETHERSCAN_API_KEY=your-etherscan-key           # Optional - Get from: https://etherscan.io/apis
ETHEREUM_RPC_URL=your-rpc-url                  # Required - Get from Infura, Alchemy, etc.

Required Configuration:

  • At least one of COINMARKETCAP_API_KEY or COINGECKO_API_KEY
  • ETHEREUM_RPC_URL for gas price functionality

Getting API Keys:

πŸš€ API Usage Examples

Health Check

curl http://localhost:3000/api/v1/health

Get Cryptocurrency Prices

# Get 1 ETH price in USD (default)
curl http://localhost:3000/api/v1/price/prices

# Get 5 ETH price in EUR
curl "http://localhost:3000/api/v1/price/prices?amount=5&currency=EUR"

Response:

[
  {
    "coin": "ETH",
    "currency": "USD", 
    "price": 4164.82,
    "provider": "coinmarketcap",
    "quote_per_amount": {
      "amount": 1.0,
      "total_price": 4164.82
    },
    "timestamp": "2025-10-27T15:30:00Z"
  },
  {
    "coin": "ETH",
    "currency": "USD",
    "price": 4162.15,
    "provider": "coingecko", 
    "quote_per_amount": {
      "amount": 1.0,
      "total_price": 4162.15
    },
    "timestamp": "2025-10-27T15:30:00Z"
  }
]

Get Gas Price Estimates

# Get gas prices from Etherscan (default)
curl http://localhost:3000/api/v1/gas/prices

# Get gas prices from Alloy RPC 
curl "http://localhost:3000/api/v1/gas/prices?provider=alloy"

Response:

{
  "gas_price": {
    "low": 2.361777,
    "average": 2.402917,
    "high": 2.798484,
    "timestamp": "2025-10-27T15:30:00Z"
  },
  "provider": "etherscan"
}

Supported Currencies

  • USD - US Dollar
  • EUR - Euro
  • CHF - Swiss Franc
  • CNY - Chinese Yuan
  • GBP - British Pound
  • JPY - Japanese Yen
  • CAD - Canadian Dollar
  • AUD - Australian Dollar

Supported Gas Providers

  • etherscan - Etherscan Gas Tracker API (default)
  • alloy - Direct Ethereum RPC via Alloy

Development

Application Structure

The application is organized with modular components:

  • Gas Price Oracle: Fetches current gas prices from multiple sources
  • Transaction Simulation: Simulates transaction costs across different scenarios
  • Fee Calculation: Implements EIP-1559, EIP-3198, and EIP-4844 fee structures
  • Price Conversion: Integrates with CoinGecko/CoinMarketCap for fiat conversion
  • REST API: Provides HTTP endpoints for all functionality
  • Subscription System: Real-time monitoring and webhooks

Running Tests

cargo test

Building

cargo build

API Documentation

Start the server and visit http://localhost:8080/docs for interactive API documentation.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Supported Chains

  • Ethereum Mainnet (Chain ID: 1)

More chains coming soon!

License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

The choice of AGPL-3.0 aligns with the principles outlined by Vitalik Buterin in his post "Why I used to prefer permissive licenses and now favor copyleft", ensuring that improvements and derivatives remain open and accessible to the community.

About

simulate, track, and optimise gas costs across EVM chains

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages