Create .env file in the root of the project and add the following variables:
# evm private key in hex format without 0x prefix
WALLET_PRIVATE_KEY=
CHAIN_URL=
# recaptcha is not supported yet
RECAPTCHA_SECRET_KEY="non supported yet"The tokens config is used to define the tokens that the faucet will distribute.
Copy tokensConfig.json from smart-contracts repo after run initFaucet.ts script.
Config must have following struct:
{
"ZKP": {
"address": "", // erc20 token-contract address, empty for native token
"amount": "2000000000000000000" // the amount of tokens to send in wei
},
"USDT": {
"address": "0x1558B7241BCD90c7C7aD7683Bf865b84F004E0a5",
"amount": "10000000"
},
...
}build:
go build -o faucet-backend ./cmd/main.gorun:
./faucet-backendThe config file described in config.yaml.
The config struct described on config/config.go.
The .env config params has higher priority than the config file.
The config file has following struct:
db_path: /app/data/faucet.db # Path to the database file
http:
addr: ":8080" # HTTP api server address
read_header_timeout: 5s # Timeout for reading the request headers
read_timeout: 10s # Timeout for reading the request body
write_timeout: 10s # Timeout for writing the response
idle_timeout: 60s # Timeout for idle connections
max_request_size: 5000 # Maximum request size in bytes
rate_period: 1s # Rate limit period for the HTTP server
rate_limit: 20 # Rate limit for the HTTP server in requests per second
chain_url: "" # URL of the Ethereum node (e.g. Infura, Alchemy), described on .env
wallet_private_key: "" # Private key of the wallet in hex format (without 0x prefix) that will be used to send transactions, described on .env
native_token_name: ZKP # Name of the native token, used in the faucet
eth_client_limits:
rate_limit: 50ms # Rate limit for the Ethereum client in milliseconds
burst: 20 # Burst limit for the Ethereum client in requests
faucet_limits:
request_limit: 1h # Time period for the faucet request limit
nonce_ttl: 30s # Time to live for the nonce in seconds
wallet_settings:
retries: 5 # Number of retries for sending transactions
tx_mine_wait: 30s # Time to wait for the transaction to be mined
gas_limit_multiplier: 120 # Multiplier for the gas limit, used to increase the gas limit for the transaction
nonce_delay: 100ms # Delay for the get pending nonce in milliseconds
nonce_max_wait: 10s # Maximum wait time for the next pending nonce in seconds
recaptcha: # recaptcha is not supported yet
enabled: false
min_score: 0.5
timeout: 2s
deadline: 60s