Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Identity Relayer

Express.js application that relays identity proofs to the Ethereum blockchain.

Features

  • 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

Installation

npm install

Configuration

Create 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

Usage

Start the server

# Development mode
npm run dev

# Production mode
npm start

API Endpoints

Submit Proof (with ZK verification)

  • 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
    }

Simple Whitelist (without ZK verification)

  • URL: POST /whitelist
  • Body:
    {
      "ethAddress": "0x742d35Cc6635C0532925a3b8D098D0ba37b5"
    }
  • Response:
    {
      "success": true,
      "message": "Address whitelisted successfully",
      "transactionHash": "0x...",
      "gasUsed": 21000,
      "blockNumber": 12345,
      "status": true
    }

Health Check

  • URL: GET /health
  • Response:
    {
      "status": "healthy",
      "timestamp": "2023-12-07T10:30:00.000Z",
      "web3Connected": true
    }

Contract Integration

Once you provide the contract ABI and address, update the submitToContract function in server.js to implement the actual blockchain interaction.

Error Handling

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages