API Reference
Complete reference of all public exports from @zerc20/client-sdk.
Core
createSdk
(options?: Zerc20SdkOptions)
Zerc20Sdk
Create SDK instance
Zerc20Sdk
class
-
Main SDK, bundles WASM, proof, decider, stealth
Zerc20SdkOptions
interface
-
Options: wasm?, teleportProofs?, decider?, stealth?
EVM Providers
Library-agnostic interfaces for EVM interaction. viem's PublicClient and WalletClient satisfy these structurally -- no adapter required.
EvmReadProvider
interface
Read-only provider: readContract, optional getBalance, estimateFeesPerGas, getGasPrice, waitForTransactionReceipt, getTransaction, getTransactionReceipt
EvmWriteProvider
interface
Write provider: writeContract, optional account, chain
Hex
type
Hex-encoded string with 0x prefix (\0x${string}``)
ICP / Stealth
StealthCanisterClient
class
-
ICP canister client for announcements, invoices, keys
StealthClientFactory
class
-
Factory for creating StealthCanisterClient instances
StealthClientConfig
interface
-
Config: agent, storageCanisterId, keyManagerCanisterId
createAuthorizationPayload
(client, address, ttlSeconds?)
Promise<AuthorizationPayload>
Create auth payload for VetKey request
requestVetKey
(client, address, payload, signature)
Promise<VetKey>
Request and decrypt VetKey
scanReceivingsForRecipient
(params: ScanReceivingsForRecipientParams)
Promise<ScannedAnnouncement[]>
Scan, decrypt, and keep only announcements whose decoded recipient matches expectedRecipientAddress
scanReceivingsByTimeForRecipient
(params: ScanReceivingsByTimeForRecipientParams)
Promise<ScannedAnnouncement[]>
Scan by listAnnouncementsByTime / nextTs, decrypt, and keep only announcements whose decoded recipient matches expectedRecipientAddress
scanReceivings
(params: ScanReceivingsParams)
Promise<ScannedAnnouncement[]>
Deprecated compatibility API that scans and decrypts announcements without recipient validation
Private Send
preparePrivateSend
(params: PreparePrivateSendParams)
Promise<PreparedPrivateSend>
Derive burn address and encrypt announcement
submitPrivateSendAnnouncement
(params: SubmitPrivateSendParams)
Promise<PrivateSendResult>
Submit announcement to storage canister
submitPrivateSendTransfer
(params: SubmitPrivateSendTransferParams)
Promise<{ transactionHash: Hex }>
Execute ERC-20 transfer to burn address
Invoice
prepareInvoiceIssue
(params: InvoiceIssueParams)
Promise<InvoiceIssueArtifacts>
Generate invoice with burn addresses
submitInvoice
(client, invoiceIdHex, signature, tag?)
Promise<void>
Submit signed invoice
listInvoices
(client, ownerAddress, chainId?, tag?)
Promise<string[]>
List invoice IDs
isSingleInvoiceHex
(invoiceIdHex: string)
boolean
Check if an invoice ID is single (not batch)
isSingleInvoiceBytes
(invoiceBytes: Uint8Array)
boolean
Check if invoice bytes represent a single invoice
Liquidity
wrapWithLiquidityManager
(params: WrapWithLiquidityManagerParams)
Promise<LiquidityActionResult>
Wrap underlying to zERC20
unwrapWithLiquidityManager
(params: LocalUnwrapParams)
Promise<LiquidityActionResult>
Unwrap zERC20 to underlying
quoteLocalUnwrap
(params)
Promise<LocalUnwrapQuote>
Quote unwrap fee
buildCrossUnwrapQuote
(params)
Promise<CrossUnwrapQuote>
Quote cross-chain unwrap
sendCrossUnwrap
(params)
Promise<LiquidityActionResult>
Execute cross-chain unwrap
fetchLiquidityManagerBalances
(params)
Promise<LiquidityBalances>
Get token balances and decimals
fetchAdaptorBalances
(params)
Promise<AdaptorBalances>
Get stuck fund balances from an adaptor contract
hasStuckFunds
(params)
Promise<boolean>
Check if any funds are stuck in an adaptor
withdrawFromAdaptor
(params: AdaptorWithdrawParams)
Promise<{ transactionHash: string }>
Withdraw stuck funds from an adaptor
NATIVE_TOKEN_ADDRESS
constant
`0x${string}`
Native token sentinel address (0xEeee...)
removeDust
(amount, conversionRate)
bigint
Remove dust from amount based on decimal conversion
Receive
collectRedeemContext
(params: RedeemContextParams)
Promise<RedeemContext>
Collect eligible events + proofs for redeem
createVerifierReader
(provider: EvmReadProvider, address: string)
ReadableVerifierContract
Create verifier contract reader from a provider
createLocalRootReader
(provider: EvmReadProvider, address: string)
LocalRootReaderContract
Create a Verifier local-root reader for teleportMode: "local"
buildLocalAggregationState
(params: BuildLocalAggregationStateParams)
Promise<AggregationTreeState>
Build synthetic aggregation state from Verifier local proved roots
prepareRedeemTransactionForRecipient
(params: PrepareRedeemTransactionForRecipientParams)
Promise<RedeemTransaction>
Validate the expected recipient, generate proof, and assemble redeem transaction
prepareRedeemTransaction
(params: PrepareRedeemTransactionParams)
Promise<RedeemTransaction>
Deprecated compatibility API that prepares redeem calldata without recipient validation
buildBatchRedeemTransactionForRecipient
(params)
RedeemTransaction
Validate the expected recipient and build batch redeem from pre-existing Decider proof
buildBatchRedeemTransaction
(params)
RedeemTransaction
Deprecated compatibility API that builds batch redeem calldata without recipient validation
submitRedeemTransaction
(params: SubmitRedeemTransactionParams)
Promise<{ transactionHash: Hex }>
Sign and submit redeem transaction on-chain
getAnnouncementStatus
(params: AnnouncementStatusParams)
Promise<AnnouncementStatus>
Lightweight status check
New receive/redeem flows should pass the wallet address as expectedRecipientAddress to the ForRecipient APIs. The legacy APIs remain exported for compatibility but are deprecated because they do not verify that decoded burn payloads or redeem calldata match the caller's intended recipient address.
collectRedeemContext and getAnnouncementStatus include Verifier-sourced redeem fee data:
redeemFeeBps
number
Current redeem fee in basis points
feeRecipient
string
Wallet authorized to withdraw accrued Verifier redeem fees
redeemableDiff
bigint
totalEligibleValue - totalTeleported, clamped to 0
redeemFee
bigint
Fee quoted by quoteRedeemFee(redeemableDiff)
redeemNetValue
bigint
Amount after redeem fee, before relayer fee
redeemBlockedReason
string | undefined
"amount_too_small" when redeem should be blocked before tx submission
SDK 0.5.0+ requires destination Verifiers to expose redeem-fee views (redeemFeeBps, quoteRedeemFee, redeemFeeBalance, and feeRecipient). Missing views or failed redeem-fee reads are surfaced as errors instead of being treated as a zero-fee redeem. Callers should retry or show the read failure instead of displaying stale or fee-free quotes.
collectRedeemContext, getAnnouncementStatus, prepareRedeemTransactionForRecipient, prepareRedeemTransaction, buildBatchRedeemTransactionForRecipient, and buildBatchRedeemTransaction accept teleportMode?: "global" | "local".
"global"
Hub aggregation state
isGlobal=true, rootHint=latestAggSeq
"local"
Each Verifier's latestProvedIndex / provedTransferRoots
isGlobal=false, rootHint=treeIndex
Use "global" for normal cross-chain redeem. Use "local" only for a local-only single-chain redeem path where the token should settle against its own Verifier without waiting for the Hub aggregation root. Global mode requires hub; local mode skips Hub reads, so hub is optional and verifierContractsByChain is required on collectRedeemContext / getAnnouncementStatus. Build those readers with createLocalRootReader. Current redeem transaction preparation supports local mode only when all eligible events are on the primary chain (redeemContext.token.chainId).
chainErrorPolicy defaults to "fail-fast" for context/status collection. Use "log-and-continue" only for pollers that can treat unreachable chains as inconclusive instead of terminal.
Relay
Relay-node HTTP helpers for gasless redeem and token-to-native swap flows.
SDK relay helpers take a token-scoped relay base URL as relayUrl. Include the /relayer/<token> suffix in the URL; the SDK appends /relay/... paths internally.
Hosted relay URLs:
Environment
Token
relayUrl
Prod / mainnet
zUSDC
https://v1.mainnet.api.zerc20.io/relayer/zusdc
Prod / mainnet
zETH
https://v1.mainnet.api.zerc20.io/relayer/zeth
Prod / mainnet
zBNB
https://v1.mainnet.api.zerc20.io/relayer/zbnb
Prod / mainnet
zJPYC
https://v1.mainnet.api.zerc20.io/relayer/zjpyc
For example, pass https://v1.mainnet.api.zerc20.io/relayer/zusdc, not https://v1.mainnet.api.zerc20.io.
submitRelayTeleport
(relayUrl, params: RelayTeleportParams, options?)
Promise<RelayResult>
Submit a redeem/teleport request to a relay node
estimateRelayFee
(relayUrl, chainId, options?)
Promise<RelayFeeEstimate>
Ask the relay node for the current redeem fee quote
verifyRelayFeeEstimate
(params: VerifyRelayFeeEstimateParams)
Promise<RelayFeeEstimate>
Verify a relay fee quote against the destination Verifier's on-chain redeemFeeBps()
estimateRelayFeeVerified
(params: VerifiedRelayFeeEstimateParams)
Promise<RelayFeeEstimate>
Fetch a relay fee quote and verify its redeemFeeBps on-chain before signing
fetchSwapQuote
(relayUrl, params: SwapQuoteParams, options?)
Promise<SwapQuote>
Quote a zERC20-to-native swap
submitRelaySwap
(relayUrl, params: RelaySwapParams, options?)
Promise<SwapResult>
Submit a signed permit-based swap request
RedeemFeeBpsDriftError (class)
-
Error
Thrown by submitRelayTeleport when a relay reports that the Verifier redeem fee changed after quoting
RelayFeeEstimateMismatchError (class)
-
Error
Thrown when a relay fee quote's redeemFeeBps does not match the Verifier's on-chain value
RelayFeeEstimate includes both relayerFee and redeemFeeBps. Before asking the user to sign RelayerFeeAuthorization, prefer estimateRelayFeeVerified() or call verifyRelayFeeEstimate() on a quote returned by estimateRelayFee(). Pass the verified redeemFeeBps into submitRelayTeleport; if it drifts, re-quote and ask the user to sign a new authorization.
Relay integrations should assume supported Verifier deployments expose redeem-fee views. In SDK 0.6.0+, if a relay cannot read the Verifier fee data, or if /relay/fee-estimate omits redeemFeeBps, treat the quote as unavailable and ask the user to retry rather than submitting with a zero-fee fallback. Relay quote parsing also rejects negative amount strings and invalid basis-point values.
If you read a relay's informational /relay/info response directly, treat a missing redeemFeeBpsByChain[chainId] entry as unavailable. Do not default missing entries to 0 bps; the single-chain /relay/fee-estimate endpoint is the authoritative quote for gasless redeem.
For Kaia/Kairos zJPYC Get Gas, the relay computes zJPYC -> KAIA quotes from two Chainlink feeds: JPY/USD on Ethereum mainnet and KAIA/USD on Arbitrum mainnet. Relay deployments that serve Kaia/Kairos quotes must set ORACLE_ARBITRUM_RPC_URL in addition to the Ethereum oracle RPC.
Chain Metadata
getChainMetadata
(chainId: number | bigint)
ChainMetadata | undefined
Get metadata for a chain ID
getChainDisplayName
(chainId: number | bigint)
string
Human-readable chain name (e.g., "Ethereum", "Arbitrum")
getChainShortName
(chainId: number | bigint)
string | undefined
Short chain label (e.g., "ETH", "ARB")
getExplorerTxUrl
(chainId: number | bigint, txHash: string)
string | undefined
Block explorer URL for a transaction
resolveChainId
(name: string)
number | undefined
Resolve chain ID from name or alias
resolveNetworkDisplayName
(label: string)
string
Resolve human-readable name from chain label
SDK 0.7.1+ includes Kaia chain metadata:
Kaia
8217
https://kaiascan.io
kaia, kaia-mainnet, klaytn
Kairos
1001
https://kairos.kaiascan.io
kairos, kaia-kairos, kairos-testnet, baobab
LayerZero Scan
Cross-chain message tracking via the LayerZero Scan API. See LayerZero Scan for full documentation.
fetchWalletStatus
(params: FetchWalletStatusParams)
Promise<WalletStatusResult>
Fetch and decode all LZ messages for a wallet
fetchWalletMessages
(config, address, params?)
Promise<ScanMessagesResponse>
Raw LZ Scan API: wallet messages
fetchTxMessages
(config, txHash)
Promise<ScanMessagesResponse>
Raw LZ Scan API: messages for a transaction
getWalletMessagesUrl
(config, address)
string
Build LZ Scan explorer URL
tryDecodeBridgeRequest
(composeMsg: Hex)
BridgeRequestSummary | null
Decode a compose message as a bridge request
decodeSendSummary
(data: Hex)
SendPayloadSummary
Decode an OFT send payload
fetchOftSentAmount
(provider, txHash)
Promise<bigint | undefined>
Read OFTSent amount from transaction logs
decorateSendSummary
(summary, token?, fetchMetadata?)
decorated summary
Enrich send summary with token metadata
endpointChain
(endpoint, direction)
string
Chain name from LZ endpoint
destinationTx
(message)
string | undefined
Extract destination tx hash
summarizeBlock
(message, direction)
string
Summarize block info
formatPathway
(message)
string
Format src → dst pathway
isMessageForTokens
(message, tokens)
boolean
Check if message involves given tokens
findTokenForMessage
(message, tokens)
TokenEntry | undefined
Find matching token for a message
Onchain
readTokenBalance
(provider, tokenAddress, account)
Promise<bigint>
Read ERC-20 balance via provider
readTokenDecimals
(provider, tokenAddress)
Promise<number>
Read ERC-20 decimals via provider
readDecimalConversionRate
(provider, tokenAddress)
Promise<bigint>
Read zERC20 decimal conversion rate
isBlockedAddress
(provider, blocklistAddress, account)
Promise<boolean>
Check if an address is on the OFAC sanctions blocklist
decodeSendPayload
(data: Hex)
DecodedSendPayload
Decode OFT send() calldata
extractOftSentAmount
(logs)
bigint | undefined
Extract OFTSent amount from tx logs
decodeBridgeRequest
(composeMsg: Hex)
DecodedBridgeRequest | null
Decode a bridge compose message
Proofs
TeleportProofClient
class
-
High-level proof client exposed as sdk.teleportProofs
createTeleportProofClient
(options?: TeleportProofClientOptions)
TeleportProofClient
Create a standalone teleport proof client
ProofService
class
-
ZK proof service for single and batch redemption
ProofServiceOptions
interface
-
Options for worker offload and proof execution
HttpDeciderClient
class
-
Decider service HTTP client
TeleportProofClient methods are called through sdk.teleportProofs or a value returned by createTeleportProofClient():
createSingleTeleportProof
(params: SingleTeleportParams)
Promise<SingleTeleportArtifacts>
Generate a global-mode single Groth16 proof
createSingleLocalTeleportProof
(params: SingleLocalTeleportParams)
Promise<SingleTeleportArtifacts>
Generate a local-mode single Groth16 proof
createNovaProof
(params: NovaProverInput)
Promise<NovaProverOutput>
Generate a global-mode Nova IVC proof
createNovaLocalProof
(params: LocalNovaProverInput)
Promise<NovaProverOutput>
Generate a local-mode Nova IVC proof
requestDeciderProof
(decider, ivcProof, mode?)
Promise<Uint8Array>
Request withdraw_global or withdraw_local Decider proof
WASM
WasmRuntime
class
-
WASM lifecycle manager
getSeedMessage
()
Promise<string>
Get message to sign for seed derivation
deriveSeed
(signMessage)
Promise<string>
Derive the canonical seed using a sign callback (canonicalizes the signature before hashing)
deriveSeedCandidates
(signMessage)
Promise<string[]>
Derive every seed a key could have produced (order not significant) for backward-compatible invoice fund discovery
derivePaymentAdvice
(seedHex, paymentAdviceIdHex, chainId, address)
Promise<SecretAndTweak>
Derive payment advice
deriveInvoiceSingle
(seedHex, invoiceIdHex, chainId, address)
Promise<SecretAndTweak>
Derive the secret and tweak for a single invoice
deriveInvoiceBatch
(seedHex, invoiceIdHex, subId, chainId, address)
Promise<SecretAndTweak>
Derive the secret and tweak for one entry in a batch invoice
buildFullBurnAddress
(chainId, address, secret, tweak)
Promise<BurnArtifacts>
Build burn address
decodeFullBurnAddress
(fullBurnAddressHex)
Promise<BurnArtifacts>
Decode burn address
Registry
normalizeTokens
(file: TokensFile)
NormalizedTokens
Normalize raw token config
normalizeTokensWithOverrides
(file: TokensFile, overrides?: RpcOverrides)
NormalizedTokens
Normalize with RPC URL overrides
findTokenByChain
(tokens, chainId)
TokenEntry
Find token by chain ID
TokensCacheManager
class
-
Cache manager for compressed token loading
Contract Artifacts
The SDK exports ABI artifacts for on-chain contracts. These can be used with any EVM library for direct contract interaction.
Zerc20Artifact
zERC20 token contract ABI
VerifierArtifact
Verifier contract ABI
HubArtifact
Hub contract ABI
LiquidityManagerArtifact
LiquidityManager contract ABI
AdaptorArtifact
Adaptor contract ABI
BlocklistArtifact
Blocklist contract ABI (OFAC sanctions registry)
Utilities
buildFeeOverrides
(provider: EvmReadProvider)
Promise<FeeOverrides>
Build gas fee overrides from provider
isHex
(value: unknown)
boolean
Check if value is a valid 0x-prefixed hex string
keccak256
(input)
Hex
Compute keccak256 hash
Types
Key exported types and interfaces:
EvmReadProvider-- Library-agnostic read-only EVM provider interface.EvmWriteProvider-- Library-agnostic write EVM provider interface.Hex-- Hex-encoded string type (\0x${string}``).SecretAndTweak-- Secret and tweak pair derived from payment advice.GeneralRecipient-- Recipient descriptor used across send and invoice flows.BurnArtifacts-- Artifacts produced when building or decoding a burn address.PreparedPrivateSend-- Fully prepared private send, ready for on-chain transfer and announcement submission.PrivateSendResult-- Result after submitting a private send announcement.SubmitPrivateSendTransferParams-- Parameters for the ERC-20 transfer step.InvoiceIssueArtifacts-- Artifacts from invoice preparation, including burn addresses and encrypted data.InvoiceBatchBurnAddress-- A single burn address within a batch invoice.ScannedAnnouncement-- A decrypted announcement discovered during scanning.ScanReceivingsForRecipientParams-- ID-cursor scanning parameters with recipient validation.ScanReceivingsByTimeForRecipientParams-- Time-cursor scanning parameters with recipient validation.AggregationTreeState-- State of the cross-chain aggregation Merkle tree.GlobalTeleportProof-- A proof valid against the global (aggregated) tree root.LocalTeleportProof-- A proof valid against a single chain's local transfer root.IndexedEvent-- An on-chain transfer event as indexed by the indexer.SingleTeleportArtifacts-- Artifacts for a single Groth16 teleport proof.SingleTeleportParams-- Parameters for generating a single teleport proof.SingleLocalTeleportParams-- Parameters for generating a single local-mode teleport proof.NovaProverInput-- Input to the Nova batch prover.LocalNovaProverInput-- Input to the local-mode Nova batch prover.NovaProverOutput-- Output from the Nova batch prover.TeleportMode--"global"or"local"redeem proof/root mode.RedeemContext-- Full context needed to execute a redeem (events, proofs, chain data).RedeemTransaction-- Prepared transaction data for on-chain redeem submission.ReadableVerifierContract-- Verifier contract interface forreadContract-based reads.DirectVerifierContract-- Verifier contract interface for ethers-like direct-method wrappers.LegacyVerifierContract-- Deprecated compatibility alias forDirectVerifierContract.OnChainGeneralRecipient-- On-chain representation of a general recipient.AnnouncementStatus-- Lightweight status of an announcement (pending, redeemable, redeemed).RelayerFeeAuthorization-- EIP-712 authorization that lets a relay redeem on the recipient's behalf while capping the fee it may keep.RelayTeleportParams-- Request body for relay-node redeem submission.RelayFeeEstimate-- Relay quote containingrelayerFeein the token's smallest unit and the VerifierredeemFeeBpsused for drift protection.VerifyRelayFeeEstimateParams-- Parameters for checking an existing relay fee quote against a destination Verifier reader.VerifiedRelayFeeEstimateParams-- Parameters for fetching and verifying a relay fee quote in one helper call.RelaySwapParams-- Request body for relay-node token-to-native swap submission.SwapQuote-- Swap quote returned by the relay node, includingpriceFallback.EventsWithEligibility-- Events annotated with their eligibility for redemption.TokenEntry-- A single token's deployment configuration.HubEntry-- Hub contract deployment configuration.TokensFile-- Raw deserialized token configuration file.NormalizedTokens-- Normalized token configuration with parsedbigintfields.RpcOverrides-- Map of chain label to RPC URL fornormalizeTokensWithOverrides.ChainMetadata-- Chain metadata (name, short name, explorer URL, etc.).LayerZeroScanConfig-- Configuration for LZ Scan API (baseUrl, apiKey).FetchWalletStatusParams-- Parameters forfetchWalletStatus.LayerZeroMessageSummary-- Decoded summary of a LayerZero message.WalletStatusResult-- Result offetchWalletStatusincluding messages and pagination.AdaptorBalances-- Balances stuck in an adaptor contract (underlying, zERC20, native).AdaptorWithdrawParams-- Parameters forwithdrawFromAdaptor(writeProvider, adaptorAddress, token, amount).FeeOverrides-- Gas fee overrides (gasPrice, maxFeePerGas, maxPriorityFeePerGas).
Constants
AGGREGATION_TREE_HEIGHT
6
Aggregation tree levels
TRANSFER_TREE_HEIGHT
40
Per-chain transfer tree levels
GLOBAL_TRANSFER_TREE_HEIGHT
46
Global tree (40 + 6)
NUM_BATCH_INVOICES
10
Burn addresses per batch invoice
Last updated