$ show ava-labs/avalanche-faucet
This is a Avalanche blockchain faucet service that allows users to request test tokens for various EVM-compatible networks and subnets. The application consists of a Node.js/Express.js backend with a React.js frontend. It implements sophisticated rate limiting (global, IP-based, wallet-based, and common token disbursal), captcha verification (reCAPTCHA v2/v3), and a pipeline check system requiring either mainnet balance validation or coupon redemption for token requests. The service supports multiple EVM chains and ERC20 tokens, with automatic nonce and balance management, transaction queuing, and mempool limit handling. Key architectural features include modular middleware, decoupled services for coupon and mainnet checking, and clean separation between blockchain interaction logic and API handling.
The LLM identified 5 files worth highlighting for reuse:
A sophisticated rate limiting middleware that supports multiple limiter types (global, IP, wallet, common token disbursal) with integration for coupon-based rate limit skipping. It properly handles reverse proxies using cf-connecting-ip header and provides clean separation of concerns. The component is isolated, reusable in any Express application with minimal modification, and demonstrates non-obvious skill in managing complex rate limiting scenarios including proxy awareness and conditional skipping based on coupon attributes.
A captcha verification middleware that supports both reCAPTCHA v2 and v3 with proper error handling and logging. It provides a clean interface for verification that can be easily integrated into any Node.js application. The component is isolated, requires only axios as a dependency, and demonstrates good integration practices with Google's reCAPTCHA service including proper token verification and error handling.
A utility module providing functions to check Ethereum-compatible blockchain balances and nonces with proper error handling and logging. It offers a clean abstraction over web3 calls that can be reused in any Ethereum-compatible blockchain application. The component is isolated, depends only on axios, and demonstrates effective encapsulation of common blockchain interaction patterns.
Contains essential utility functions for blockchain applications: calculateBaseUnit for precise conversion between human-readable amounts and blockchain units (handling decimal precision correctly), and asyncCallWithTimeout for handling promises with timeouts. These are pure, isolated functions that demonstrate non-obvious skill in handling blockchain-specific mathematical operations and asynchronous control flow.
A self-contained coupon service implementing a quota/coupon system with DynamoDB persistence, Mutex-based concurrency control, and periodic synchronization between memory and database. It includes proper validation, consumption, and reclamation of coupons with atomic operations. The component is isolated, follows the service pattern, and demonstrates non-obvious skill in managing concurrent access to shared resources while maintaining data consistency.