status(...)— returns a non-blocking snapshot of where an operation is.wait(..., { for })— blocks/polls until a specified checkpoint is reached.
status(...) for UI refreshes; use wait(...) when you need to gate logic on inclusion/finality.
You can pass either a handle returned from
create(...) or a raw transaction hash.Withdrawals
withdrawals.status(h | l2TxHash): Promise<WithdrawalStatus>
Input
h: aWithdrawalWaitable(e.g., fromcreate) or the L2 tx hashHex.
| Phase | Meaning |
|---|---|
UNKNOWN | Handle doesn’t contain an L2 hash yet. |
L2_PENDING | L2 tx not yet included. |
PENDING | L2 included, not yet ready to finalize on L1. |
READY_TO_FINALIZE | Finalization on L1 would succeed now. |
FINALIZED | Finalized on L1; funds released. |
- No L2 receipt ⇒
L2_PENDING. - Finalization key derivable but not ready ⇒
PENDING. - Already finalized ⇒
FINALIZED.
withdrawals-status.ts
withdrawals.wait(h | l2TxHash, { for, pollMs?, timeoutMs? })
Targets
| Target | Resolves with |
|---|---|
{ for: 'l2' } | L2 receipt (TransactionReceipt | null) |
{ for: 'ready' } | null when finalization becomes possible |
{ for: 'finalized' } | L1 receipt when finalized, or null if finalized but receipt not found |
- If the handle has no L2 hash, returns
nullimmediately. - Default polling: 5500 ms (override via
pollMs). timeoutMsreturnsnullon deadline.
withdrawals-wait.ts
Deposits
deposits.status(h | l1TxHash): Promise<DepositStatus>
Input
h:DepositWaitable(fromcreate) or L1 tx hashHex.
| Phase | Meaning |
|---|---|
UNKNOWN | No L1 hash present on the handle. |
L1_PENDING | L1 receipt missing. |
L1_INCLUDED | L1 included; L2 hash not yet derivable from logs. |
L2_PENDING | L2 hash known but L2 receipt missing. |
L2_EXECUTED | L2 receipt present with status === 1. |
L2_FAILED | L2 receipt present with status !== 1. |
deposits-status.ts
deposits.wait(h | l1TxHash, { for: 'l1' | 'l2' })
Targets
| Target | Resolves with |
|---|---|
{ for: 'l1' } | L1 receipt or null |
{ for: 'l2' } | L2 receipt or null (waits L1 inclusion then L2 execution) |
deposits-wait.ts
wait(..., { for: 'l2' }) waits for both L1 inclusion and canonical L2 execution.Practical patterns
Pick the right tool
- Use
status(...)for poll-less UI refreshes (e.g., on page focus or interval timers you control). - Use
wait(...)for workflow gating (scripts, jobs, “continue when X happens”).
Timeouts & polling
polling.ts
Error handling
- Network hiccup while fetching receipts ⇒ throws
ZKsyncErrorof kindRPC. - Internal decode issue ⇒ throws
ZKsyncErrorof kindINTERNAL.
no-throw.ts
Tips & edge cases
- Handles vs hashes: Passing a handle without the relevant hash yields
UNKNOWN/null. If you already have a hash, pass the hash directly. - Finalization windows: For withdrawals,
READY_TO_FINALIZEcan take a while. Usestatus(...)to keep the UI responsive andwait(..., { for: 'finalized' })only where blocking makes sense. - Retries: If a wait returns
nulldue totimeoutMs, you can safely callstatus(...)to decide whether to keep waiting or surface guidance to the user.