GarlicWiki Logo

How to Create a Faucet for Garlicoin

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:

  1. User's browser contacts DNS to get the faucet’s IP address.
  2. The Apache server validates CAPTCHA through Google’s HTTP API.
  3. Source IP is identified.
  4. An IP verification service (e.g., getipintel.net) checks that the IP is not on a VPN list or banned.
  5. Verifies that the IP address has not used the faucet during the cooldown period.
  6. Triggers a Garlicoin transaction if the request is valid.
  7. 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.