Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cordtus/devnet-faucet

Repository files navigation

Devnet Faucet

A dual-chain faucet for distributing native tokens on Cosmos SDK chains with EVM support.

Features

  • Dual Environment Support: Simultaneous Cosmos SDK + EVM native token distribution
  • Balance-Based Limiting: Only tops up wallets below a configurable threshold
  • API Key Authentication: Secure token distribution via authenticated API
  • Wallet Support: Keplr (Cosmos) and EIP-6963 compatible wallets (EVM)
  • Minimal Frontend: Simple Vue 3 example frontend included

Quick Start

1. Install Dependencies

yarn install

2. Configure Environment

cp .env.example .env

Edit .env:

MNEMONIC="your twelve word mnemonic phrase here"
FAUCET_API_KEY="your-secure-api-key-here"

3. Configure Network

Edit config.js to set your network endpoints and native token:

const config = {
  blockchain: {
    name: 'your-chain',
    ids: {
      chainId: 1234,              // EVM chain ID
      cosmosChainId: 'chain-1',   // Cosmos chain ID
    },
    endpoints: {
      rpc_endpoint: 'https://rpc.yourchain.com',
      evm_endpoint: 'https://evm-rpc.yourchain.com',
      rest_endpoint: 'https://rest.yourchain.com',
    },
    sender: {
      option: {
        prefix: 'yourprefix',     // Bech32 address prefix
      },
    },
    tx: {
      amounts: [{
        denom: 'utoken',
        symbol: 'TOKEN',
        amount: '1000000000000000000',
        decimals: 18,
      }],
    },
    balanceThreshold: '1000000000000000000', // 1 token
  },
};

4. Start the Server

yarn start         # Production server on port 8088
yarn dev           # Dev server with hot reload (port 3000)

API Endpoints

Endpoint Auth Description
GET /send/:address API Key Request tokens (Bech32 or EVM address)
GET /balance/:type No Query balance (type: cosmos or evm)
GET /config.json No Network configuration
GET /health No Health check

Authentication

The /send endpoint requires an API key via the X-API-Key header:

curl -H "X-API-Key: your-api-key" http://localhost:8088/send/0x...

See API_INTEGRATION.md for full integration documentation.

Project Structure

devnet-faucet/
|-- faucet.js              # Express API server
|-- config.js              # Network configuration
|-- src/
|   |-- App.vue            # Frontend example
|   |-- main.js            # Vue entry
|   |-- SecureKeyManager.js # Key derivation
|   |-- logRotation.js     # Log management
|-- tests/                 # Test suite

Scripts

yarn start        # Production server
yarn dev          # Development server
yarn build        # Build frontend
yarn test         # Run tests
yarn lint         # Check code
yarn lint:fix     # Fix linting issues

Deployment

Docker

docker build -t faucet .
docker run -p 8088:8088 \
  -e MNEMONIC="..." \
  -e FAUCET_API_KEY="..." \
  faucet

Fly.io

fly apps create your-faucet
fly secrets set MNEMONIC="..." FAUCET_API_KEY="..."
fly deploy

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8