At a glance
- Factory:
createEthersClient({ l1, l2, signer, overrides? }) → EthersClient - What it provides: cached core addresses, connected contracts, L2-bound ZKsync RPC (
zks), and a signer force-bound to L1. - When to use: create this first; then pass into
createEthersSdk(client).
Import
Quick start
createEthersClient(args) → EthersClient
Returns: EthersClient
EthersClient interface
Adapter discriminator.
Public L1 provider.
Public L2 (ZKsync) provider.
Signer (bound to
l1 for sends).ZKsync-specific RPC surface bound to
l2.Methods
ensureAddresses() → Promise<ResolvedAddresses>
Resolve and cache core contract addresses from chain state (merges any overrides).
contracts() → Promise<{ ...contracts }>
Return connected ethers.Contract instances for all core contracts.
refresh(): void
Clear cached addresses/contracts. Subsequent calls re-resolve.
baseToken(chainId: bigint) → Promise<Address>
Return the L1 base-token address for a given L2 chain via Bridgehub.baseToken(chainId).
Types
ResolvedAddresses
Notes & pitfalls
- Provider roles:
l1is used for L1 lookups and finalization sends;l2is used for ZKsync reads/RPC viazks. - Signer binding: The signer is connected to
l1to ensure L1 transactions (e.g., finalize) succeed without extra wiring. - Caching:
ensureAddresses()andcontracts()are cached. Callrefresh()after network changes or when using new overrides. - Overrides: For forks or custom deployments, pass
overridesat construction; they are merged with on-chain resolution.