@cosmosapp/pay_sdkDefinitionenWeb

WebClient

The browser wallet client that detects the user's Stellar wallet, then builds, signs and submits the transaction. It never touches your secret key.

The browser wallet client that detects the user's Stellar wallet, then builds, signs and submits the transaction. It never touches your secret key.

Constructor

WebClient

constructor(options?: WebClientOptions)

Parameters

  • options (optional): WebClientOptions

Properties

wallets

The wallet adapter registry (auto-detection + custom registration).

readonly wallets: WalletRegistry

Type WalletRegistry

connection

The most recent successful connection (wallet + address + network).

connection: ConnectResult | null

connect

Auto-detect a wallet and connect, returning the account + network. You can skip this and call {@link pay} directly — it connects on demand.

connect(options?: { wallet?: WalletId

network

network?: StellarNetwork

member

}): Promise<ConnectResult>

source

source: string

intent

intent: NormalizedIntent

network

network: NetworkConfig

member

}>

Methods

getAvailableWallets()

Probe and list wallets, flagging which are currently available.

getAvailableWallets(): Promise<WalletInfo[]>

Returns Promise<WalletInfo[]>

registerWallet()

Register a custom wallet adapter (WalletConnect, Ledger, …).

registerWallet(adapter: WalletAdapter, prepend?: boolean): this

Parameters

  • adapter: WalletAdapter
  • prepend (optional): boolean

Returns this

disconnect()

Forget the current connection (and disconnect the adapter if it supports it).

disconnect(): Promise<void>

Returns Promise<void>

pay()

The one-call happy path: detect a wallet, adapt the intent into a transaction, sign it, and (unless told otherwise) broadcast it. Works for both tx intents (signs the returned XDR) and pay intents (builds the payment from the connected account).

pay(input: PayableInput, options?: PayOptions): Promise<PayResult>

Parameters

  • input: PayableInput
  • options (optional): PayOptions

Returns Promise<PayResult>

buildTransaction()

Adapt an intent into an unsigned transaction without signing it. Useful when you want to inspect/confirm the XDR before prompting the wallet.

buildTransaction(input: PayableInput, options?: PayOptions): Promise<{ xdr: string

Parameters

  • input: PayableInput
  • options (optional): PayOptions

Returns Promise<{ xdr: string

createPay()

Create a pay intent directly from the browser. Requires a browser-safe apiKey (trusted environments only). Accepts typed assets (Assets.USDC) and named addresses.

createPay(options: CreatePayPaymentIntentOptions): Promise<PaymentIntentData>

Parameters

  • options: CreatePayPaymentIntentOptions

Returns Promise<PaymentIntentData>

createTx()

Create a tx intent directly from the browser. Requires a browser-safe apiKey (trusted environments only). Accepts typed assets (Assets.USDC) and named addresses.

createTx(options: CreateTxPaymentIntentOptions): Promise<PaymentIntentData>

Parameters

  • options: CreateTxPaymentIntentOptions

Returns Promise<PaymentIntentData>

validate()

Validate a submitted transaction against an intent. Requires an apiKey.

validate(intentId: string, txHash: string): Promise<ValidationOutcomeData>

Parameters

  • intentId: string
  • txHash: string

Returns Promise<ValidationOutcomeData>

Auf dieser Seite