A modern, responsive Bitcoin SV (BSV) faucet built with React, TypeScript, and the latest @bsv/sdk. Features a clean UI, bonus system, and rate limiting capabilities.
- π React 18 - A JavaScript library for building user interfaces
- π TypeScript - Type-safe JavaScript
- β‘ Vite - Next Generation Frontend Tooling
- π @bsv/sdk v1.3+ - Modern TypeScript SDK for Bitcoin SV
- π¨ CSS3 - Custom styling with modern CSS features
- π― Clean, responsive UI with modern CSS
- π Random bonus rewards system
- π Rate limiting capabilities
- π Transaction metadata via OP_RETURN
- β‘ Real-time balance updates
- π Automatic UTXO management
- π‘οΈ Type-safe BSV operations with @bsv/sdk
- π Secure AWS Lambda deployment option for backend operations
This project supports a secure deployment model using AWS Lambda for handling sensitive operations. This approach offers several advantages:
- π Enhanced Security: Private keys never exposed to client-side code
- π‘οΈ Server-Side Rate Limiting: More robust protection against abuse
- π Scalability: Handles traffic spikes without manual intervention
- π° Cost-Effective: Pay only for the compute time you use (1 million free requests every month)
- π Global Availability: Deploy to any AWS region for reduced latency
-
Create Lambda Function:
- Sign in to AWS Management Console
- Navigate to Lambda service
- Click "Create function"
- Select "Author from scratch"
- Name your function (e.g.,
bsv-faucet-service) - Choose Node.js 18.x or higher as runtime
- Create a new execution role with basic Lambda permissions
-
Deploy Lambda Code:
- Zip the contents of the
lambdadirectory:cd lambda zip -r function.zip index.mjs package.json - Upload the zip file to your Lambda function
- Zip the contents of the
-
Configure Environment Variables:
- Add the following environment variables to your Lambda function:
FAUCET_PRIVATE_KEY=your_private_key_in_wif_format FAUCET_AMOUNT=1000 FAUCET_IDENTIFIER=your_faucet_identifier MIN_TIME_BETWEEN_CLAIMS=3000
- Add the following environment variables to your Lambda function:
-
Create API Gateway:
- Create a new API in API Gateway (REST API)
- Add a new resource with a POST method
- Set the integration type to "Lambda Function"
- Select your Lambda function
- Enable CORS with appropriate settings
- Deploy the API to a stage (e.g.,
prod)
-
Update Frontend Configuration:
- In your frontend code, update the API endpoint to point to your API Gateway URL
- Example:
https://your-api-id.execute-api.region.amazonaws.com/stage/resource
- Multiple UTXO source fallbacks (WhatsOnChain, Bitails)
- Robust error handling and logging
- In-memory caching for rate limiting
- Low fee transactions (0.5 satoshis/kilobyte)
- Configurable faucet amount and claim frequency
- Click the "Deploy to Netlify" button above
- Connect your GitHub account
- Configure the following environment variables:
VITE_PRIVATE_KEY=your_private_key VITE_FAUCET_AMOUNT=1000 VITE_BONUS_RANGE=500-2000 VITE_FAUCET_IDENTIFIER=your_faucet_identifier
# Clone the repository
git clone https://github.com/dnh33/simple-bsv-faucet
cd simple-bsv-faucet
# Install dependencies
npm install
# Create and configure environment variables
cp .env.example .env
# Start development server
npm run devVITE_PRIVATE_KEY: Your BSV private key in WIF format (Keep this secure!)VITE_FAUCET_AMOUNT: Base amount for each claim (in satoshis)VITE_BONUS_RANGE: Range for bonus rewards (format: "min-max")VITE_FAUCET_IDENTIFIER: Identifier added to OP_RETURN
The faucet includes built-in rate limiting for specific addresses. Modify the delay in src/App.tsx:
if (recipientAddress === "your_address") {
setStatus("Processing claim...");
await new Promise((resolve) => setTimeout(resolve, 30000)); // 30 second delay
throw new Error("This address is rate limited");
}Each transaction includes OP_RETURN data with your faucet identifier:
lockingScript: new Script([
{ op: OP.OP_FALSE },
{ op: OP.OP_RETURN },
{
op: OP.OP_PUSHDATA1,
data: Array.from(new TextEncoder().encode(FAUCET_IDENTIFIER)),
},
]);- NEVER expose your private key in client-side code in production
- RECOMMENDED: Use the AWS Lambda approach described above
- The Lambda function keeps private keys secure on the server side
- Rate limiting is essential
- Client-side rate limiting can be bypassed
- The Lambda implementation provides more robust server-side rate limiting
- Testing and monitoring
- Test thoroughly on testnet before deploying to mainnet
- Monitor your faucet balance and set up alerts
- Review AWS CloudWatch logs for any suspicious activity
Modify src/App.css to customize the appearance:
:root {
--background: #13111c;
--primary: #8b5cf6;
--text: #ffffff;
/* Add your custom variables */
}Adjust bonus probability and amounts in src/utils/hooks.ts:
const BONUS_PROBABILITY = 0.05; // 5% chance
const BONUS_RANGE = [500, 2000]; // in satoshisContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project helpful, consider donating to: 1KaMouXsastUR5kdoiWUaHmpBuBnY9Xevg
Built with β€οΈ for the Bitcoin community