Client vs SDK: the client wires RPC/signing; the sdk adds high-level flows (quote → prepare → create → wait) and convenience helpers.
Wallets by flow:
Deposits (L1 tx):l1Wallet required
Withdrawals (L2 tx):l2Wallet required
Finalize (L1 tx):l1Wallet required
Import
import { createViemClient, createViemSdk } from '@dutterbutter/zksync-sdk/viem';
Quick start
import { createPublicClient, createWalletClient, http } from "viem";import { createViemClient, createViemSdk } from "@dutterbutter/zksync-sdk/viem";// Public clients (reads)const l1 = createPublicClient({ transport: http(process.env.ETH_RPC!) });const l2 = createPublicClient({ transport: http(process.env.ZKSYNC_RPC!) });// Wallet clients (writes)const l1Wallet = createWalletClient({ account: /* your L1 Account */, transport: http(process.env.ETH_RPC!),});const l2Wallet = createWalletClient({ account: /* your L2 Account (can be the same key) */, transport: http(process.env.ZKSYNC_RPC!),});const client = createViemClient({ l1, l2, l1Wallet, l2Wallet });const sdk = createViemSdk(client);// Example: deposit 0.05 ETH L1 → L2, wait for L2 executionconst handle = await sdk.deposits.create({ token: ETH_ADDRESS, // 0x…00 sentinel for ETH supported amount: 50_000_000_000_000_000n, // 0.05 ETH in wei to: l2Wallet.account.address,});await sdk.deposits.wait(handle, { for: "l2" });// Example: resolve contracts and map an L1 token to its L2 addressconst { l1NativeTokenVault } = await sdk.helpers.contracts();const l2Crown = await sdk.helpers.l2TokenAddress(CROWN_ERC20_ADDRESS);
You can construct the client with only the wallets you need for a given flow (e.g., just
l2Wallet to create withdrawals; add l1Wallet when you plan to finalize).
createViemSdk(client) → ViemSdk
Returns:ViemSdk
The SDK composes the client with resources: deposits, withdrawals, and
convenience helpers.