/swan-faucet

Simple smart contract based ERC20 faucet for Ethereum

Primary LanguageJavaScriptMIT LicenseMIT

Swan Faucet

Swan Faucet is a pretty minimalistic faucet for Ethereum-based ERC20 tokens. It's based on a simple smart contract that will allow you to withdraw some tokens every couple of minutes. The amount of tokens and the waiting period can be defined upon deployment of the smart contract.

Technology Stack: node + react.js + web3

Container Installation

Running Swan Faucet as a container is the recommended way of using it.

Prerequisites

Install Docker Compose

https://docs.docker.com/compose/install/

Environment

Before deploying, you need to set environment variables in a .env file inside the backend directory, an example .env.example file is provided

  • WALLET_ADDRESS the address of signer that will be calling the function on the server-side
  • PRIVATE_KEY the private key of this wallet address
  • FAUCET_ADDRESS_MUMBAI faucet contract address
  • RPC_URL_MUMBAI the url of the RPC server/node (defaults to https://matic-mumbai.chainstacklabs.com)
  • PORT the localhost port the server is running on (defaults to 5000)
  • REDIS_HOST the localhost port of the redis database
  • FAUCET_ADDRESS_BINANCE_TESTNET faucet contract address
  • RPC_URL_BINANCE_TESTNET the url of the RPC server/node

For the frontend, you need to set environment variables inside the vue-frontend/config directory

  • NODE_ENV production or development,
  • BASE_API the base API for the UI
  • BASE_NETWORK the base RPC network
  • TOKEN_ADDRESS the token address
  • FAUCET_ADDRESS the address of the faucet contract
  • MATIC_TOKEN_ADDRESS native token address
  • GOOGLE_KEY key for google recaptcha service

Stable

Run the following command to run the latest stable image of Swan Faucet

docker-compose up

You can check the service at:

http://127.0.0.1:8080

http://172.21.0.2:8080

http://localhost:8080

Install from Source

Prerequisites

Install npm. (Version v14.18.1 of Node was used for this project) Both the front and backend use npm as the package manager.

Install redis.io The backend uses a redis server to provide API rate limiting.

Install Dependencies

Backend

  • cd backend
  • npm install
  • cd ..

Frontend

  • cd vue-frontend
  • npm install
  • cd ..

Build Frontend

npm run build should build the project. The build artifacts will be stored in the build/ directory

Build Backend

redis-server
node server

Reference Documents