DocumentationTroubleshooting
DocsProtocol

Find the next step.

Diagnose asset loading, wallet setup, protocol errors, and delayed settlement.

On this page

Asset loading

If the worker fails to initialize, inspect the browser’s Network panel before changing wallet code.

  1. Open /zkapi/browser-config.json and confirm that it returns JSON.
  2. Check /zkapi/assets/zkapiWasmWorker.js and the referenced WASM and proof files.
  3. Ensure the asset paths return their actual files, not your router’s HTML fallback.
  4. Regenerate the assets for the selected deployment.

init() can resolve after a readiness failure. For diagnostics in browser code, call client.ensureReady() and inspect the thrown error.

Wallet and network

Register the provider with purseClient().setWalletProvider(provider) before requesting a wallet operation. Confirm that the connected account and chain match your deployment.

For wallet_rejected, let the person initiate another attempt. For Sepolia access failures, obtain the operator’s testnet access credentials through its normal process.

Error catalog

Map protocol codes to readable messages using the exported catalog. Display the message next to the action that failed.

Read an error message
TypeScript
import { getErrorCatalogEntry } from "@openzk.app/purse";

const entry = getErrorCatalogEntry(errorCode);
// entry.code, entry.userMessage, entry.action, entry.severity
Protocol error catalog
CodeRecovery actionMessage
stale_rootresync_retryYour balance check is out of date. Refreshing now.
replayfresh_retryThat request was already counted. Sending a new one.
native_quote_expiredfresh_retryThe price changed. Getting a fresh one.
native_quote_supersededfresh_retryThe price changed. Getting a fresh one.
nullifier_usedhaltThis balance was already spent somewhere else.
lease_pendingbackoffFinishing up the last request. One moment.
note_expiredroute_exitThis balance expired. Withdraw any remaining funds.
invalid_proofhaltSomething went wrong verifying your balance. Nothing was charged.
protocol_mismatchhaltThis app needs a refresh. Reload the page.
invalid_requesthaltThat request could not be sent. Try again.
oa_minute_request_limitbackoffThe service is busy. Trying again in a moment.
oa_hourly_issuance_budgetbackoffThe service is busy right now. Please try again later.
oa_rate_limitedbackoffThe service is busy. Trying again in a moment.
capacity_exhaustedbackoffTemporarily unavailable. Please try again shortly.
network_errorhaltConnection lost. Check your internet and try again.
upstream_errorhaltThe model service reported a problem. You only pay for what was used.
insufficient_chat_balancehaltThis purchase costs more than your private balance. Fund a larger balance, then try again.
wallet_rejectedhaltThe wallet request was declined. Nothing was sent.

Unknown codes use the catalog’s fallback message and halt action.

Retry policy

The exported executeWithSingleRetry helper retries once for catalog actions resync_retry and fresh_retry. Supply a recovery callback to refresh whatever state the operation requires.

backoff, halt, and route_exit return a failure result from this helper. They are not automatically retried, delayed, or redirected. The payment hooks do not wrap every action in this retry helper.

Settlement

Inference streaming and note settlement are separate phases. The burn hook releases the lease, asks for settlement, and briefly waits for the refreshed balance to decrease before recording the cost.

If that balance update has not arrived, the receipt can show settled onchain without a resolved local cost. Treat that display as pending cost information, not proof of a free request.

Client API

Read the lease lifecycle and state-subscription APIs.

Documentation for the OpenZK browser toolkit. Report a documentation issue ↗