Pay.sh — x402 Micro-Payments
Heron is a real pay.sh consumer — the agent buys market data before every allocation decision using x402 micro-payments on Solana mainnet.
Overview
| Component | Detail |
|---|---|
| Protocol | x402 (HTTP 402 payment challenges) |
| Network | Solana mainnet USDC |
| Provider | Vybe Network (opens in a new tab) — token prices, holders, DEX trades |
| Cost | ~$0.012 USDC per call |
| Wallet | Per-user keypair stored in GCP Secret Manager |
| Receipt | Every purchase receipt (tx signature, amount, payee) attached to decision record |
x402 Protocol Flow
Agent needs market data
→ GET https://x402-api.vybenetwork.xyz/v4/token-price/...
→ Server responds: HTTP 402 Payment Required
→ Challenge includes: payee address, amount, network
→ Agent signs USDC transfer to payee
→ Agent retries GET with payment proof
→ Server returns data
→ Receipt recorded in VDLPer-User Pay.sh Wallet
Each Heron user gets a dedicated Solana wallet for pay.sh purchases:
Create (UI)
- User clicks "Create Pay.sh Wallet" in the Pay.sh tab
- Backend generates a new Solana keypair
- Keypair stored securely in GCP Secret Manager
- Public address returned to the user
Fund (UI)
- User sends mainnet USDC from their connected wallet to the pay.sh address
- Balance displayed in the UI
- Agent draws from this balance for signal purchases
Subscribe (UI)
Users control which data services the agent should buy:
- Toggle individual services on/off
- Currently live: Vybe Network (token prices, analytics)
- Only enabled services incur costs
Activity Log
Every paid API call is logged:
- Timestamp, service, amount, tx signature
- Running total of spend
- Available in the Pay.sh tab
GCP Secret Manager Integration
Pay.sh wallet keypairs are stored in Google Cloud Secret Manager:
Secret name: paysh-wallet-{user_wallet_pubkey}
Contents: Base58-encoded Solana keypair
Access: Backend service account onlyThe backend loads the keypair on each decision cycle — it never caches private keys in memory longer than needed.
Budget Controls
| Variable | Purpose | Default |
|---|---|---|
PAYSH_MAX_USDC | Max per-call spend | $0.10 |
PAYSH_BUDGET_USDC | Lifetime budget cap | $5.00 |
If the budget is exhausted, the agent continues operating but without paid signals — it falls back to on-chain-only data.
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/paysh-wallet | GET | Wallet address + balance |
/api/paysh-wallet/create | POST | Create new pay.sh wallet |
/api/paysh-wallet/fund | POST | Get fund-to address |
/api/paysh-subscriptions | GET | Which services are enabled |
/api/paysh-subscriptions | POST | Toggle services on/off |
/api/paysh-activity | GET | Spending log |