Troubleshooting

Common issues and solutions when using Shade402.

Payment Issues

Payment Not Detected

Problem: Server doesn't detect payment authorization.

Solutions:

  • Check that X-Payment-Authorization header is included

  • Verify header is base64-encoded JSON

  • Check that payment authorization format is correct

  • Ensure middleware is processing the header

// Debug: Log headers
app.use((req, res, next) => {
  console.log('Headers:', req.headers);
  next();
});

Payment Verification Fails

Problem: Payment verification fails even though transaction exists.

Solutions:

  • Check RPC endpoint is correct and accessible

  • Verify network matches (devnet vs mainnet)

  • Ensure transaction is confirmed on blockchain

  • Check transaction signature is valid

  • Verify payment addresses match

Payment Expired

Problem: Payment request expires before payment is made.

Solutions:

  • Increase expiration time

  • Make payment faster

  • Check system clock synchronization

  • Use shorter expiration for automated flows

Insufficient Funds

Problem: Wallet doesn't have enough tokens.

Solutions:

  • Check wallet balance

  • Ensure correct token mint address

  • Verify token account exists

  • Add funds to wallet

Client Issues

Cannot Connect to RPC

Problem: Client cannot connect to Solana RPC endpoint.

Solutions:

  • Check RPC URL is correct

  • Verify network connectivity

  • Try different RPC endpoint

  • Check rate limits on RPC provider

Transaction Broadcast Fails

Problem: Transaction fails to broadcast.

Solutions:

  • Check network congestion

  • Verify recent blockhash

  • Ensure sufficient SOL for fees

  • Retry transaction

URL Validation Errors

Problem: Client rejects localhost URLs.

Solutions:

  • Enable allowLocal for development

  • Use production URLs in production

  • Check URL format is correct

Server Issues

402 Response Not Sent

Problem: Server doesn't send 402 response when payment required.

Solutions:

  • Check middleware is applied correctly

  • Verify payment authorization header is missing

  • Ensure error middleware is after routes

  • Check middleware order

Payment Authorization Not Parsed

Problem: Server cannot parse payment authorization.

Solutions:

  • Check header format is correct

  • Verify base64 encoding

  • Check JSON structure

  • Validate all required fields

Resource Encryption Fails

Problem: Resource encryption/decryption fails.

Solutions:

  • Verify RSA keys are correct format

  • Check keys are PEM format

  • Ensure public/private key pair matches

  • Verify encryption algorithm compatibility

Configuration Issues

Configuration Not Initialized

Problem: Error that X402 is not initialized.

Solutions:

  • Call initX402() before using middleware

  • Ensure initialization happens once at startup

  • Check configuration values are set

Environment Variables Not Loaded

Problem: Configuration values are undefined.

Solutions:

  • Check .env file exists

  • Verify environment variables are loaded

  • Use dotenv package if needed

  • Check variable names match

Network Issues

Wrong Network

Problem: Using wrong Solana network.

Solutions:

  • Check network configuration matches

  • Verify devnet vs mainnet

  • Ensure RPC endpoint matches network

  • Check token mint matches network

RPC Rate Limiting

Problem: RPC endpoint rate limits exceeded.

Solutions:

  • Use different RPC provider

  • Implement rate limiting

  • Add retry logic with backoff

  • Use premium RPC service

TypeScript Issues

Type Errors

Problem: TypeScript compilation errors.

Solutions:

  • Install type definitions

  • Check TypeScript version

  • Verify import paths

  • Use correct type annotations

Debugging Tips

Enable Verbose Logging

Check Transaction Status

Test Payment Flow Manually

Getting Help

If you're still experiencing issues:

  1. Check the Examples for working code

  2. Review Best Practices for common patterns

  3. Check Security for configuration issues

  4. Open an issue on GitHub with:

    • Error messages

    • Code snippets

    • Configuration (without secrets)

    • Network and environment details

Next Steps

Last updated