Pay.sh
x402 Micro-Payments

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

ComponentDetail
Protocolx402 (HTTP 402 payment challenges)
NetworkSolana mainnet USDC
ProviderVybe Network (opens in a new tab) — token prices, holders, DEX trades
Cost~$0.012 USDC per call
WalletPer-user keypair stored in GCP Secret Manager
ReceiptEvery 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 VDL

Per-User Pay.sh Wallet

Each Heron user gets a dedicated Solana wallet for pay.sh purchases:

Create (UI)

  1. User clicks "Create Pay.sh Wallet" in the Pay.sh tab
  2. Backend generates a new Solana keypair
  3. Keypair stored securely in GCP Secret Manager
  4. Public address returned to the user

Fund (UI)

  1. User sends mainnet USDC from their connected wallet to the pay.sh address
  2. Balance displayed in the UI
  3. 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 only

The backend loads the keypair on each decision cycle — it never caches private keys in memory longer than needed.

Budget Controls

VariablePurposeDefault
PAYSH_MAX_USDCMax per-call spend$0.10
PAYSH_BUDGET_USDCLifetime 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

EndpointMethodDescription
/api/paysh-walletGETWallet address + balance
/api/paysh-wallet/createPOSTCreate new pay.sh wallet
/api/paysh-wallet/fundPOSTGet fund-to address
/api/paysh-subscriptionsGETWhich services are enabled
/api/paysh-subscriptionsPOSTToggle services on/off
/api/paysh-activityGETSpending log

Links