Sample Wallet
For a complete working example, check out our sample wallet implementation:Sample Wallet - Kotlin
A reference Android wallet app demonstrating WalletConnect Pay integration.
Requirements
- Min SDK: 23 (Android 6.0)
- Target SDK: 36
- JVM Target: 11
Installation
Add the WalletConnect Pay SDK to your project’sbuild.gradle.kts file:
The version shown above may not be the latest. Check the GitHub releases for the most recent version.
UnsatisfiedLinkError or class loading issues), explicitly configure the JNA dependency:
Initialization
Initialize the SDK in yourApplication class or before any payment operations:
*Either
apiKey or appId is required for authentication.Don’t have a project ID? Create one at the WalletConnect Dashboard by signing up and creating a new project.
Supported Networks & Tokens
WalletConnect Pay currently supports the following tokens and networks:
All account addresses must be provided in CAIP-10 format:
eip155:<chainId>:<address>
Include accounts for all supported networks to maximize payment options for your users.
Payment Flow
The payment flow consists of five main steps: Get Options -> Collect Data (if required) -> Get Actions -> Sign Actions -> Confirm PaymentGet Payment Options
When a user scans a payment QR code or opens a payment link, fetch available payment options:
Collect User Data (If Required)
After the user selects an option, check for
collectData on it. If present, collect the data before fetching the required actions.Embedded Data Collection Form
When a payment requires user information (e.g., for Travel Rule compliance), the SDK returns acollectData field on individual payment options. Each option may independently require data collection — some options may require it while others don’t.The form is loaded from selectedOption.collectData.url and embedded in your wallet (a WebView on mobile, an iframe on web). It handles field rendering, validation, Terms & Conditions and Privacy Policy acceptance, and submits data directly to the backend.Collect this data before fetching the required actions. For an option that requires Information Capture, getRequiredPaymentActions fails with 400 IC data required until the data has been submitted.Recommended Flow
The recommended approach is to display all payment options upfront, then handle data collection only when the user selects an option that requires it:- Call
getPaymentOptionsand display all available options to the user - Show a visual indicator (e.g., “Info required” badge) on options where
option.collectDatais present - When the user selects an option, check
selectedOption.collectData - If present, load
selectedOption.collectData.urlin the embedded form - Optionally append query parameters to the form URL —
prefill(known user data),theme, andthemeVariables(appearance). See Form URL parameters below. Use proper URL building so existing query parameters are preserved. - Listen for completion messages:
IC_COMPLETE(success) orIC_ERROR(failure) - On
IC_COMPLETE, continue the flow — fetch the required actions, sign, and confirm the payment. Don’t passcollectedDatatoconfirmPayment(); the form submits data directly to the backend
Decision Matrix
Form URL parameters
The form URL accepts the following optional query parameters. Append them toselectedOption.collectData.url before loading it, preserving any existing query parameters.collectData.schema is a JSON schema string — parse it and read its required array to discover the field keys for prefill. For example, a required array of ["fullName", "dob", "pobAddress"] maps to a prefill object of {"fullName": "...", "dob": "...", "pobAddress": "..."}.Customizing the form appearance
theme and themeVariables are optional and independent — pass either, both, or neither:themeswitches the form betweenlightanddarkbase color modes. Match it to your wallet’s active mode for a seamless transition.themeVariablesapplies brand-level overrides (font, font size, select colors, button border radius, and input border radius). Generate the theme in the WalletConnect Pay Dashboard, export it as a base64url string, and append it to the form URL verbatim — you don’t need to encode it at runtime.
The top-level
collectData on the payment options response is still available for backward compatibility. However, the per-option collectData is the recommended approach as it provides more granular control over the flow.WebView Message Types
The WebView communicates with your wallet through JavaScript bridge messages. The message payload is a JSON string with the following structure:Platform-Specific Bridge Names
Get Required Actions
After the user selects a payment option (and any required data collection has completed), get the wallet RPC actions needed to complete the payment:
Sign Actions
Sign each action using your wallet’s signing implementation:
Payment options may include multiple actions with different RPC methods. For example, a Permit2 payment where the user lacks sufficient allowance returns two actions: an
eth_sendTransaction to approve the token allowance, followed by an eth_signTypedData_v4 to sign the Permit2 transfer. Your wallet must check rpc.method (or action.action.method) and dispatch to the appropriate handler. For full implementation guidance, see USDT support.Data Collection Implementation
WhenselectedOption.collectData.url is present, display the URL in a WebView. The WebView handles form rendering, validation, and T&C acceptance.
Data Collection Best Practices
- Display prominently: Show the form full-screen or as a prominent modal so users can interact with it easily
- Loading indicator: Show a loading indicator while the form loads
- Handle errors: Listen for
IC_ERRORmessages and display a user-facing error message with an option to retry - External links: Open Terms & Conditions and Privacy Policy links in the system browser rather than navigating within the form
- Domain restriction: Only allow navigation to WalletConnect pay domains and HTTPS URLs
- Back navigation: Handle back/dismiss gracefully — confirm cancellation with the user before closing the form mid-flow
- Keyboard behavior: Test that the soft keyboard appears and behaves correctly when users tap on form inputs
- Theme to match your brand: Pass
theme=lightortheme=darkto match your wallet’s active color mode, and apply brand tokens withthemeVariablesexported from the WalletConnect Pay Dashboard. See Form URL parameters.
Complete Example
Here’s a complete implementation example using a ViewModel:API Reference
WalletConnectPay Main entry point for the Pay SDK (singleton object). Properties
Methods
Data Models
Pay.PaymentOptionsResponseError Handling
The SDK provides typed errors for different failure scenarios: GetPaymentOptionsError
GetPaymentRequestError
ConfirmPaymentError
Example Error Handling
Best Practices
-
Initialize once: Call
initialize()only once, typically inApplication.onCreate() -
Account Format: Always use CAIP-10 format for accounts:
eip155:{chainId}:{address} - Multiple Chains: Provide accounts for all supported chains to maximize payment options
- Signature Order: Maintain the same order of signatures as the actions array
- Error Handling: Always handle errors gracefully and show appropriate user feedback
- Thread Safety: Events are delivered on IO dispatcher; update UI on main thread
-
WebView Data Collection: When
selectedOption.collectData?.urlis present, display the URL in a WebView rather than building native forms. The WebView handles form rendering, validation, and T&C acceptance. -
Per-Option Data Collection: When displaying payment options, check each option’s
collectDatafield. Show a visual indicator (e.g., “Info required” badge) on options that require data collection. Only open the WebView when the user selects an option withcollectDatapresent — use the option’scollectData.urlwhich is already scoped to that option’s account.