Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
Solana crypto paywall — @three-ws/x402-payment-modal demo
A complete, runnable demo that paywalls a free crypto-price API (CoinGecko) behind an x402 USDC payment on Solana, served to the payment modal we ship on npm. It exists to prove the published modal works end to end on a plain page:
click ─▶ 402 challenge ─▶ Phantom connect ─▶ sign SPL transfer
─▶ PayAI /verify ─▶ fetch CoinGecko ─▶ PayAI /settle ─▶ prices + receipt
Three things make it a real test, not a mock:
- The modal loads from npm.
public/index.htmlpullshttps://unpkg.com/@three-ws/[email protected], the exact artifact we publish — so you're testing the shipped code, not local source. - The data is gated for real.
/api/paid/cryptoreturns live CoinGecko prices only after the payment verifies and settles on-chain via the PayAI facilitator. No payment, no data. - The payout wallet is set at runtime. There is no
.envand no source constant for it — you start the server, paste a Solana address into the page, and that address becomes thepayToin the 402 challenge.
Run it (inside the three.ws repo)
The server reuses the repo's express + @solana/* and imports the package's
checkout helpers from source, so no install is needed:
node x402-payment-modal/examples/solana-crypto-paywall/server.mjs
# ▸ open http://localhost:4021
Then in the page:
- Set your payout wallet — paste a base58 Solana address, click Save.
- Pick coins — BTC / ETH / SOL / … (live from CoinGecko).
- Pay & unlock — approve $0.01 USDC in Phantom. Prices + an on-chain receipt (with a Solscan link) appear when settlement lands.
Paying is a real Solana mainnet micropayment — you need Phantom with a little USDC. The fee payer is covered by the facilitator, so you don't need SOL.
Run it standalone (outside the repo)
npm install
# in server.mjs, change the two relative imports to the package subpaths:
# '../../server/express.js' → '@three-ws/x402-payment-modal/server/express'
# '../../server/checkout.js' → '@three-ws/x402-payment-modal/server'
npm start
What's runtime vs. fixed
| Thing | Where it comes from |
|---|---|
Payout wallet (payTo) |
Set at runtime from the page — POST /api/config, in memory. No env. |
| Fee-payer sponsor | Public PayAI account PayeRNCipcerPHCsYMTrX9pAYDm1LnPGzgb66NUDG5a (pays SOL fees; not a secret, not the payout). Override with X402_FEE_PAYER_SOLANA only if you change facilitators. |
| Facilitator | https://facilitator.payai.network (no API key). Override with X402_FACILITATOR_URL. |
| Solana RPC | Public mainnet RPC. Override with SOLANA_RPC_URL for anything beyond a quick try. |
| Price | Fixed at $0.01 USDC. |
| Port | 4021, or PORT. |
Endpoints
| Method & path | Purpose |
|---|---|
GET /api/config |
Current payout wallet, fee payer, price, coin catalog. |
POST /api/config { payTo } |
Set the payout wallet at runtime (validated Solana address). |
POST /api/paid/crypto { ids } |
The paid resource. 402 until paid; verifies + settles, then returns live prices. |
ALL /api/x402-checkout |
The package's Solana prepare/encode router the modal calls. |
Files
server.mjs— Express app: runtime config, the 402 → verify → fetch → settle paid endpoint, and the package's checkout router.facilitator.mjs— minimal PayAI/verify+/settleclient (the merchant half of the protocol), mirroring the wire formatapi/_lib/x402-spec.jsuses.public/index.html— the demo page: runtime payout panel, coin picker, and designed loading / empty / error / populated states with an on-chain receipt.