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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Sell your API · Robinhood Chain Examples</title>
<meta name="description" content="x402 server middleware" />
<link rel="stylesheet" href="../../style.css" />
<link rel="stylesheet" href="../../hljs-theme.css" />
</head>
<body>
<div class="topbar">
<a class="brand" href="../../index.html">Robinhood Chain Examples</a>
<a class="ghlink" href="https://github.com/nirholas/robinhood-chain-examples">GitHub ↗</a>
</div>
<div class="wrap"><div class="readme"><h1>10 · Sell your API</h1>
<p>Put a USDG paywall in front of any Robinhood Chain endpoint. The entire paid
route is one <code>paywall()</code> middleware from
<a href="https://www.npmjs.com/package/hood402"><code>hood402</code></a> plus one handler that reads
the chain with <code>hoodchain</code>. Everything else in the file is startup wiring and
a self-check that proves the gate is live.</p>
<p>This is the sell side of <a href="../09-x402-paid-api-call">example 09</a>. Run them
together and you have a complete market: an agent discovers a price it can
read, pays it, and gets data back, with no account and no API key anywhere.</p>
<p><strong>What it proves:</strong> monetizing an endpoint is middleware, not architecture.
Any spec-compliant x402 client can pay this route, and a free route can sit
directly beside a paid one in the same app.</p>
<h2>Prerequisites</h2>
<ul>
<li>Node ≥ 20.</li>
<li><strong>No key needed.</strong> With no settlement credentials the server self-settles
from a freshly generated gas key that holds nothing: challenges and
signature verification are fully real, and a paid request stops honestly at
"insufficient gas wallet" instead of pretending to settle.</li>
</ul>
<h2>Run</h2>
<pre><code class="hljs language-bash">npm install
npm start <span class="hljs-comment"># boot on testnet, self-check, keep serving</span>
npm start -- --once <span class="hljs-comment"># boot, self-check, exit (what CI runs)</span>
HOOD402_NETWORK=robinhood npm start <span class="hljs-comment"># mainnet 4663 instead</span>
HOOD402_PAY_TO=0x... npm start <span class="hljs-comment"># your own settlement address</span>
</code></pre><h2>Expected output</h2>
<pre><code>hood402 paid endpoint - robinhood-testnet (chain 46630)
paid : GET http://127.0.0.1:8010/v1/quote/:symbol 0.01 USDG
free : GET http://127.0.0.1:8010/v1/symbols
payTo: 0xA9b426C23E7dDc33Eb2B2fB69A058f2749F61daC
settle: self-settle (ephemeral unfunded gas key)
USDG : 0x7E955252E15c84f5768B83c41a71F9eba181802F
data : mainnet 4663 Chainlink feeds (reads are free and public)
GET /v1/quote/AAPL with no payment -> HTTP 402
x402Version 1
scheme exact
network robinhood-testnet
asset 0x7E955252E15c84f5768B83c41a71F9eba181802F (USDG, 6 decimals)
maxAmount 10000 atomic = 0.01 USDG
payTo 0xA9b426C23E7dDc33Eb2B2fB69A058f2749F61daC
description Robinhood Chain Stock Token quote: Chainlink oracle price, feed, and freshness.
GET /v1/symbols (free) -> HTTP 200, 95 Stock Tokens, no payment required
--once: self-check done, shutting down. Drop the flag to keep serving.
</code></pre><h2>Two ways to settle, both real</h2>
<p>Pick one with an environment variable:</p>
<table>
<thead>
<tr>
<th>Setting</th>
<th>What happens</th>
<th>Who pays gas</th>
</tr>
</thead>
<tbody><tr>
<td><code>FACILITATOR_URL=https://...</code></td>
<td>Verify and settle are delegated. This process never holds a key.</td>
<td>The facilitator</td>
</tr>
<tr>
<td><code>FACILITATOR_PRIVATE_KEY=0x...</code></td>
<td>This process broadcasts the authorization itself. Needs ETH on the chosen network.</td>
<td>You</td>
</tr>
<tr>
<td>neither</td>
<td>Self-settle from an ephemeral unfunded key. Challenges and verification are real; settlement stops honestly.</td>
<td>Nobody</td>
</tr>
</tbody></table>
<p>The third row is the default because it makes the example runnable by anyone
in one command while refusing to fake the part it cannot actually do.</p>
<h2>Charging for your own endpoint</h2>
<p>Swap the handler and keep the middleware. The price, the asset, and the
settlement address are all arguments:</p>
<pre><code class="hljs language-js">app.<span class="hljs-title function_">get</span>(<span class="hljs-string">'/v1/quote/:symbol'</span>, <span class="hljs-title function_">paywall</span>({ <span class="hljs-attr">price</span>: <span class="hljs-string">'0.01'</span>, <span class="hljs-attr">payTo</span>: <span class="hljs-variable constant_">MY_ADDRESS</span> }), handler)
</code></pre><hr>
<p>Built by <a href="https://x.com/nichxbt">nirholas</a> · <a href="https://three.ws">three.ws</a></p>
</div></div>
<footer>
Built by <a href="https://x.com/nichxbt">nirholas</a> ·
<a href="https://three.ws">three.ws</a> ·
powered by <a href="https://github.com/nirholas/robinhood-chain-sdk">hoodchain</a>
</footer>
</body>
</html>