Skip to Content
Privacy Protocol relayer flow is now default in the SDK.
DocsOperatorsRun a Relayer Node

Run a Relayer Node

This manual covers production setup for a Privacy Protocol relayer operator.

The SDK is relayer-first by default. Running your own relayer is optional, but lets you control routing, economics, and operational policy.

Why Operate a Relayer

  • Earn relay fees for private transactions your node submits.
  • Strengthen censorship resistance for the protocol.
  • Run lightweight Rust infrastructure on standard VPS setups.

Prerequisites

  • Rust stable toolchain (rustup, cargo)
  • Funded EOA dedicated to relayer gas
  • RPC endpoint for target chain
  • Deployed PrivacyProtocolPool address

Configure Environment

Create relayer/.env:

RELAYER_RPC_URL=https://your-rpc-provider RELAYER_PRIVATE_KEY=0xyour_relayer_private_key FAN_POOL_ADDRESS=0xyour_privacy_protocol_pool RELAYER_BIND_ADDR=0.0.0.0:8787 RELAYER_PUBLIC_INPUT_RELAYER_INDEX=6 RELAYER_PUBLIC_INPUT_FEE_INDEX=7 RELAYER_BATCH_SIZE=10 RELAYER_BATCH_MAX_WAIT_SECS=15 RELAYER_RETRY_MAX_ATTEMPTS=5 RELAYER_RETRY_BASE_DELAY_MS=500 RELAYER_MEMPOOL_PATH=./data/mempool.json

Variable Notes

  • RELAYER_RPC_URL: RPC endpoint used for simulation and submission.
  • RELAYER_PRIVATE_KEY: relayer signer paying gas for submitted batches.
  • FAN_POOL_ADDRESS: deployed PrivacyProtocolPool address.
  • RELAYER_PUBLIC_INPUT_RELAYER_INDEX: index in public_inputs for relayer address.
  • RELAYER_PUBLIC_INPUT_FEE_INDEX: index in public_inputs for relayer fee.
  • RELAYER_BATCH_SIZE + RELAYER_BATCH_MAX_WAIT_SECS: batching policy knobs.

Build and Run

cd relayer cargo build --release cargo run --release

API Surface

  • POST /relay
  • GET /relay/{request_id}
  • GET /health
  • GET /relay/{request_id}

Health check:

curl http://127.0.0.1:8787/health

Render Deployment Example

  1. Create a new Web Service from this repo.
  2. Set Root Directory to relayer.
  3. Build Command: cargo build --release.
  4. Start Command: RELAYER_BIND_ADDR=0.0.0.0:$PORT ./target/release/privacy-protocol-relayer.
  5. Add the .env values in Render secrets.
  6. Fund the relayer signer with native gas token.

Connect Apps to Your Relayer

By default, SDK consumers do not need relayer config.
To point apps to your operator endpoint explicitly:

const sdk = new PrivacyProtocolSDK(provider, poolAddress, undefined, { relayer: { url: "https://your-relayer.example.com", relayerAddress: "0xYourRelayerAddress", }, });

Security Checklist

  • Use a dedicated relayer key.
  • Store private key only in secret manager.
  • Monitor health endpoint and submission failures.
  • Rotate key if compromise is suspected.
  • Back up mempool persistence file if required.

Performance Tuning

  • Lower RELAYER_BATCH_SIZE for faster user finality.
  • Raise RELAYER_BATCH_SIZE for higher batching efficiency.
  • Lower RELAYER_BATCH_MAX_WAIT_SECS to reduce tail latency.
  • Tune retry values to match RPC quality.
Last updated on