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: WalletRegistryType WalletRegistry
connection
The most recent successful connection (wallet + address + network).
connection: ConnectResult | nullconnect
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?: WalletIdnetwork
network?: StellarNetworkmember
}): Promise<ConnectResult>source
source: stringintent
intent: NormalizedIntentnetwork
network: NetworkConfigmember
}>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): thisParameters
adapter:WalletAdapterprepend(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:PayableInputoptions(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: stringParameters
input:PayableInputoptions(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:stringtxHash:string
Returns Promise<ValidationOutcomeData>