### Fetch Delivery Methods in Go Source: https://docs.wirexapp.com/docs/card-issuance This Go code example shows how to retrieve card delivery methods via an HTTP GET request. It includes setting necessary headers like Authorization, X-User-Address, and X-Chain-Id. ```go req, _ := http.NewRequest("GET", baseURL+"/api/v1/cards/delivery/methods/"+country, nil) req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("X-User-Address", userEoaAddress) req.Header.Set("X-Chain-Id", chainId) resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() var methods []DeliveryMethod json.NewDecoder(resp.Body).Decode(&methods) selectedProvider := methods[0].Provider // e.g., "DHL" ``` -------------------------------- ### Install SDK and Dependencies Source: https://docs.wirexapp.com/docs/sdk Install the Wirex BaaS SDK and the required 'viem' peer dependency using npm. ```bash npm install @wirexapp/wpay-baas-sdk npm install viem ``` -------------------------------- ### Install Policy and Executor Source: https://docs.wirexapp.com/docs/sdk Installs the policy and executor if they are not already present. This ensures the smart wallet is properly configured. ```typescript if (!isPolicyInstalled || !isExecutorInstalled) { const result = await sdk.crypto.accountAbstraction.signInPolicyAndExecutor(); console.log('TX hash:', result?.receipt?.transactionHash); } ``` -------------------------------- ### Install All Wirex BaaS Skills (npx skills CLI) Source: https://docs.wirexapp.com/docs/agent-skills Install all available Wirex BaaS agent skills using the skills CLI. ```bash npx skills add wirexpay/wirex-baas-agent-skills --all ``` -------------------------------- ### Complete Example: EVM Direct Deployment with ZeroDev SDK Source: https://docs.wirexapp.com/docs/onchain-registration A comprehensive TypeScript example demonstrating the initialization of clients, resolution of contract addresses from a registry, and obtaining a user signer for on-chain account deployment. ```typescript // ============================================================ // Imports // ============================================================ import { createZeroDevPaymasterClient, KernelV3_1AccountAbi } from '@zerodev/sdk'; import { createKernelAccount, createKernelAccountClient } from '@zerodev/sdk'; import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator'; import { getEntryPoint, KERNEL_V3_1, VALIDATOR_TYPE } from '@zerodev/sdk/constants'; import { toPermissionValidator } from '@zerodev/permissions'; import { toSudoPolicy } from '@zerodev/permissions/policies'; import { toECDSASigner } from '@zerodev/permissions/signers'; import { createPublicClient, http, encodeFunctionData, concatHex, pad, zeroAddress, zeroHash, type PrivateKeyAccount, } from 'viem'; import { base } from 'viem/chains'; import { privateKeyToAccount } from 'viem/accounts'; // ============================================================ // ABIs - see ABI Reference guide for complete definitions // ============================================================ import { ContractRegistryAbi, AccountsAbi } from './abi'; // Or define inline - see: ABI Reference guide // ============================================================ // Configuration (provided by Wirex during onboarding) // ============================================================ interface WirexConfig { chainId: number; rpcUrl: string; bundlerRpc: string; paymasterRpc: string; contractRegistryAddress: `0x${string}`; partnerId: `0x${string}`; } // Example configuration for Base mainnet const config: WirexConfig = { chainId: 8453, rpcUrl: 'https://...', // Provided by Wirex bundlerRpc: 'https://...', // Provided by Wirex paymasterRpc: 'https://...', // Provided by Wirex contractRegistryAddress: '0x...', // Provided by Wirex partnerId: '0x00000000000000000000000000000007', // Your partner_id }; // ============================================================ // Step 1: Initialize Clients // ============================================================ async function initializeClients(config: WirexConfig) { const chain = base; const publicClient = createPublicClient({ chain, transport: http(config.rpcUrl, { timeout: 30_000 }), }); // Kernel public client for account operations const kernelPublicClient = createPublicClient({ chain, transport: http(config.rpcUrl, { timeout: 60_000 }), }); const paymasterClient = createZeroDevPaymasterClient({ chain, transport: http(config.paymasterRpc), }); return { chain, publicClient, kernelPublicClient, paymasterClient }; } // ============================================================ // Step 2: Resolve Contract Addresses from Registry // ============================================================ interface ContractAddresses { accounts: `0x${string}`; fundsManagement: `0x${string}`; executionDelayPolicy: `0x${string}`; } async function resolveContractAddresses( publicClient: any, registryAddress: `0x${string}` ): Promise { const getAddress = async (name: string): Promise<`0x${string}`> => { return publicClient.readContract({ address: registryAddress, abi: ContractRegistryAbi, functionName: 'contractByName', args: [name], }); }; return { accounts: await getAddress('Accounts'), fundsManagement: await getAddress('FundsManagement'), executionDelayPolicy: await getAddress('ExecutionDelayPolicy'), }; } // ============================================================ // Step 3: Obtain User Signer // ============================================================ ``` -------------------------------- ### ACH Account Capability Status Example Source: https://docs.wirexapp.com/docs/ach-bank-details This JSON response shows an example of the AchAccount capability within the user's capabilities list, indicating that activation has not yet started. ```json { "capabilities": [ { "type": "AchAccount", "status": "ActivationNotStarted" } ] } ``` -------------------------------- ### Install Dependencies for ZeroDev SDK Source: https://docs.wirexapp.com/docs/onchain-registration Install the necessary packages for using the ZeroDev SDK, including the SDK itself, ECDSA validator, permissions, and viem. ```bash npm install @zerodev/sdk @zerodev/ecdsa-validator @zerodev/permissions viem ``` -------------------------------- ### Install FundsManagementExecutor Only Source: https://docs.wirexapp.com/docs/sdk Installs only the `FundsManagementExecutor` by submitting a UserOperation. ```typescript sdk.crypto.accountAbstraction.signInExecutor() ``` -------------------------------- ### Install Specific Wirex BaaS Skill (npx skills CLI) Source: https://docs.wirexapp.com/docs/agent-skills Install a specific Wirex BaaS agent skill, such as `wirex-baas-auth`, using the skills CLI. ```bash npx skills add wirexpay/wirex-baas-agent-skills --skill wirex-baas-auth ``` -------------------------------- ### Kernel v3.1 Account ABI Functions Source: https://docs.wirexapp.com/docs/abi-reference Key functions for Kernel account setup, including installing modules, changing root validators, and checking module installation status. ```typescript import { KernelV3_1AccountAbi } from '@zerodev/sdk'; // Key functions used during setup: // Install executor module // moduleType: 2 = Executor encodeFunctionData({ abi: KernelV3_1AccountAbi, functionName: 'installModule', args: [moduleType, moduleAddress, initData], }); // Set policy as root validator encodeFunctionData({ abi: KernelV3_1AccountAbi, functionName: 'changeRootValidator', args: [validatorId, hook, validatorData, hookData], }); // Check if module is installed // moduleType: 1 = Validator, 2 = Executor const isInstalled = await publicClient.readContract({ address: smartWalletAddress, abi: KernelV3_1AccountAbi, functionName: 'isModuleInstalled', args: [moduleType, moduleAddress, '0x'], }); // Get current root validator const rootValidator = await publicClient.readContract({ address: smartWalletAddress, abi: KernelV3_1AccountAbi, functionName: 'rootValidator', }); ``` -------------------------------- ### Install Policy Separately Source: https://docs.wirexapp.com/docs/sdk Installs only the ExecutionDelayPolicy or FundsManagementExecutor if needed independently. ```typescript await sdk.crypto.accountAbstraction.signInPolicy(); // ExecutionDelayPolicy only await sdk.crypto.accountAbstraction.signInExecutor(); // FundsManagementExecutor only ``` -------------------------------- ### User Response Example Source: https://docs.wirexapp.com/docs/card-issuance This is an example of the user response JSON, highlighting the 'capabilities' field which indicates available card types and their status. ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "owner": "0x1234567890abcdef1234567890abcdef12345678", "verification": { "status": "Approved", "levels": [ { "status": "Approved", "type": "SDD", "name": "Wirex SDD Level" } ] }, "capabilities": [ { "type": "VisaVirtualCard", "verification_requirements": [ { "type": "BDD", "order": 1 } ], "prerequisites": null, "status": "Active" }, { "type": "VisaPlasticCard", "verification_requirements": [ { "type": "SDD", "order": 1 } ], "prerequisites": null, "status": "Active" } ] } ``` -------------------------------- ### Install ExecutionDelayPolicy Only Source: https://docs.wirexapp.com/docs/sdk Installs only the `ExecutionDelayPolicy` by submitting a UserOperation. ```typescript sdk.crypto.accountAbstraction.signInPolicy() ``` -------------------------------- ### Kernel v3.1 Account ABI Functions Source: https://docs.wirexapp.com/docs/abi-reference Key functions for Smart Wallet setup using the Kernel v3.1 ABI. These include installing modules, changing the root validator, checking module installation, and retrieving the current root validator. ```APIDOC ## Kernel v3.1 Account ABI ### Description Provides key functions for Smart Wallet setup. ### Functions #### `installModule` Installs an executor module. - **Parameters**: - `moduleType` (number) - Required - Type of module (2 for Executor). - `moduleAddress` (address) - Required - The address of the module. - `initData` (bytes) - Required - Initialization data for the module. #### `changeRootValidator` Sets the policy as the root validator. - **Parameters**: - `validatorId` (uint256) - Required - The ID of the validator. - `hook` (address) - Required - The hook address. - `validatorData` (bytes) - Required - Data for the validator. - `hookData` (bytes) - Required - Data for the hook. #### `isModuleInstalled` Checks if a module is installed. - **Parameters**: - `moduleType` (number) - Required - Type of module (1 for Validator, 2 for Executor). - `moduleAddress` (address) - Required - The address of the module. - `extraData` (bytes) - Required - Additional data, typically '0x'. - **Returns**: - `isInstalled` (boolean) - True if the module is installed, false otherwise. #### `rootValidator` Retrieves the current root validator. - **Returns**: - `rootValidator` (address) - The address of the current root validator. ``` -------------------------------- ### Install Policy and Executor in One UserOperation Source: https://docs.wirexapp.com/docs/sdk Installs both the `ExecutionDelayPolicy` and `FundsManagementExecutor` by submitting a single UserOperation. ```typescript sdk.crypto.accountAbstraction.signInPolicyAndExecutor() ``` -------------------------------- ### Check and Install Policy/Executor Source: https://docs.wirexapp.com/docs/onchain-registration Verify if the execution delay policy and funds management executor are installed. If not, install both in a single transaction for account abstraction. ```typescript // Check if already installed const policyInstalled = await sdk.crypto.accountAbstraction.isPolicyInstalled(); const executorInstalled = await sdk.crypto.accountAbstraction.isExecutorInstalled(); // Install both policy and executor in one transaction if (!policyInstalled || !executorInstalled) { await sdk.crypto.accountAbstraction.signInPolicyAndExecutor(); } ``` -------------------------------- ### Verify Smart Wallet Setup Status Source: https://docs.wirexapp.com/docs/onchain-registration Checks if the executor module is installed, if a policy is installed (root validator is set), and if the account is registered in the Accounts contract. This function helps determine the current state of a deployed smart wallet. ```typescript import { KernelV3_1AccountAbi } from '@zerodev/sdk'; import { AccountsAbi } from './abi'; // See ABI Reference async function verifyWalletSetup( publicClient: any, smartWalletAddress: `0x${string}`, contracts: ContractAddresses, partnerId: `0x${string}` ) { // 1. Check if executor is installed const isExecutorInstalled = await publicClient.readContract({ address: smartWalletAddress, abi: KernelV3_1AccountAbi, functionName: 'isModuleInstalled', args: [BigInt(2), contracts.fundsManagement, '0x'], }); console.log('Executor installed:', isExecutorInstalled); // 2. Check if policy is installed (root validator set) const rootValidator = await publicClient.readContract({ address: smartWalletAddress, abi: KernelV3_1AccountAbi, functionName: 'rootValidator', }); const isPolicyInstalled = rootValidator && rootValidator !== '0x'; console.log('Policy installed:', isPolicyInstalled); // 3. Check if registered in Accounts contract try { const account = await publicClient.readContract({ address: contracts.accounts, abi: AccountsAbi, functionName: 'getUserAccount', args: [smartWalletAddress, partnerId], }); const isRegistered = account && account.status !== 0; console.log('Account registered:', isRegistered); return { isExecutorInstalled, isPolicyInstalled, isRegistered }; } catch { console.log('Account not registered'); return { isExecutorInstalled, isPolicyInstalled, isRegistered: false }; } } ``` -------------------------------- ### Install Wirex BaaS Agent Skills Plugin (Claude Code) Source: https://docs.wirexapp.com/docs/agent-skills Use these commands to add the Wirex BaaS agent skills marketplace and install the plugin for Claude Code. ```bash /plugin marketplace add wirexpay/wirex-baas-agent-skills /plugin install wirex-baas@wirex-baas-agent-skills ``` -------------------------------- ### Install Wirex BaaS Skills for Specific Agent (npx skills CLI) Source: https://docs.wirexapp.com/docs/agent-skills Install all Wirex BaaS agent skills for a specific agent, like Claude Code, using the skills CLI. ```bash npx skills add wirexpay/wirex-baas-agent-skills -a claude-code --all ``` -------------------------------- ### sdk.crypto.accountAbstraction.signInPolicy Source: https://docs.wirexapp.com/docs/sdk Install `ExecutionDelayPolicy` only. ```APIDOC ## POST sdk.crypto.accountAbstraction.signInPolicy ### Description Install `ExecutionDelayPolicy` only. ### Method POST ### Endpoint /sdk/crypto/account-abstraction/sign-in-policy ### Response #### Success Response (200) - **message** (string) - Confirmation message. ### Response Example { "message": "ExecutionDelayPolicy installed successfully." } ``` -------------------------------- ### Example Purchase (Auth + Clearing) Request Source: https://docs.wirexapp.com/docs/sandbox-testing-reference This is an example of a POST request to the /card/auth-and-clearing endpoint to simulate an in-store purchase. It includes the common parameters for a transaction. ```http POST /card/auth-and-clearing ``` ```json { "cardId": "550e8400-e29b-41d4-a716-446655440000", "amount": 25.50, "currency": "GBP", "settlementAmount": 25.50, "settlementCurrency": "GBP", "merchantCountry": "GBR", "paymentProvider": "Visa" } ``` -------------------------------- ### Check and Install Policy/Executor Source: https://docs.wirexapp.com/docs/onchain-registration Checks if the execution delay policy and funds management executor are installed. If not, it installs both in a single transaction. ```APIDOC ## Check and Install Policy/Executor ### Description Checks if the execution delay policy and funds management executor are installed. If not, it installs both in a single transaction. ### Methods - `sdk.crypto.accountAbstraction.isPolicyInstalled()`: Checks if the policy is installed. - `sdk.crypto.accountAbstraction.isExecutorInstalled()`: Checks if the executor is installed. - `sdk.crypto.accountAbstraction.signInPolicyAndExecutor()`: Installs both policy and executor. ### Request Example ```typescript // Check if already installed const policyInstalled = await sdk.crypto.accountAbstraction.isPolicyInstalled(); const executorInstalled = await sdk.crypto.accountAbstraction.isExecutorInstalled(); // Install both policy and executor in one transaction if (!policyInstalled || !executorInstalled) { await sdk.crypto.accountAbstraction.signInPolicyAndExecutor(); } ``` ``` -------------------------------- ### sdk.crypto.accountAbstraction.signInExecutor Source: https://docs.wirexapp.com/docs/sdk Install `FundsManagementExecutor` only. ```APIDOC ## POST sdk.crypto.accountAbstraction.signInExecutor ### Description Install `FundsManagementExecutor` only. ### Method POST ### Endpoint /sdk/crypto/account-abstraction/sign-in-executor ### Response #### Success Response (200) - **message** (string) - Confirmation message. ### Response Example { "message": "FundsManagementExecutor installed successfully." } ``` -------------------------------- ### NotFulfilled Capability Example Source: https://docs.wirexapp.com/docs/card-issuance This JSON example shows a capability with 'NotFulfilled' status, indicating that the user has not met the necessary requirements, such as verification levels. ```json { "type": "VisaPlasticCard", "verification_requirements": [ { "type": "SDD", "order": 1 } ], "prerequisites": null, "status": "NotFulfilled", "status_reason": "Verification level SDD is required" } ``` -------------------------------- ### User API Request Example Source: https://docs.wirexapp.com/docs/kyc-shared This is an example of a POST request to the /api/v2/user endpoint. Ensure the wallet_address is the user's EOA address and the sharing_data includes a valid SumSub sharing_token and the user's email. ```json { "wallet_address": "0xA7E41d5680dE394EaA2ed417169DFf56840Fb3EE", "sharing_data": { "sharing_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "email": "alex.grey@wirexapp.com" } } ``` -------------------------------- ### Example: Filter by Multiple Activity Types Source: https://docs.wirexapp.com/docs/activity-history Use repeated 'types' parameters to filter activities by more than one type. This example shows how to retrieve both card transactions and SEPA transfers. ```http GET /api/v2/activity/feed?types=CardTransaction&types=Sepa ``` -------------------------------- ### sdk.crypto.accountAbstraction.signInPolicyAndExecutor Source: https://docs.wirexapp.com/docs/sdk Install both `ExecutionDelayPolicy` and `FundsManagementExecutor` in one UserOperation. ```APIDOC ## POST sdk.crypto.accountAbstraction.signInPolicyAndExecutor ### Description Install both `ExecutionDelayPolicy` and `FundsManagementExecutor` in one UserOperation. ### Method POST ### Endpoint /sdk/crypto/account-abstraction/sign-in-policy-and-executor ### Response #### Success Response (200) - **message** (string) - Confirmation message. ### Response Example { "message": "Policy and Executor installed successfully." } ``` -------------------------------- ### sdk.api.baas.config.getConfig Source: https://docs.wirexapp.com/docs/sdk Get the client application configuration. ```APIDOC ## GET sdk.api.baas.config.getConfig ### Description Get client app config. ### Method GET ### Endpoint /sdk/api/baas/config ### Response #### Success Response (200) - **data** (object) - The client application configuration object. ### Response Example { "data": { "appName": "Wirexapp", "version": "1.0.0" } } ``` -------------------------------- ### sdk.crypto.wallet.getSmartWalletClient Source: https://docs.wirexapp.com/docs/sdk Get Kernel client with ExecutionDelayPolicy. ```APIDOC ## GET sdk.crypto.wallet.getSmartWalletClient ### Description Get Kernel client with ExecutionDelayPolicy. ### Method GET ### Endpoint /sdk/crypto/wallet/smart-wallet-client ### Response #### Success Response (200) - **client** (object) - The Kernel client instance. ### Response Example { "client": { "type": "KernelClient", "policy": "ExecutionDelayPolicy" } } ``` -------------------------------- ### Get Recipient by ID Response Example Source: https://docs.wirexapp.com/docs/recipients-overview This is an example of the JSON response when retrieving a specific recipient by their ID. It returns the details of that single recipient. ```json { "id": "77fc49bd-1d7d-41d9-beea-a0aee0dc8c35", "personal_info": { "first_name": "Alex", "last_name": "Grey", "is_business": false }, "payment_details": [ { "id": "c34908da-d980-4a9c-9b39-4dabd6f6144e", "type": "Card", "currencies": ["EUR", "USD"], "card": { "card_id": "tok_a1b2c3d4e5f6789012345678", "card_pan_last": "4242" } } ] } ``` -------------------------------- ### Initialize WirexPaySDK Source: https://docs.wirexapp.com/docs/sdk Initialize the SDK with environment, company ID, and a factory function for the user's wallet client. Logging can be enabled with optional custom logger. ```typescript import { createSDK, type WirexPaySDK } from '@wirexapp/wpay-baas-sdk'; const sdk: WirexPaySDK = await createSDK({ env: 'dev', // 'dev' → sandbox | 'prod' → production companyId: process.env.COMPANY_ID, // hex company ID from Wirex onboarding getMainWalletClient: () => mainWalletClient, enableLogging: false, // optional logger: customLogger, // optional, requires enableLogging: true }); ``` -------------------------------- ### Initialize Wirex SDK Source: https://docs.wirexapp.com/docs/onchain-registration Initialize the Wirex SDK with your company ID and environment settings. Ensure you provide a method to retrieve the user's main wallet client. ```typescript import { createSDK } from '@wirexapp/wpay-baas-sdk'; const sdk = await createSDK({ env: 'production', // or 'sandbox' companyId: '0x00000000000000000000000000000007', // Your partner_id enableLogging: true, getMainWalletClient: async () => { // Return the user's EOA wallet client (from Privy, WalletConnect, etc.) return mainWalletClient; }, }); ``` -------------------------------- ### Get Smart Wallet Address Source: https://docs.wirexapp.com/docs/sdk Retrieves the smart wallet address associated with the SDK. This is the first step in the on-chain setup. ```typescript const smartWalletAddress = await sdk.crypto.wallet.getSmartWalletAddress(); console.log('Smart Wallet:', smartWalletAddress); ``` -------------------------------- ### SDK Initialization Source: https://docs.wirexapp.com/docs/onchain-registration Initializes the Wirex SDK with environment, company ID, and a function to get the main wallet client. Logging can be enabled. ```APIDOC ## SDK Initialization ### Description Initializes the Wirex SDK with environment, company ID, and a function to get the main wallet client. Logging can be enabled. ### Method `createSDK(options)` ### Parameters #### Request Body - **env** (string) - Required - The environment to use ('production' or 'sandbox'). - **companyId** (string) - Required - Your partner ID. - **enableLogging** (boolean) - Optional - Enables logging if set to true. - **getMainWalletClient** (function) - Required - An async function that returns the user's EOA wallet client. ### Request Example ```typescript import { createSDK } from '@wirexapp/wpay-baas-sdk'; const sdk = await createSDK({ env: 'production', companyId: '0x00000000000000000000000000000007', enableLogging: true, getMainWalletClient: async () => { return mainWalletClient; }, }); ``` ``` -------------------------------- ### Get Activity Statement for a Date Range Source: https://docs.wirexapp.com/docs/sdk Fetches a financial statement for a specified date range. Requires start and end Unix timestamps in seconds. ```typescript const statement = await sdk.api.baas.activity.getFullStatement({ start: Math.floor((Date.now() - 30 * 24 * 60 * 60 * 1000) / 1000), end: Math.floor(Date.now() / 1000), }); ``` -------------------------------- ### Deploy AA Wallet and Register Source: https://docs.wirexapp.com/docs/dev-onboarding This sequence diagram illustrates the steps for deploying an AA wallet using the ZeroDev SDK, installing necessary modules, and registering the wallet on the blockchain. It also shows the subsequent webhook notification from Wirex BaaS. ```mermaid sequenceDiagram participant User participant App as Your App participant BaaS as Wirex BaaS participant Chain as Blockchain Note over User,BaaS: Authentication User->>App: Sign in App->>BaaS: POST /api/v1/oauth2/token BaaS-->>App: access_token Note over App,Chain: Wallet Deployment App->>Chain: Deploy AA wallet (ZeroDev SDK) App->>Chain: Install modules (executor + policy) App->>Chain: Register in Accounts contract Chain-->>BaaS: Event detected BaaS->>App: POST /v2/webhooks/wallets Note over App,BaaS: API Registration App->>BaaS: POST /api/v2/user BaaS-->>App: user_id ``` -------------------------------- ### Register User API Request (Go) Source: https://docs.wirexapp.com/docs/extauth-creating-user-2 Example of how to call the user registration API using Go's net/http package. The request includes necessary headers and a JSON body. ```go body, _ := json.Marshal(map[string]string{ "wallet_address": userEoaAddress, "email": "user@example.com", "country": "GB", }) req, _ := http.NewRequest("POST", baseURL+"/api/v2/user", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("X-User-Address", userEoaAddress) req.Header.Set("X-Chain-Id", chainId) req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() var user UserResponse json.NewDecoder(resp.Body).Decode(&user) ``` -------------------------------- ### Check if FundsManagementExecutor is Installed Source: https://docs.wirexapp.com/docs/sdk Verifies if the `FundsManagementExecutor` is currently installed for account abstraction. ```typescript sdk.crypto.accountAbstraction.isExecutorInstalled() ``` -------------------------------- ### Handle Card Transaction Webhook in Go Source: https://docs.wirexapp.com/docs/extauth-cards This Go example demonstrates how to handle card transaction webhooks to manage user balance updates. ```go func handleActivityWebhook(w http.ResponseWriter, r *http.Request) { var activity ActivityWebhook json.NewDecoder(r.Body).Decode(&activity) if activity.Type != "CardTransaction" || activity.Status != "Completed" { w.WriteHeader(http.StatusOK) return } if activity.Direction == "Outbound" { // Purchase: debit user balance db.DebitUserBalance(activity.UserID, activity.SourceAmount.Amount, activity.SourceAmount.Currency) } else { // Refund: credit user balance db.CreditUserBalance(activity.UserID, activity.SourceAmount.Amount, activity.SourceAmount.Currency) } w.WriteHeader(http.StatusOK) } ``` -------------------------------- ### Fetch Bank Accounts in Python Source: https://docs.wirexapp.com/docs/sepa-bank-details Python example for retrieving bank accounts. It shows how to set up the request headers and extract SEPA account information from the response. ```python response = requests.get( f"{base_url}/api/v1/bank/accounts", headers={ "Authorization": f"Bearer {access_token}", "X-User-Address": user_eoa_address, "X-Chain-Id": chain_id } ) accounts = response.json()["accounts"] sepa_account = next((a for a in accounts if a["account_type"] == "Sepa"), None) if sepa_account: print("IBAN:", sepa_account["details"]["iban"]) print("BIC:", sepa_account["details"]["bic"]) ``` -------------------------------- ### Check if ExecutionDelayPolicy is Installed Source: https://docs.wirexapp.com/docs/sdk Verifies if the `ExecutionDelayPolicy` is currently installed as the root validator for account abstraction. ```typescript sdk.crypto.accountAbstraction.isPolicyInstalled() ``` -------------------------------- ### Create Wallet Client from Raw Private Key Source: https://docs.wirexapp.com/docs/sdk This adapter is useful for testing or when using embedded wallets with a raw private key. It implements the MainWalletClient interface using viem. ```typescript import { createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { baseSepolia } from 'viem/chains'; import type { MainWalletClient } from '@wirexapp/wpay-baas-sdk'; export function createWalletClientFromKey( privateKey: `0x${string}`, rpcUrl: string, ): MainWalletClient { const account = privateKeyToAccount(privateKey); const client = createWalletClient({ account, chain: baseSepolia, transport: http(rpcUrl) }); return { address: account.address, getEthereumProvider: async () => ({ request: async ({ method, params = [] }) => { if (method === 'eth_accounts') return [account.address]; if (method === 'personal_sign') { const [data] = params as [`0x${string}`, string]; return client.signMessage({ account, message: { raw: data } }); } if (method === 'eth_signTypedData_v4') { const [, json] = params as [string, string]; const { domain, types, primaryType, message } = JSON.parse(json); const { EIP712Domain: _, ...filteredTypes } = types; return client.signTypedData({ account, domain, types: filteredTypes, primaryType, message }); } return (client.transport as any).request({ method, params }); }, }), }; } ``` -------------------------------- ### Card Transaction Webhook Payload Example Source: https://docs.wirexapp.com/docs/extauth-cards This is an example JSON payload for a completed card transaction webhook notification. ```json { "id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22", "type": "CardTransaction", "status": "Completed", "direction": "Outbound", "source_amount": { "amount": 123.45, "currency": "USD" }, "user_id": "5f7e3f7b-8e0c-48b8-9f2c-3e0c9d7a2a11", "card_id": "c0b2c7b1-1d2e-4d7a-9a5d-2b7e3c4d5f66", "created_at": "2024-01-01T10:00:00Z" } ``` -------------------------------- ### Initiate User Registration and Get ID Source: https://docs.wirexapp.com/docs/kyc-api Initiate the user registration process by sending the wallet address and initial data. This returns a user ID required for subsequent steps. ```HTTP POST /api/v2/user { wallet_address, initial_data } ``` -------------------------------- ### Get Verification Token Endpoint Source: https://docs.wirexapp.com/docs/kyc-hosted Use this GET endpoint to obtain a token required for initializing the SumSub SDK within your application. ```http GET /api/v1/user/verification-token ``` -------------------------------- ### Fetch Bank Accounts in Go Source: https://docs.wirexapp.com/docs/sepa-bank-details Go language example for fetching bank accounts. This snippet illustrates creating an HTTP request, setting headers, and decoding the JSON response to access SEPA details. ```go req, _ := http.NewRequest("GET", baseURL+"/api/v1/bank/accounts", nil) req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("X-User-Address", userEoaAddress) req.Header.Set("X-Chain-Id", chainId) resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() var result struct { Accounts []BankAccountResponse `json:"accounts"` } json.NewDecoder(resp.Body).Decode(&result) for _, account := range result.Accounts { if account.AccountType == "Sepa" { fmt.Println("IBAN:", account.Details.IBAN) fmt.Println("BIC:", account.Details.BIC) } } ``` -------------------------------- ### Get Verification Link Endpoint Source: https://docs.wirexapp.com/docs/kyc-hosted Use this GET endpoint to obtain a URL for redirecting users to the hosted SumSub KYC widget. ```http GET /api/v1/user/verification-link ``` -------------------------------- ### Activity Webhook Payload Example Source: https://docs.wirexapp.com/docs/activity-history This is an example of the JSON payload received for an activity webhook. It includes details about the transaction, source, destination, and amounts. ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "user_address": "0xA7E41d5680dE394EaA2ed417169DFf56840Fb3EE", "type": "Sepa", "direction": "Inbound", "status": "Completed", "source": { "type": "SepaBankAccount", "bank_account": { "iban": "DE89370400440532013000", "bic": "COBADEFFXXX", "owner_name": "Alex Grey", "is_business": false } }, "destination": { "type": "Wallet", "wallet": { "address": "0xA7E41d5680dE394EaA2ed417169DFf56840Fb3EE" } }, "source_amount": { "amount": 1000.00, "currency": "EUR" }, "destination_amount": { "amount": 1000.00, "token_symbol": "WEUR", "token_address": "0x..." }, "created_at": "2024-01-15T10:30:00Z", "activity_steps": [...] } ``` -------------------------------- ### Manage Cards in Go Source: https://docs.wirexapp.com/docs/card-issuance Examples for blocking, unblocking, and closing cards using Go's http package. Ensure correct headers are set for each request. ```go actions := []string{"block", "unblock", "close"} for _, action := range actions { req, _ := http.NewRequest("PUT", baseURL+"/api/v1/cards/"+cardId+"/"+action, nil) req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("X-User-Address", userEoaAddress) req.Header.Set("X-Chain-Id", chainId) http.DefaultClient.Do(req) } ``` -------------------------------- ### List Recipients Response Example Source: https://docs.wirexapp.com/docs/recipients-overview This is an example of the JSON response when listing recipients. It includes recipient details, payment information, and pagination metadata. ```json { "items": [ { "id": "77fc49bd-1d7d-41d9-beea-a0aee0dc8c35", "personal_info": { "first_name": "Alex", "last_name": "Grey", "is_business": false }, "payment_details": [ { "id": "c34908da-d980-4a9c-9b39-4dabd6f6144e", "type": "Card", "currencies": ["EUR", "USD"], "card": { "card_id": "tok_a1b2c3d4e5f6789012345678", "card_pan_last": "4242" } }, { "id": "d45019eb-e091-5b0d-0c4a-5ebce7255f0f", "type": "Sepa", "currencies": ["EUR"], "sepa": { "iban": "DE89370400440532013000", "bic": "COBADEFFXXX" } } ] } ], "total_count": 1, "page_number": 0, "page_size": 25 } ``` -------------------------------- ### Simulate Card Purchase in Go Source: https://docs.wirexapp.com/docs/sandbox-testing-reference This Go function simulates a card purchase, including authorization and clearing. It requires a card ID, amount, and optionally currency. Ensure the helperAPI constant is correctly set and necessary imports are included. ```go type CardTransactionRequest struct { CardID string `json:"cardId"` Amount float64 `json:"amount"` Currency string `json:"currency"` SettlementAmount float64 `json:"settlementAmount"` SettlementCurrency string `json:"settlementCurrency"` PaymentProvider string `json:"paymentProvider"` } func simulateCardPurchase(cardID string, amount float64, currency string) error { body, _ := json.Marshal(CardTransactionRequest{ CardID: cardID, Amount: amount, Currency: currency, SettlementAmount: amount, SettlementCurrency: currency, PaymentProvider: "Visa", }) _, err := http.Post( helperAPI+"/card/auth-and-clearing", "application/json", bytes.NewBuffer(body), ) return err } ``` -------------------------------- ### Register User for Hosted KYC (Go) Source: https://docs.wirexapp.com/docs/kyc-hosted Implement user registration for hosted KYC using this Go function. It requires an access token and essential user data including wallet address, email, country, and chain ID. ```go func RegisterUserHostedKYC(accessToken, walletAddress, email, country string, chainID int, baseURL string) (string, error) { reqBody, _ := json.Marshal(map[string]interface{}{ "wallet_address": walletAddress, "initial_data": map[string]interface{}{ "profile": map[string]string{"email": email}, "residence_address": map[string]string{"country": country}, }, }) req, _ := http.NewRequest("POST", baseURL+"/api/v2/user", bytes.NewBuffer(reqBody)) req.Header.Set("Authorization", "Bearer "+accessToken) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Chain-Id", fmt.Sprintf("%d", chainID)) resp, err := http.DefaultClient.Do(req) if err != nil { return "", err } defer resp.Body.Close() var result struct{ ID string `json:"id"` } json.NewDecoder(resp.Body).Decode(&result) return result.ID, nil } ``` -------------------------------- ### Load Wirex BaaS Agent Skills Locally (Claude Code) Source: https://docs.wirexapp.com/docs/agent-skills Clone the repository and load the Wirex BaaS agent skills directly for Claude Code. ```bash git clone https://github.com/wirexapp/wirex-baas-agent-skills.git claude --plugin-dir ./wirex-baas-agent-skills ``` -------------------------------- ### Available SDK Methods Source: https://docs.wirexapp.com/docs/onchain-registration Lists the available methods within the Wirex SDK for account abstraction and smart wallet management. ```APIDOC ## Available SDK Methods ### Description Lists the available methods within the Wirex SDK for account abstraction and smart wallet management. ### Methods #### `sdk.crypto.accountAbstraction` - `isPolicyInstalled()`: Check if execution delay policy is installed. - `isExecutorInstalled()`: Check if funds management executor is installed. - `signInPolicyAndExecutor()`: Install both in one transaction. - `signInPolicy()`: Install policy only. - `signInExecutor()`: Install executor only. #### `sdk.crypto.accountContract` - `isWalletInAccounts()`: Check if registered. - `registerInAccounts()`: Register user. #### `sdk.crypto.wallet` - `getSmartWalletClient()`: Get Kernel account client. ``` -------------------------------- ### Simulate SEPA Deposit in Go Source: https://docs.wirexapp.com/docs/sandbox-testing-reference This Go function simulates a SEPA deposit. It requires the user's email and the deposit amount. Ensure the helperAPI constant is correctly set and necessary imports are included. ```go package main import ( "bytes" "encoding/json" "net/http" ) const helperAPI = "https://ramc.wirexapp.tech" type SepaDepositRequest struct { Region string `json:"region"` Email string `json:"email"` Amount float64 `json:"amount"` } func simulateSepaDeposit(email string, amount float64) error { body, _ := json.Marshal(SepaDepositRequest{ Region: "GB", Email: email, Amount: amount, }) _, err := http.Post( helperAPI+"/bank/sepa/deposit", "application/json", bytes.NewBuffer(body), ) return err } ``` -------------------------------- ### Webhook Payload Example Source: https://docs.wirexapp.com/docs/card-transactions Example JSON payload received via the Activity Webhook for a completed card transaction. This payload contains detailed information about the transaction, including amounts, status, and activity steps. ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "user_address": "0x1234567890abcdef1234567890abcdef12345678", "source": { "type": "Cards", "card": { "id": "64120850-73a1-4df5-a074-d463258c9deb", "pan_last": "1234", "payment_system": "Visa" } }, "destination": { "type": "Merchant", "merchant": { "name": "Amazon", "category": "Online Shopping", "country": "US" } }, "status": "Completed", "status_reason": null, "source_amount": { "amount": 50.00, "token_symbol": "WUSD", "token_address": "0x..." }, "destination_amount": { "amount": 50.00, "currency": "USD" }, "type": "CardTransaction", "direction": "Outbound", "operations": [ { "hash": "0xabc123...", "operation_amount": { "amount": -50.00, "token_symbol": "WUSD", "token_address": "0x..." }, "transaction_amount": { "amount": 50.00, "currency": "USD" }, "rate": { "ticker": "USD/WUSD", "rate": 1.0 } } ], "activity_steps": [ { "type": "Initiated", "status": "Completed", "created_at": "2024-01-15T10:00:00Z", "completed_at": "2024-01-15T10:00:00Z" }, { "type": "CryptoOut", "status": "Completed", "created_at": "2024-01-15T10:00:01Z", "completed_at": "2024-01-15T10:00:05Z" }, { "type": "CardOut", "status": "Completed", "created_at": "2024-01-15T10:00:05Z", "completed_at": "2024-01-15T10:00:06Z" }, { "type": "Completed", "status": "Completed", "created_at": "2024-01-15T10:00:06Z", "completed_at": "2024-01-15T10:00:06Z" } ], "created_at": "2024-01-15T10:00:00Z" } ``` -------------------------------- ### sdk.crypto.accountAbstraction.isExecutorInstalled Source: https://docs.wirexapp.com/docs/sdk Check if `FundsManagementExecutor` is installed. ```APIDOC ## GET sdk.crypto.accountAbstraction.isExecutorInstalled ### Description Check if `FundsManagementExecutor` is installed. ### Method GET ### Endpoint /sdk/crypto/account-abstraction/is-executor-installed ### Response #### Success Response (200) - **isInstalled** (boolean) - True if the executor is installed, false otherwise. ### Response Example { "isInstalled": true } ``` -------------------------------- ### Check User Capabilities (Python) Source: https://docs.wirexapp.com/docs/card-issuance This Python snippet demonstrates how to retrieve user information and verify if the user is eligible to issue virtual cards. ```python response = requests.get( f"{base_url}/api/v2/user", headers={ "Authorization": f"Bearer {access_token}", "X-User-Address": user_eoa_address, "X-Chain-Id": chain_id } ) user = response.json() virtual_card = next((c for c in user["capabilities"] if c["type"] == "VisaVirtualCard"), None) if virtual_card and virtual_card["status"] == "Active": # User can issue virtual cards pass ``` -------------------------------- ### Wirex BaaS Skill Structure Source: https://docs.wirexapp.com/docs/agent-skills Illustrates the directory structure for a typical Wirex BaaS skill, including the main skill file and reference documentation. ```text skills/wirex-baas-{name}/ ├── SKILL.md # Main skill file with YAML frontmatter └── references/ # Detailed documentation ├── REFERENCE.md # API endpoint details └── ... # Additional reference files ``` -------------------------------- ### sdk.crypto.wallet.getSmartAccountSigner Source: https://docs.wirexapp.com/docs/sdk Get signer for Smart Account. ```APIDOC ## GET sdk.crypto.wallet.getSmartAccountSigner ### Description Get signer for Smart Account. ### Method GET ### Endpoint /sdk/crypto/wallet/smart-account-signer ### Response #### Success Response (200) - **signer** (object) - The signer object for the Smart Account. ### Response Example { "signer": { "type": "SmartAccountSigner" } } ``` -------------------------------- ### Configure Cursor for Wirex BaaS MCP Server Source: https://docs.wirexapp.com/docs/mcp-server Add this configuration to `~/.cursor/mcp.json` to connect Cursor to the Wirex BaaS MCP server. ```json { "mcpServers": { "wirex-baas": { "url": "https://docs.wirexapp.com/mcp" } } } ``` -------------------------------- ### sdk.api.baas.rates.getRates Source: https://docs.wirexapp.com/docs/sdk Get exchange rates between currencies. ```APIDOC ## GET sdk.api.baas.rates.getRates ### Description Get exchange rates. ### Method GET ### Endpoint /sdk/api/baas/rates ### Parameters #### Query Parameters - **request** (object) - Optional - Specifies the currencies for which to get rates. - **from** (string) - The base currency. - **to** (string) - The target currency. ### Response #### Success Response (200) - **data** (object) - An object containing exchange rates. ### Response Example { "data": { "USD_EUR": 0.92 } } ```