Configuration
Wiring chains, transports (HTTP, WebSocket, fallback), accounts, and custom RPC providers into clients.
Third-party documentation. This is independently authored analysis of the public Viem codebase — not the official docs, and not reviewed or endorsed by the Viem team.
Configuration
Viem is configured entirely at client construction — there is no global setup, registry, or default instance to mutate.
Chains
Import a chain definition and attach it to a client: chain: mainnet. Attaching a chain gives the client correct defaults (explorer URL for transaction links, hardfork-aware behavior) and lets viem guard against talking to the wrong network. Overriding RPC URLs per environment is done on the transport, not the chain.
Transports
http(url) accepts any JSON-RPC endpoint; omitting the url uses the chain's public RPC (fine for development, rate-limited in production). fallback([http(a), http(b)]) provides provider redundancy with configurable rank ordering. webSocket(url) enables subscription-based watching; it pairs naturally with watchContractEvent for low-latency indexers.
Accounts and signers
A wallet client takes an account at construction: local accounts sign in-process and require key management discipline; JSON-RPC accounts forward to injected providers and never expose keys. Switching the active account later means constructing or re-keying the client — again, explicit over implicit.
Bundling
Because actions are plain named exports, bundlers tree-shake aggressively; server-side usage imports only what it needs. There are no peer dependencies beyond TypeScript types at build time.
