CryptoPay - Etherscan Payment Gateway
A Rust library for verifying and monitoring cryptocurrency payments on Ethereum using the Etherscan API.
Features
- ✅ Etherscan API Integration - Complete API coverage for accounts, transactions, tokens, and gas
- 💰 Payment Verification - Verify ETH and ERC20 token payments with confirmation tracking
- 👀 Payment Monitoring - Real-time monitoring with customizable callbacks
- ⚡ Rate Limiting - Built-in token bucket rate limiter (5 req/s default)
- 💾 Caching - In-memory LRU cache with configurable TTL
- 🔄 API Key Rotation - Round-robin rotation for multiple API keys
- 🎯 Type Safety - Strongly-typed models with helper methods
Quick Start
[]
= "0.1"
= { = "1", = ["full"] }
= "1.33"
use *;
use Decimal;
async
Documentation
- 📚 API Documentation
- 📖 User Guide
- 🚀 Examples
- 📝 CHANGELOG
Examples
See the examples/ directory for complete examples:
basic_payment.rs- ETH payment verificationtoken_payment.rs- ERC20 token verificationpayment_monitor.rs- Real-time monitoring with callbacks
Run examples:
ETHERSCAN_API_KEY=your-key
Configuration
Environment Variables
Builder Pattern
let config = builder
.api_key
.api_key // Multiple keys for rotation
.rate_limit // Higher limit for PRO plan
.testnet // Use Sepolia testnet
.build?;
let client = with_config?;
Supported Currencies
// Native ETH
ETH
// Predefined tokens
usdt // Tether (6 decimals)
usdc // USD Coin (6 decimals)
dai // Dai (18 decimals)
// Custom ERC20
erc20
Getting an API Key
- Visit Etherscan
- Create an account
- Go to API-KEYs section
- Generate a free API key
License
Licensed under either of:
- MIT license LICENSE
at your option.
Contributing
Contributions welcome! Please feel free to submit a Pull Request.