Skip to content

ETH Faucet Setup Guide

Published:
by 22Xy

In this tutorial, we’ll walk through the steps to set up a local Ethereum node using go-ethereum (geth) client and run a local Ethereum faucet with eth-faucet. This setup is ideal for testing and development purposes for your own geth client.

Spin Up Go Ethereum Locally

To get started, we’ll use the Go Ethereum client, which is a widely-used implementation of the Ethereum protocol.

Building the Source

First, clone the Go Ethereum repository and build the source:

git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
make geth
make all

Running the Node Locally

Once built, you can run the Ethereum node in development mode:

geth --dev --http --http.api eth,net,web3 --http.port 8545

Running the node in development mode is crucial as it provides a pre-configured environment with a pre-funded account, making it perfect for testing and development. This command starts a local Ethereum node with HTTP RPC enabled, allowing you to interact with it programmatically.

Run eth-faucet Locally

Next, we’ll set up the eth-faucet, which allows you to distribute test Ether to accounts.

Installation

  1. Clone the eth-faucet repository and navigate to the app’s directory:
git clone https://github.com/chainflag/eth-faucet.git
cd eth-faucet
  1. Bundle the frontend with Vite:
go generate
  1. Build the Go project:
go build -o eth-faucet

Running the Faucet Locally

Start the faucet frontend application with the following command:

./eth-faucet -httpport 8080 -wallet.provider http://localhost:8545 -wallet.privkey <FUNDING_ACCOUNT_PRIVATE_KEY>

Replace <FUNDING_ACCOUNT_PRIVATE_KEY> with the private key of the account you want to use for funding.

Fund the Faucet Account

To fund the faucet account, follow these steps:

  1. Open a new terminal and attach (connect) to the running geth node we started earlier:
geth attach http://localhost:8545
  1. Send ETH to the Faucet Account
// Get the dev account (it's pre-funded in dev mode)
eth.accounts[0];

// Send 100 ETH to your faucet account
eth.sendTransaction({
  from: eth.accounts[0],
  to: "<FUNDING_ACCOUNT_PUBLIC_ADDRESS>",
  value: web3.toWei(100, "ether"),
});

// Check the balance
eth.getBalance("<FUNDING_ACCOUNT_PUBLIC_ADDRESS>");

Replace <FUNDING_ACCOUNT_PUBLIC_ADDRESS> with the public address of your faucet account.

Test the Faucet

Go to http://localhost:8080 to interact with the faucet frontend application:

eth-faucet-working-frontend

By following these steps, you can set up a local Ethereum environment specifically tailored for your Geth client, complete with a faucet to distribute test Ether. This setup is ideal for developers who want to experiment with Ethereum smart contracts and applications in a controlled and customizable environment.


Previous Post
golangci-lint Memory Issue Fix
Next Post
Stop Promoting Software Engineering Shortcut Tutorials