Payment.ts
This module provides the agnostic promise-based public client.
Added in v0.4.0
layers
Section titled “layers”layerSingleChain
Section titled “layerSingleChain”A Layer projecting the concrete wallet and public clients for a single
chain over the direction-based client tags.
Signature
export declare const layerSingleChain: <E1, E2, R1 = never, R2 = never>(options: { walletClient: Layer.Layer<WalletClient.WalletClient, E1, R1> publicClient: Layer.Layer<PublicClient.PublicClient, E2, R2>}) => Layer.Layer< | WalletClient.SourceWalletClient | WalletClient.DestinationWalletClient | WalletClient.WalletClient | PublicClient.SourcePublicClient | PublicClient.DestinationPublicClient | PublicClient.PublicClient, E1 | E2 | Error.SdkError, R1 | R2>Added in v0.4.0
models
Section titled “models”CreateBatchPaymentPayee (interface)
Section titled “CreateBatchPaymentPayee (interface)”Input for a single payee in a batch payment.
Signature
export interface CreateBatchPaymentPayee { /** The recipient's address */ readonly address: Domain.Erc20Address /** Amount in the token's smallest unit (e.g., 1 USDC = 1000000) */ readonly amount: bigint}Added in v0.3.2
CreateBatchPaymentResult (interface)
Section titled “CreateBatchPaymentResult (interface)”Output from createBatchPayment for a single payee.
Contains the generated payment key and deposit address needed for the batch transfer and later redemption.
Signature
export interface CreateBatchPaymentResult { /** Secret key for this payment - required for redemption */ readonly paymentKey: Domain.PaymentKey /** Deposit address containing the zAsset address for transfers */ readonly depositAddress: DepositAddress /** The recipient's address */ readonly beneficiary: Domain.Erc20Address /** Amount in the token's smallest unit */ readonly amount: bigint}Added in v0.3.2
DepositAddress (interface)
Section titled “DepositAddress (interface)”Signature
export interface DepositAddress { readonly beneficiaries: [Domain.Erc20Address, Domain.Erc20Address, Domain.Erc20Address, Domain.Erc20Address] readonly zAssetAddress: Domain.ZAssetAddress readonly destinationChainId: Domain.UniversalChainId}Added in v0.4.0
DepositOptions (interface)
Section titled “DepositOptions (interface)”Signature
export interface DepositOptions { readonly depositAddress: DepositAddress /** Amount to deposit (in underlying token's smallest unit) */ readonly amount: bigint readonly srcErc20Address: Domain.Erc20Address readonly destinationChainId: Domain.UniversalChainId}Added in v0.4.0
Proof (interface)
Section titled “Proof (interface)”Signature
export interface Proof { proof: Prover.Proof metadata: { depositAddress: Domain.ZAssetAddress beneficiary: Domain.Erc20Address value: bigint lightClients: LightClientData[] nullifier: Domain.Nullifier }}Added in v0.4.0
RedeemOptions (interface)
Section titled “RedeemOptions (interface)”Signature
export interface RedeemOptions { /** The 32-byte secret payment key as a hex string */ paymentKey: PS.Hex /** Array of 0-4 beneficiary addresses */ beneficiaries: Address[] /** The beneficiary address to redeem to */ beneficiary: Address /** Amount to redeem */ amount: bigint /** Light client IDs to include in the proof (for anonymity set) */ clientIds: number[] /** The specific light client ID to use for the proof */ selectedClientId: number /** Auto unwrap */ unwrap?: boolean | undefined}Added in v0.4.0
computeStorageSlot
Section titled “computeStorageSlot”Signature
export declare const computeStorageSlot: ( address: `0x${string}`, mappingSlot: bigint) => Effect.Effect< `0x${string}`, [YieldWrap<Effect.Effect<`0x${string}`, never, never>>] extends [never] ? never : [YieldWrap<Effect.Effect<`0x${string}`, never, never>>] extends [ YieldWrap<Effect.Effect<infer _A, infer E, infer _R>> ] ? E : never, [YieldWrap<Effect.Effect<`0x${string}`, never, never>>] extends [never] ? never : [YieldWrap<Effect.Effect<`0x${string}`, never, never>>] extends [ YieldWrap<Effect.Effect<infer _A, infer _E, infer R>> ] ? R : never>Added in v0.4.0
createBatchPayment
Section titled “createBatchPayment”Create payment keys and deposit addresses for multiple payees at once.
This is the first step in a batch payment flow:
- Call
createBatchPayment()to generate keys and addresses for each payee - Call
walletClient.prepareWrap()to prepare approve/wrap transactions - Execute the batch transfer to all deposit addresses
- Later, each payee can redeem using their payment key
Signature
export declare const createBatchPayment: (options: { payees: ReadonlyArray<CreateBatchPaymentPayee> destinationChainId: Domain.UniversalChainId}) => Effect.Effect.AsEffect<Effect.Effect<CreateBatchPaymentResult[], Error.SdkError, never>>Added in v0.3.2
deterministicShuffleClients
Section titled “deterministicShuffleClients”Deterministically shuffle light clients using the secret as seed. The same secret always produces the same ordering for privacy.
Signature
export declare function deterministicShuffleClients(clients: LightClientData[], secret: PS.Hex): LightClientData[]Added in v0.4.0
generateKey
Section titled “generateKey”Signature
export declare const generateKey: Effect.Effect<Domain.PaymentKey, Error.SdkError, never>Added in v0.4.0
generateProof
Section titled “generateProof”Signature
export declare const generateProof: (options: { paymentKey: Domain.PaymentKey beneficiary: Domain.Erc20Address amount: bigint clientIds: number[] selectedClientId: number nullifier: Domain.Nullifier depositAddress: DepositAddress srcChainId: Domain.UniversalChainId srcErc20Address: Domain.Erc20Address dstErc20Address: Domain.Erc20Address}) => Effect.Effect< Proof, Error.SdkError, PublicClient.SourcePublicClient | PublicClient.DestinationPublicClient | PublicClient.PublicClient | Prover.Prover>Added in v0.4.0
getDepositAddress
Section titled “getDepositAddress”Signature
export declare const getDepositAddress: (options: { paymentKey: Domain.PaymentKey beneficiaries: ReadonlyArray<Domain.Erc20Address> destinationChainId: Domain.UniversalChainId}) => Effect.Effect.AsEffect< Effect.Effect< { beneficiaries: [Domain.Erc20Address, Domain.Erc20Address, Domain.Erc20Address, Domain.Erc20Address] zAssetAddress: Domain.ZAssetAddress destinationChainId: string & Brand<"UniversalChainId"> }, Error.SdkError, never >>Added in v0.4.0
getNullifier
Section titled “getNullifier”Signature
export declare const getNullifier: (options: { paymentKey: Domain.PaymentKey destinationChainId: Domain.UniversalChainId}) => Effect.Effect<Domain.Nullifier, Error.SdkError, never>Added in v0.4.0
prepareDeposit
Section titled “prepareDeposit”Signature
export declare const prepareDeposit: ( options: DepositOptions) => Effect.Effect.AsEffect< Effect.Effect< readonly [ { readonly _tag: "PreparedEvm" readonly kind: "Erc20.Approve" | "Erc20.Wrap" | "ZAsset.Transfer" | "LoopbackClient.Update" readonly universalChainId: Domain.UniversalChainId readonly contractAddress: Domain.Erc20Address readonly abi: Abi readonly functionName: string readonly args: ReadonlyArray<unknown> }, ...{ readonly _tag: "PreparedEvm" readonly kind: "Erc20.Approve" | "Erc20.Wrap" | "ZAsset.Transfer" | "LoopbackClient.Update" readonly universalChainId: Domain.UniversalChainId readonly contractAddress: Domain.Erc20Address readonly abi: Abi readonly functionName: string readonly args: ReadonlyArray<unknown> }[] ], Error.SdkError, WalletClient.SourceWalletClient >>Added in v0.4.0
prepareRedemption
Section titled “prepareRedemption”Signature
export declare const prepareRedemption: (options: { universalChainId: Domain.UniversalChainId dstErc20Address: Domain.Erc20Address attestation: Attestor.Attestation proof: Proof}) => Effect.Effect<Domain.PreparedRequest, Error.SdkError, WalletClient.DestinationWalletClient>Added in v0.4.0