@akcanetwork/x402
v0.2.2
Published
Akca x402 SDK - Pay-per-use proxy and VPN via Solana USDC
Maintainers
Readme
@akcanetwork/x402
Pay-per-use anonymous proxy and VPN SDK via Solana USDC. Built on the x402 protocol (HTTP 402 + on-chain payments).
Install
npm install @akcanetwork/x402Peer dependencies: @solana/web3.js and @solana/spl-token
Quick Start
import { AkcaX402Client } from '@akcanetwork/x402';
import { Keypair } from '@solana/web3.js';
const wallet = Keypair.fromSecretKey(/* your key */);
const akca = new AkcaX402Client({ wallet });
// Proxy a request through German exit node
const result = await akca.fetch('https://api.example.com/data', {
country: 'DE',
});
// 402 → auto-pay USDC → 200 OK
console.log(result.body);API
new AkcaX402Client({ baseUrl?, wallet, rpcUrl? })
| Param | Type | Default |
|-------|------|---------|
| baseUrl | string | https://api.akca.network |
| wallet | Keypair | required |
| rpcUrl | string | Solana mainnet |
Proxy
// Single request (0.001 USDC)
await akca.fetch(url, { method, headers, body, country });
// 24h session (1.00 USDC)
await akca.createProxySession({ country: 'DE' });VPN (Manual)
// List servers (free)
const servers = await akca.getVpnServers();
// Get pricing (free)
const pricing = await akca.getVpnPricing();
// Connect (0.50 USDC / 24h)
const vpn = await akca.connectVpn({
serverId: servers[0].id,
duration: '24h', // '24h' | '7d' | '30d'
});
console.log(vpn.config); // WireGuard config
// Disconnect
await akca.disconnectVpn(vpn.session.id);VPN Auto-Install + Tunnel
import { quickVpn } from '@akcanetwork/x402';
// One line: auto-install WireGuard + pay USDC + bring up tunnel
const vpn = await quickVpn({
wallet,
country: 'US',
duration: '24h',
});
// All system traffic now routes through VPN
await vpn.disconnect(); // tunnel down + peer removedVPN Manager (Advanced)
import { AkcaX402Client, AkcaVpnManager } from '@akcanetwork/x402';
const akca = new AkcaX402Client({ wallet });
const mgr = new AkcaVpnManager();
// Auto-install AmneziaWG/WireGuard if missing
const info = await mgr.ensureInstalled();
// { installed: true, binary: 'awg-quick', type: 'amneziawg' }
// Connect and get config
const vpn = await akca.connectVpn({ serverId: 'us-virginia-1' });
// Bring up tunnel (writes config + wg-quick up)
await mgr.up(vpn.config);
// Check status
const status = await mgr.status();
// Bring down tunnel
await mgr.down();
await akca.disconnectVpn(vpn.session.id);Supported platforms: Ubuntu/Debian (apt), Fedora/RHEL (dnf), Arch (pacman), macOS (brew). Prefers AmneziaWG (DPI bypass), falls back to standard WireGuard.
How x402 Works
- SDK sends request to Akca API
- API returns
402 Payment Requiredwith USDC amount - SDK creates and signs a Solana USDC transfer
- SDK retries with
X-PAYMENT: <tx-signature>header - API verifies on-chain, returns response + session cookie
- Subsequent requests use the session cookie (no re-payment)
Proxy vs VPN
| Requests | Proxy Cost | VPN Cost | Best Choice | |----------|-----------|----------|-------------| | 10 | $0.01 | $0.50 | Proxy | | 100 | $0.10 | $0.50 | Proxy | | 500 | $0.50 | $0.50 | Tie | | 1,000+ | $1.00+ | $0.50 | VPN |
Rule of thumb: < 500 requests → Proxy. 500+ requests → VPN.
Pricing
| Product | Tier | Price | |---------|------|-------| | Proxy | Per request | 0.001 USDC | | Proxy | 24h session | 1.00 USDC | | VPN | 24h | 0.50 USDC | | VPN | 7d | 2.00 USDC | | VPN | 30d | 6.00 USDC |
License
MIT - Akca Network
