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
PrivacyProtocolPooladdress
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.jsonVariable Notes
RELAYER_RPC_URL: RPC endpoint used for simulation and submission.RELAYER_PRIVATE_KEY: relayer signer paying gas for submitted batches.FAN_POOL_ADDRESS: deployedPrivacyProtocolPooladdress.RELAYER_PUBLIC_INPUT_RELAYER_INDEX: index inpublic_inputsfor relayer address.RELAYER_PUBLIC_INPUT_FEE_INDEX: index inpublic_inputsfor relayer fee.RELAYER_BATCH_SIZE+RELAYER_BATCH_MAX_WAIT_SECS: batching policy knobs.
Build and Run
cd relayer
cargo build --release
cargo run --releaseAPI Surface
POST /relayGET /relay/{request_id}GET /healthGET /relay/{request_id}
Health check:
curl http://127.0.0.1:8787/healthRender Deployment Example
- Create a new Web Service from this repo.
- Set Root Directory to
relayer. - Build Command:
cargo build --release. - Start Command:
RELAYER_BIND_ADDR=0.0.0.0:$PORT ./target/release/privacy-protocol-relayer. - Add the
.envvalues in Render secrets. - 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_SIZEfor faster user finality. - Raise
RELAYER_BATCH_SIZEfor higher batching efficiency. - Lower
RELAYER_BATCH_MAX_WAIT_SECSto reduce tail latency. - Tune retry values to match RPC quality.
Last updated on