Why Migrate?
voltaire-effect provides key advantages over viem and ethers.js:| Benefit | viem/ethers | voltaire-effect |
|---|---|---|
| Error handling | Try/catch with unknown | Typed errors with ParseError, TransportError |
| Dependency injection | Pass clients everywhere | Services via Layer composition |
| Testability | Mock modules or imports | Swap layers with test implementations |
| Composition | Manual promise chaining | Effect.gen, pipe, retry, timeout built-in |
| Type safety | Branded strings | Branded Uint8Array with schemas |
Core Concepts
Effect.gen vs async/await
yield* is like await but tracks errors in the type system.
Layer Composition vs Client Configuration
Typed Errors vs Exceptions
Side-by-Side Comparisons
Getting Block Number
Reading Contract Data
Sending Transactions
Event Watching
Step-by-Step Migration
Step 1: Add Dependencies
Step 2: Create Base Layers
Step 3: Migrate One Function at a Time
Start with read-only operations before wallet interactions:Step 4: Add Error Handling
Step 5: Create Test Layers
Common Gotchas
1. Forgetting to Provide Layers
2. Not Yielding Effects
3. Mixing Promises and Effects
4. Address Type Differences
5. Layer Composition Matters
Quick Reference
| viem/ethers | voltaire-effect |
|---|---|
await fn() | yield* fn() |
try/catch | Effect.catchTag |
createPublicClient | ProviderService + layers |
createWalletClient | SignerService + layers |
privateKeyToAccount | LocalAccount(key) |
getAddress(str) | S.decodeSync(Address.Hex)(str) |
parseEther('1') | 1000000000000000000n |
Incremental Migration with tryPromise / trySync
You can keep viem in place and wrap it so it composes with Effect. UseEffect.tryPromise for existing async APIs, and use Effect.try (sync) as a trySync helper for local parsing/validation.
getBalance free function and provide a Provider layer instead of the tryPromise wrapper.
See Also
- Comparisons — Detailed library comparison
- Why voltaire-effect? — Trade-offs and benefits
- Effect Primer — Learn Effect.ts basics
- viem Documentation — viem reference
- ethers.js Documentation — ethers.js reference

