Wallet Integration
The widget does not bundle a wallet adapter. Instead, it exposes asetWallet() method and a connect-wallet event so you can plug in any wallet solution.
How It Works
- User clicks “Swap” (or “Connect”) with no wallet set
- Widget fires
connect-walletevent - Your app handles the event, connects the wallet, and calls
widget.setWallet(address) - Widget loads balances and enables swapping
setWallet(address)
Set the wallet address programmatically. When called with a non-empty address, the widget fetches native SOL balance and SPL token balances via the configured rpc-url.
connect-wallet Event
Fired when the user clicks the primary button but no wallet is connected. Listen for this to trigger your wallet adapter.
Solana Wallet Adapter (React)
Phantom (Vanilla JS)
Balance Display
OncesetWallet() is called with a valid address, the widget automatically:
- Fetches native SOL balance via
getBalanceRPC call - Fetches all SPL token balances via
getTokenAccountsByOwner - Displays balances next to the selected input/output tokens
- Enables HALF and MAX buttons for quick amount entry
rpc-url attribute (defaults to https://mainnet.fogo.io/).