x402 Payment Utilities
src/lib/x402.tsCore x402 protocol utilities for payment quotes, verification, and settlement with PayAI facilitator.
Available Functions
generatePaymentQuote() - Create payment quotes with fee calculationverifyPaymentWithFacilitator() - Verify payments via PayAIsettlePaymentWithFacilitator() - Settle verified paymentscalculateFeeDistribution() - Calculate platform feescreate402Response() - Generate HTTP 402 Payment Required responsesparsePaymentProof() - Parse payment proofs from headers or body
Wallet Integration
src/lib/wallet.tsBase network wallet utilities for connecting wallets, transferring USDC, and managing approvals.
Available Functions
connectWallet() - Connect MetaMask or other Web3 walletstransferUSDC() - Transfer USDC tokens on BaseapproveUSDC() - Approve USDC spendinggetUSDCBalance() - Check USDC balanceformatUSDC() - Format USDC amounts for display
PayAI Service Sync
src/lib/payai-sync.tsSynchronize services from PayAI facilitator to your database. Handles service discovery and normalization.
Available Functions
fetchPayAIServices() - Fetch services from PayAI facilitatorsyncPayAIServices() - Sync services to databasenormalizePayAIService() - Normalize PayAI service formatextractCategory() - Automatically categorize services
Panel Authentication
src/lib/panel-auth.tsAuthentication utilities for user and platform panels. Wallet-based access control.
Available Functions
verifyAdminAccess() - Verify admin wallet addressesgetUserFromRequest() - Extract user address from request
Fee Transfer
src/lib/fee-transfer.tsOn-chain fee transfer utilities. Transfers platform fees to fee recipient address.
Available Functions
transferFee() - Transfer fees on-chainbatchTransferFees() - Batch transfer multiple fees
Agent Payment Handler
src/lib/agent-payment.tsUtilities for r1x Agent to handle x402 payments. Processes payment requests and guides users.
Available Functions
handlePaymentRequest() - Process agent payment requestsgeneratePaymentMessage() - Create payment guidance messages