Understand the Structure
The Garlicoin Faucet provides a simple interface for users to enter a CAPTCHA. Once verified, a random amount of Garlicoin is sent to their wallet address. Below is an overview of the faucet system:
- User's browser contacts DNS to get the faucet’s IP address.
- The Apache server validates CAPTCHA through Google’s HTTP API.
- Source IP is identified.
- An IP verification service (e.g., getipintel.net) checks that the IP is not on a VPN list or banned.
- Verifies that the IP address has not used the faucet during the cooldown period.
- Triggers a Garlicoin transaction if the request is valid.
- Transaction is broadcasted to the mainnet.
Create Virtual Machine
Create a virtual machine with Ubuntu on any cloud provider (AWS, GCP, Azure) or using on-premise hardware.
Create MySQL Table
Set up MySQL to store faucet user data:
sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation
Login to MySQL and set up the database:
sudo mysql
CREATE DATABASE IF NOT EXISTS faucet;
USE faucet;
CREATE TABLE IF NOT EXISTS users (
address VARCHAR(35) NOT NULL,
time INT(11) UNSIGNED NOT NULL,
ip VARCHAR(17) NOT NULL,
amount VARCHAR(7) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Host Apache Web Server
To install Apache, follow this DigitalOcean tutorial. It covers installation and configuration of Apache on Ubuntu.
Write index.php
Write an index.php
file to handle the user’s IP, CAPTCHA verification, MySQL interactions, and initiate Garlicoin RPC calls. Refer to the example code on GitHub for setup details.
- Source IP logging
- CAPTCHA validation via Google’s API
- Data storage in the MySQL database
- Sending RPC commands to the Garlicoin node