Requirements
- Node.js 16+
Installation
Install the WalletConnect Pay SDK using npm or yarn:- npm
- yarn
Architecture
The SDK uses a provider abstraction that allows different implementations:- WasmProvider: Uses WebAssembly module for web browsers
- NativeProvider: Uses platform-specific uniffi module (for React Native environments)
Configuration
Initialize the WalletConnect Pay client with your credentials:Configuration Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
appId | string | No* | WCP ID for authentication |
apiKey | string | No* | API key for authentication |
clientId | string | No | Client ID for tracking |
baseUrl | string | No | Custom API base URL |
logger | Logger | No | Custom logger instance or level |
Either
appId or apiKey must be provided for authentication.Don’t have a project ID? Create one at the WalletConnect Dashboard by signing up and creating a new project.
Supported Networks
WalletConnect Pay currently supports the following networks with USDC:| Network | Chain ID | CAIP-10 Format |
|---|---|---|
| Ethereum | 1 | eip155:1:{address} |
| Base | 8453 | eip155:8453:{address} |
| Optimism | 10 | eip155:10:{address} |
| Polygon | 137 | eip155:137:{address} |
| Arbitrum | 42161 | eip155:42161:{address} |
Support for all EVM chains, Solana, and additional native and non-native assets is coming soon. Include accounts for all supported networks to maximize payment options for your users.
Payment Flow
The payment flow consists of four main steps: Get Options -> 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:
Get Required Actions
After the user selects a payment option, get the wallet RPC actions required to complete the payment:
Collect User Data (If Required)
Some payments may require additional user data. Check for
collectData on the selected payment option:Iframe-Based Data Collection
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.Recommended Flow (Per-Option)
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, open
selectedOption.collectData.urlin an iframe within your wallet - Optionally append a
prefill=<base64-json>query parameter with known user data (e.g., name, date of birth, address). Use proper URL building to handle existing query parameters. - Listen for
postMessageevents:IC_COMPLETE(success) orIC_ERROR(failure) - On
IC_COMPLETE, proceed toconfirmPayment()without passingcollectedData— the iframe submits data directly to the backend
Decision Matrix
Response collectData | option.collectData | Behavior |
|---|---|---|
| present | present | Option requires IC — use option.collectData.url |
| present | null | Option does NOT require IC (others might) — skip IC for this option |
null | null | No IC needed for any option |
The
collectData also includes a schema field — a JSON schema string describing the required fields. The required list in this schema tells you which fields the form expects. Wallets can use these field names as keys when building the prefill JSON object. For example, if the schema’s required array contains ["fullName", "dob", "pobAddress"], you can prefill with {"fullName": "...", "dob": "...", "pobAddress": "..."}.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.Iframe Message Types
The iframe communicates with your wallet throughpostMessage events. The message payload is a JSON string with the following structure:| Message Type | Payload | Description |
|---|---|---|
IC_COMPLETE | { "type": "IC_COMPLETE", "success": true } | User completed the form successfully. Proceed to payment confirmation. |
IC_ERROR | { "type": "IC_ERROR", "error": "..." } | An error occurred. Display the error message and allow the user to retry. |
Data Collection Implementation
When a selected option hascollectData.url present, display the URL in an iframe or modal. Listen for postMessage events to handle completion:
Complete Example
Here’s a complete implementation example:Provider Utilities
The SDK provides utilities for checking provider availability:Error Handling
The SDK throws typed errors for different failure scenarios:Error Types
| Error Class | Description |
|---|---|
PayError | Base error class for all Pay SDK errors |
PaymentOptionsError | Error when fetching payment options |
PaymentActionsError | Error when fetching required payment actions |
ConfirmPaymentError | Error when confirming payment |
Error Codes
ThePayError class includes a code property with one of the following values:
API Reference
WalletConnectPay
Main client for payment operations.Constructor
Methods
| Method | Description |
|---|---|
getPaymentOptions(params) | Fetch available payment options |
getRequiredPaymentActions(params) | Get signing actions for a payment option |
confirmPayment(params) | Confirm and execute the payment |
static isAvailable() | Check if a provider is available |
Data Types
PaymentStatus
PayProviderType
CollectDataFieldType
Method Parameters
Response Types
PaymentOption
Action
Amount Types
Payment Info Types
Collect Data Types
Best Practices
- Check Provider Availability: Always check if a provider is available before using the SDK
-
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
- Loading States: Show loading indicators during API calls and signing operations
-
Expiration: Check
paymentInfo.expiresAtand warn users if time is running low -
User Data: Only collect data when
collectDatais present on the selected payment option and you don’t already have the required user data. If you already have the required data, you can submit this without collecting from the user. You must make sure the user accepts WalletConnect Terms and Conditions and Privacy Policy before submitting user information to WalletConnect. -
Data Collection: When
selectedOption.collectData?.urlis present, display the URL in an iframe or modal rather than building custom forms. The hosted form handles 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 iframe when the user selects an option withcollectDatapresent — use the option’scollectData.urlwhich is already scoped to that option’s account.