A lightweight HTTP faucet service for the Janction testnet, designed to distribute test tokens to users for development and testing purposes.
- Go 1.20 or higher
- A running Janction node (accessible at
localhost:26657)
Generate a new key named faucet using the test keyring backend:
janctiond keys add faucet \
--keyring-backend test
Transfer tokens from an existing account (e.g., alice) to the faucet account:
janctiond tx bank send alice janction1t43dueljm7kya9ddkhxq24f8kmkhv44vjjcnfg 1000000jct \
--from alice \
--chain-id demo \
--keyring-backend test \
--node http://localhost:26657 \
--yes
janction1t43dueljm7kya9ddkhxq24f8kmkhv44vjjcnfgis the address of thefaucetaccount
Ensure the configuration variables in your .env file are correct:
APP_NAME=test
CHAIN_ID=demo
FAUCET_ADDRESS=janction1t43dueljm7kya9ddkhxq24f8kmkhv44vjjcnfg
FAUCET_ADDRESS_ALIAS=faucet
TOKEN_AMOUNT_PER_REQUEST=1000
NODE_ADDRESS=localhost
NODE_PORT=26657
GRPC_ADDRESS=localhost
GRPC_PORT=9090
PUBLISH_ADDRESS=localhost
PUBLISH_PORT=8081
Install dependencies and run the faucet service:
go mod tidy
go run .
Use curl or your preferred HTTP client to request tokens:
curl "http://localhost:8081/faucet?address=janction1ev7mkxtccqud7d0j7pzxrd42e9ze4t4gah5dyl"
Replace janction1ev7mkxtccqud7d0j7pzxrd42e9ze4t4gah5dyl with the recipient’s Bech32 target address.
You can customize the faucet by modifying the following parameters in .env:
-
TOKEN_AMOUNT_PER_REQUEST: Number of tokens dispensed per request -
NODE_ADDRESSandNODE_PORT: Janction node RPC endpoint -
GRPC_ADDRESSandGRPC_PORT: Janction node gRPC endpoint -
PUBLISH_ADDRESSandPUBLISH_PORT: HTTP server settings for the faucet service