← Protocols
dRPC
01Description

Decentralized RPC aggregator routing requests across a network of independent node providers, with 200+ networks and a flat-rate compute-unit pricing model.

02Best for
  • 01decentralized RPC routing
  • 02multi-region failover
  • 03flat-rate CU pricing
  • 04long-tail chain coverage
  • 05self-hosted load balancing (NodeCore)
03Install
  • pnpm add viem
04Environment variables
VariableScopeDescription
DRPC_API_KEYServerdRPC API key from the dashboard. Used as the `dkey` query param on the endpoint URL. Server-side only.
DRPC_ENDPOINT_URLServerFull dRPC endpoint URL with key, e.g. `https://lb.drpc.org/ogrpc?network=ethereum&dkey=<DRPC_API_KEY>`. Server-side only.
05Prompt snippet
Use dRPC as the JSON-RPC transport. Build the endpoint URL as `https://lb.drpc.org/ogrpc?network=<chain>&dkey=${process.env.DRPC_API_KEY}` (or use the WebSocket variant `wss://lb.drpc.org/ogws?...`). Pass it to `viem` via `createPublicClient({ chain: mainnet, transport: http(process.env.DRPC_ENDPOINT_URL) })`. Each method burns a flat 20 CU regardless of complexity, so prefer `multicall3` for batched reads. For self-hosting and routing across multiple providers, deploy `drpcorg/nodecore` instead of calling the hosted gateway. Supported chains include Ethereum, Base, Arbitrum, Optimism, Polygon, BNB, Avalanche, Solana, Starknet, and 200+ others.
06Gotchas
  • Endpoint URLs embed the `dkey` query param — never ship them in a client bundle; proxy through a server route or use a separate domain-locked key.
  • Pricing is flat 20 CU per method (~$0.30 per 1M CU as of 2026), so heavy methods like `eth_getLogs` no longer cost more than `eth_blockNumber` — but free-tier monthly CU caps still apply and exhaust quickly under indexer-style backfills.
  • Decentralized routing means you don't choose the underlying node provider per request — debug-trace methods can route to a node that doesn't support them and 405; pin to providers via the `provider_ids` query param when you need archive/trace.
  • Archive-mode access (state at historical blocks) is gated behind paid tiers and only some upstream providers offer it — confirm `eth_getBalance` at an old block returns data before relying on it.
  • Public endpoints (no `dkey`) are heavily rate-limited and rotate keys — production traffic must use an authenticated `dkey` URL.
  • WebSocket subscriptions are subject to per-connection caps and may be evicted under load; reconnect with backoff and resubscribe.
07Alternatives