Express.js application that relays identity proofs to the Ethereum blockchain.
- Single endpoint to accept ETH addresses and ZK proofs
- Input validation for hex strings and ETH addresses
- Ethers.js integration for blockchain interaction
- Error handling and logging
- Health check endpoint
npm installCreate a .env file with the following variables:
# Server Configuration
PORT=3000
# Ethereum Configuration
RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
# Or use a local node: http://localhost:8545
# Contract Configuration (to be filled once provided)
CONTRACT_ADDRESS=your_contract_address
CONTRACT_ABI=your_contract_abi_json
# Private key for signing transactions (keep secure!)
PRIVATE_KEY=your_private_key# Development mode
npm run dev
# Production mode
npm start- URL:
POST /submit-proof - Body:
{ "ethAddress": "0x742d35Cc6635C0532925a3b8D098D0ba37b5", "zkProof": "0x1234abcd..." } - Response:
{ "success": true, "message": "Proof submitted and address whitelisted successfully", "transactionHash": "0x...", "gasUsed": 21000, "blockNumber": 12345, "status": true }
- URL:
POST /whitelist - Body:
{ "ethAddress": "0x742d35Cc6635C0532925a3b8D098D0ba37b5" } - Response:
{ "success": true, "message": "Address whitelisted successfully", "transactionHash": "0x...", "gasUsed": 21000, "blockNumber": 12345, "status": true }
- URL:
GET /health - Response:
{ "status": "healthy", "timestamp": "2023-12-07T10:30:00.000Z", "web3Connected": true }
Once you provide the contract ABI and address, update the submitToContract function in server.js to implement the actual blockchain interaction.
The API validates:
- Required fields (ethAddress, zkProof)
- ETH address format (40 hex characters)
- ZK proof format (hex string starting with 0x)
Common error responses:
400: Bad request (validation errors)500: Internal server error