Gas Network SDK
A Rust SDK for the Gas Network API, providing gas price prediction and optimization for blockchain transactions.
Features
- Multi-chain support: Ethereum, Polygon, Bitcoin, SEI, Optimism, Arbitrum, Base, Linea, Unichain
- Real-time gas price estimates with confidence levels
- Base fee and blob fee predictions (Ethereum only)
- Gas price distribution analysis (Ethereum only)
- Oracle integration for on-chain gas data
- Async/await support with tokio
- Comprehensive error handling
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
async
API Reference
Client Creation
let client = new?;
Gas Price Estimation
// Get comprehensive gas price data
let prices = client.get_gas_prices.await?;
// Get specific confidence level estimate
let estimate = client.get_next_block_estimate.await?;
Base Fee Prediction (Ethereum only)
let base_fees = client.get_base_fee_estimates.await?;
println!;
println!;
// Get estimates for next 5 blocks
for block_estimate in &base_fees.estimated_base_fees
Gas Distribution Analysis (Ethereum only)
let distribution = client.get_gas_distribution.await?;
Oracle Data
// Get oracle data for a specific chain ID
let oracle_data = client.get_oracle_data.await?; // Ethereum mainnet
Supported Chains
- Ethereum
- Polygon
- Bitcoin
- SEI
- Optimism
- Arbitrum
- Base
- Linea
- Unichain
Error Handling
The SDK uses a comprehensive error system:
use ;
match client.get_gas_prices.await
Authentication
You can optionally use an API key from Blocknative for higher rate limits. The API works without authentication but with rate limitations. Pass your API key when creating the client, or use a placeholder if you don't have one.
License
Licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.