Built-in UI (Beta)
Swap Interface
showSwapUI()
Opens the AIR Kit swap interface, allowing users to exchange tokens directly within your application.
Method Signature:
tsx
public async showSwapUI(): Promise<{ txHash: `0x${string}` }>
Returns:
tsx
{
txHash: string; // The transaction hash of the swap transaction
}
Usage:
tsx
try {
const result = await airService.showSwapUI();
console.log("Swap completed! Transaction hash:", result.txHash);
} catch (error) {
console.error("Swap failed:", error);
}
What happens during swap:
- Opens the swap interface
- User selects token and amount to swap
- User confirms the swap transaction
- Returns the transaction hash upon successful completion
Requirements:
- User must be logged in
Important Notes:
- Experimental feature: This method is marked as experimental and may change in future versions
- Chain support: Currently only supported on Base network
- User experience: Opens a full swap interface with token selection, amount input, and slippage settings.
- Advanced control: For more control over the swap flow, use the RPC method
air_getSwapQuote
andair_sendSwapTransaction
to specify exact token addresses, amounts, and slippage settings
On-Ramp Interface
showOnRampUI()
Opens the AIR Kit on-ramp interface, allowing users to purchase cryptocurrency with fiat currency.
Method Signature:
tsx
public async showOnRampUI(options: {
displayCurrencyCode: string;
targetCurrencyCode?: string;
}): Promise<void>
Parameters:
tsx
{
displayCurrencyCode: string; // Fiat currency code (e.g., "USD", "EUR")
targetCurrencyCode?: string; // Optional target cryptocurrency (e.g., "ETH", "USDC")
}
Usage:
tsx
try {
await airService.showOnRampUI({
displayCurrencyCode: "USD",
targetCurrencyCode: "USDC"
});
console.log("On-ramp interface opened");
} catch (error) {
console.error("Failed to open on-ramp:", error);
}
What happens during on-ramp:
- Opens the on-ramp interface
- User selects payment method and amount
- User completes the fiat-to-crypto purchase
- Cryptocurrency is deposited to their wallet
Requirements:
- User must be logged in
Important Notes:
- Experimental feature: This method is marked as experimental and may change in future versions
- No return value: This method doesn't return a transaction hash as the purchase is handled by the on-ramp provider
- Currency support: Supported currencies depend on the on-ramp provider configuration