Overview
Implementing delegation requires coordination between your backend (API calls) and frontend (wallet interaction). This guide walks through all four steps with complete code examples.Architecture Note: Steps 1, 3, and 4 are backend API calls. Step 2 happens entirely in your frontend with Web3 libraries and wallet providers.
Prerequisites
Before implementing delegation, ensure you have:User Account Requirements
User Account Requirements
- User must have completed registration including consent acceptance
- User must have accepted terms of service and data processing consent
- User must have completed identity verification (KYC)
- See Consent Management for compliance tracking
API Authentication
API Authentication
- Client public key (
x-client-keyheader) - User access token (OAuth2 Bearer token)
- Valid API credentials from your dashboard
Frontend Requirements
Frontend Requirements
- Web3 library installed (ethers.js, web3.js, or @solana/web3.js)
- Wallet provider support (MetaMask, WalletConnect, Phantom)
- User has wallet installed and funded with desired currency
Smart Contract Information
Smart Contract Information
- Token contract addresses for each network (USDC/USDT)
- Platform spender addresses for approvals
- Chain IDs for each supported network
- Obtain dynamically: Call
GET /v1/delegation/chain/configto retrieve all addresses and chain IDs before Step 1
Step 1: Request Delegation Token
Call your backend to generate a single-use delegation token from the API.Backend Implementation
GET /v1/delegation/token
Response
Token Characteristics
- Single-use only: Becomes invalid after use in Step 3
- ~10 minute lifetime: Complete the flow before expiration
- Temporary storage: Store in session/state, not database
- Pass to frontend: Required for Step 3 submission
Step 2: Frontend Wallet Interaction
This step happens entirely in your frontend application. The API does not provide this functionality.Important: This is client-side code that runs in the browser. You’ll need to implement this using Web3 libraries and wallet provider integrations.
Architecture Overview
Required Tasks
Your frontend must complete these tasks:1
Connect User's Wallet
Use Web3 provider to connect to user’s wallet application
2
Request Network Switch
Ensure user is on correct blockchain network (if needed)
3
Request Approval Transaction
Call token contract’s approval function with spending limit
4
Wait for Confirmation
Monitor blockchain for transaction confirmation
5
Request Message Signature
Have user sign a message to prove wallet ownership
6
Collect Transaction Data
Gather all required fields for Step 3 submission
Frontend Implementation (EVM Example)
Frontend Implementation (Solana Example)
UI/UX Recommendations
- Transaction Preview
- Progress Indicator
- Error Handling
Show users exactly what they’re approving before signing:
Step 3: Submit Delegation Proof
Call your backend to submit the delegation proof and finalize wallet registration.Use the blockchain-specific endpoint:
/v1/delegation/evm/post-approval for EVM chains (Linea/Ethereum) or /v1/delegation/solana/post-approval for Solana.Backend Implementation (EVM)
Backend Implementation (Solana)
POST /v1/delegation/evm/post-approval
Response
What Happens
- API validates address format (EVM vs Solana)
- API validates transaction hash format
- API verifies signature matches wallet address
- API validates blockchain transaction exists and is confirmed
- External wallet is registered and linked to user account
- User can now make card purchases using delegated wallet funds
Step 4: Verify Registration
Confirm the wallet was successfully registered and view its details.Backend Implementation
GET /v1/wallet/external
Response
Complete Flow Example
Here’s a complete end-to-end implementation example:Implementation Checklist
Use this checklist to ensure you’ve implemented all required components:Backend Requirements
- Implement delegation token request endpoint integration
- Implement blockchain-specific post-approval submission (EVM/Solana)
- Store delegation tokens securely (short-lived, single-use)
- Handle API errors gracefully with user feedback
- Implement wallet verification after delegation
- Add retry logic for failed API requests
- Log delegation attempts for debugging
Frontend Requirements
- Implement wallet connection UI (MetaMask, WalletConnect, Phantom)
- Support multiple blockchain networks (Linea, Ethereum, Solana)
- Display approval transaction details before signing
- Show transaction confirmation and status
- Implement signature collection (SIWE for EVM chains)
- Handle wallet errors and rejections
- Display current allowance and balance information
- Implement loading states and progress indicators
Smart Contract Integration
- Obtain correct token contract addresses for each network
- Obtain platform spender addresses for approvals
- Implement ERC20 approval flow for EVM chains
- Implement token account delegation for Solana
- Handle transaction confirmation and receipts
- Monitor blockchain for transaction success/failure
- Validate contract addresses before approval
Troubleshooting
Token Expired Error
Token Expired Error
Symptom: API returns error about expired token in Step 3Solution: Generate a new token and restart from Step 1. Tokens are valid for ~10 minutes.
Transaction Not Found
Transaction Not Found
Symptom: API can’t find the blockchain transactionSolutions:
- Wait longer for transaction confirmation (especially on Ethereum mainnet)
- Verify transaction hash is correct
- Check transaction status on block explorer
- Ensure you’re on the correct network
Invalid Signature
Invalid Signature
Symptom: API rejects signature in Step 3Solutions:
- Ensure sigMessage format matches SIWE specification (for EVM)
- Verify signature was created from the same wallet address
- Check that message wasn’t modified after signing
User Rejected Transaction
User Rejected Transaction
Symptom: Wallet throws error code 4001Solution: Allow user to retry without regenerating token. Keep the delegation token and retry Steps 2-3.
Wrong Network
Wrong Network
Symptom: Wallet is on different network than requestedSolution: Implement network switching in your frontend:
Next Steps
EVM Implementation
Dive deeper into EVM-specific implementation details
Solana Implementation
Learn Solana-specific delegation patterns
Priority Management
Configure which wallets are charged first
Redelegation
Update existing delegations when needed