| Crates.io | cryptopay |
| lib.rs | cryptopay |
| version | 0.1.0 |
| created_at | 2025-12-30 14:40:20.351154+00 |
| updated_at | 2025-12-30 14:40:20.351154+00 |
| description | A comprehensive Rust library for BscScan API integration and payment verification on Binance Smart Chain |
| homepage | |
| repository | https://github.com/GrandpaEJ/cryptopay |
| max_upload_size | |
| id | 2012742 |
| size | 209,724 |
A Rust library for verifying and monitoring cryptocurrency payments on Ethereum using the Etherscan API.
[dependencies]
cryptopay = "0.1"
tokio = { version = "1", features = ["full"] }
rust_decimal = "1.33"
use cryptopay::*;
use rust_decimal::Decimal;
#[tokio::main]
async fn main() -> Result<()> {
let client = EtherscanClient::new("your-api-key")?;
let verifier = PaymentVerifier::new(client);
let payment = PaymentRequest::eth(
Decimal::new(1, 1), // 0.1 ETH
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0",
12, // confirmations
);
match verifier.verify_payment(&payment).await? {
VerificationResult::Confirmed { tx_hash, .. } => {
println!("✅ Payment confirmed: {}", tx_hash);
}
_ => println!("⏳ Payment pending or not found"),
}
Ok(())
}
See the examples/ directory for complete examples:
basic_payment.rs - ETH payment verificationtoken_payment.rs - ERC20 token verificationpayment_monitor.rs - Real-time monitoring with callbacksRun examples:
ETHERSCAN_API_KEY=your-key cargo run --example basic_payment
export ETHERSCAN_API_KEY="your-api-key"
export ETHERSCAN_RATE_LIMIT=5
export ETHERSCAN_CACHE_TTL=300
let config = ClientConfig::builder()
.api_key("key1")
.api_key("key2") // Multiple keys for rotation
.rate_limit(10) // Higher limit for PRO plan
.testnet() // Use Sepolia testnet
.build()?;
let client = EtherscanClient::with_config(config)?;
// Native ETH
Currency::ETH
// Predefined tokens
Currency::usdt() // Tether (6 decimals)
Currency::usdc() // USD Coin (6 decimals)
Currency::dai() // Dai (18 decimals)
// Custom ERC20
Currency::erc20("0xcontract...", 18)
Licensed under either of:
at your option.
Contributions welcome! Please feel free to submit a Pull Request.