Skip to content

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.

feat(x402): port x402-domains as a native Solana x402 service

nirholas92cd17eb6f42
diff --git a/api/_lib/service-catalog/services/domains-bulk.js b/api/_lib/service-catalog/services/domains-bulk.js
new file mode 100644
index 000000000..f7aa5f4c2
--- /dev/null
+++ b/api/_lib/service-catalog/services/domains-bulk.js
@@ -0,0 +1,44 @@
+// Service-catalog descriptor: see news-pulse.js for the contract notes.
+// Do not re-add a hand-written mirror for this route in api/wk.js.
+
+export default {
+ slug: 'domains-bulk',
+ title: 'Domain Check (Bulk RDAP)',
+ category: 'live-data',
+ useCase: 'three.ws Domain Check Bulk: $0.005 USDC per call checks up to 50 domains in one paid RDAP sweep, for domain-portfolio audits and brand-protection scans.',
+ path: '/api/x402/domains-bulk',
+ method: 'POST',
+ free: false,
+ status: 'live',
+ priceAtomics: '5000',
+ acceptsBuilder: 'standard',
+ serviceName: 'three.ws Domain Intelligence',
+ tags: ['domains', 'rdap', 'live-data', 'dns', 'bulk'],
+ description: 'three.ws Domain Check Bulk: pay $0.005 USDC per call to check up to 50 domains in one request against their authoritative RDAP servers, with bounded concurrency. Returns a per-domain registration breakdown plus registered/available/unknown counts, for domain-portfolio audits and brand-protection scans.',
+ input: { domains: ['example.com', 'example.net', 'example.org'] },
+ inputSchema: {
+ type: 'object',
+ required: ['domains'],
+ properties: {
+ domains: {
+ type: 'array',
+ items: { type: 'string' },
+ minItems: 1,
+ maxItems: 50,
+ description: 'Domains to check, 1 to 50 per call.',
+ },
+ },
+ },
+ outputExample: {
+ count: 3,
+ registered: 2,
+ available: 1,
+ unknown: 0,
+ results: [
+ { domain: 'example.com', status: 'registered', available: false },
+ { domain: 'example.net', status: 'registered', available: false },
+ { domain: 'a-free-name-example.com', status: 'available', available: true },
+ ],
+ },
+ storefronts: ['x402scan'],
+};
diff --git a/api/_lib/service-catalog/services/domains-check.js b/api/_lib/service-catalog/services/domains-check.js
new file mode 100644
index 000000000..d583fa306
--- /dev/null
+++ b/api/_lib/service-catalog/services/domains-check.js
@@ -0,0 +1,43 @@
+// Service-catalog descriptor: see news-pulse.js for the contract notes.
+// Do not re-add a hand-written mirror for this route in api/wk.js.
+
+export default {
+ slug: 'domains-check',
+ title: 'Domain Check (RDAP)',
+ category: 'live-data',
+ useCase: 'three.ws Domain Check: $0.001 USDC per call returns live registration status for one domain, straight from its authoritative RDAP server (RFC 9082/9083), no WHOIS scraping, no API key.',
+ path: '/api/x402/domains-check',
+ method: 'GET',
+ free: true,
+ status: 'live',
+ priceAtomics: '1000',
+ acceptsBuilder: 'standard',
+ serviceName: 'three.ws Domain Intelligence',
+ tags: ['domains', 'rdap', 'live-data', 'dns'],
+ description: 'three.ws Domain Check: live public-data endpoint, no API key anywhere in the chain. Pay $0.001 USDC (or use the free daily per-IP quota) to query the authoritative RDAP server for a domain (resolved via the IANA bootstrap registry, with an rdap.org fallback) and get its registration status, registrar, creation/update/expiry dates, nameservers, status flags, and DNSSEC signing state.',
+ input: { domain: 'example.com' },
+ inputSchema: {
+ type: 'object',
+ required: ['domain'],
+ properties: {
+ domain: { type: 'string', description: 'Domain name to check, e.g. "example.com".' },
+ },
+ },
+ outputExample: {
+ domain: 'example.com',
+ status: 'registered',
+ available: false,
+ registrar: 'RESERVED-Internet Assigned Numbers Authority',
+ registrarIanaId: '376',
+ createdAt: '1995-08-14T04:00:00Z',
+ updatedAt: '2024-08-14T07:01:38Z',
+ expiresAt: '2025-08-13T04:00:00Z',
+ nameservers: ['a.iana-servers.net', 'b.iana-servers.net'],
+ statusFlags: ['client delete prohibited', 'client transfer prohibited', 'client update prohibited'],
+ dnssecSigned: true,
+ rdapServer: 'https://rdap.verisign.com/com/v1/domain/example.com',
+ source: 'rdap',
+ checkedAt: '2026-10-14T00:00:00Z',
+ },
+ storefronts: ['x402scan'],
+};
diff --git a/api/_lib/service-catalog/services/index.js b/api/_lib/service-catalog/services/index.js
index b09645ffb..5f3d57034 100644
--- a/api/_lib/service-catalog/services/index.js
+++ b/api/_lib/service-catalog/services/index.js
@@ -78,6 +78,8 @@ import weatherGuardForecast from './weather-guard-forecast.js';
import weatherGuardDecision from './weather-guard-decision.js';
import carbonNow from './carbon-now.js';
import carbonBestWindow from './carbon-best-window.js';
+import domainsCheck from './domains-check.js';
+import domainsBulk from './domains-bulk.js';
export const PAID_SERVICES = Object.freeze([
modelCheck,
@@ -145,4 +147,6 @@ export const PAID_SERVICES = Object.freeze([
weatherGuardDecision,
carbonNow,
carbonBestWindow,
+ domainsCheck,
+ domainsBulk,
]);
diff --git a/api/_lib/x402-services/domains.js b/api/_lib/x402-services/domains.js
new file mode 100644
index 000000000..bb0a42b9a
--- /dev/null
+++ b/api/_lib/x402-services/domains.js
@@ -0,0 +1,181 @@
+// Live domain availability and registration intelligence over RDAP
+// (Registration Data Access Protocol, RFC 9082/9083), the IANA-standard
+// successor to WHOIS. Keyless and live: resolve the authoritative RDAP
+// server for a TLD via the IANA bootstrap registry, falling back to the
+// rdap.org aggregator when a TLD has no bootstrap entry.
+
+const THREE_WS_UA = 'three.ws/1.0 (+https://three.ws; [email protected])';
+const IANA_BOOTSTRAP_URL = 'https://data.iana.org/rdap/dns.json';
+const RDAP_ORG_BASE = 'https://rdap.org';
+const BOOTSTRAP_TTL_MS = 24 * 60 * 60 * 1000;
+
+let bootstrapCache = null;
+
+function domainError(code, message, status = 400) {
+ const err = new Error(message);
+ err.status = status;
+ err.code = code;
+ return err;
+}
+
+const DOMAIN_RE = /^(?=.{1,253}$)([a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
+
+export function normalizeDomain(raw) {
+ const d = String(raw || '').trim().toLowerCase().replace(/\.$/, '');
+ if (!DOMAIN_RE.test(d)) throw domainError('invalid_domain', `"${raw}" is not a valid domain name`, 400);
+ return d;
+}
+
+async function fetchJson(url, timeoutMs = 10_000) {
+ const controller = new AbortController();
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
+ try {
+ const res = await fetch(url, {
+ headers: { accept: 'application/rdap+json, application/json', 'user-agent': THREE_WS_UA },
+ redirect: 'follow',
+ signal: controller.signal,
+ });
+ let body = null;
+ try {
+ body = await res.json();
+ } catch {
+ body = null;
+ }
+ return { status: res.status, body };
+ } finally {
+ clearTimeout(timer);
+ }
+}
+
+async function getBootstrapMap() {
+ if (bootstrapCache && Date.now() - bootstrapCache.fetchedAt < BOOTSTRAP_TTL_MS) return bootstrapCache.map;
+ const { status, body } = await fetchJson(IANA_BOOTSTRAP_URL, 15_000);
+ if (status !== 200 || !body || typeof body !== 'object') {
+ if (bootstrapCache) return bootstrapCache.map; // serve stale on refresh failure
+ return new Map();
+ }
+ const map = new Map();
+ for (const [tlds, urls] of body.services ?? []) {
+ const base = urls.find((u) => u.startsWith('https://')) ?? urls[0];
+ if (!base) continue;
+ for (const tld of tlds) map.set(tld.toLowerCase(), base.replace(/\/$/, ''));
+ }
+ bootstrapCache = { map, fetchedAt: Date.now() };
+ return map;
+}
+
+function eventDate(events, action) {
+ return events?.find((e) => e.eventAction === action)?.eventDate ?? null;
+}
+
+function findRegistrar(entities) {
+ for (const e of entities ?? []) {
+ if (e.roles?.includes('registrar')) {
+ let name = null;
+ const vcard = e.vcardArray?.[1];
+ if (Array.isArray(vcard)) {
+ const fn = vcard.find((entry) => entry[0] === 'fn');
+ if (fn && typeof fn[3] === 'string') name = fn[3];
+ }
+ const ianaId = e.publicIds?.find((p) => String(p.type || '').toLowerCase().includes('iana'))?.identifier ?? null;
+ return { name, ianaId };
+ }
+ const nested = findRegistrar(e.entities);
+ if (nested.name || nested.ianaId) return nested;
+ }
+ return { name: null, ianaId: null };
+}
+
+function emptyCheck(domain, status, overrides) {
+ return {
+ domain,
+ status,
+ available: null,
+ registrar: null,
+ registrarIanaId: null,
+ createdAt: null,
+ updatedAt: null,
+ expiresAt: null,
+ nameservers: [],
+ statusFlags: [],
+ dnssecSigned: null,
+ rdapServer: null,
+ source: 'rdap',
+ checkedAt: new Date().toISOString(),
+ ...overrides,
+ };
+}
+
+export async function checkDomain(raw) {
+ const domain = normalizeDomain(raw);
+ const tld = domain.split('.').pop();
+
+ const bootstrap = await getBootstrapMap();
+ const base = bootstrap.get(tld) ?? RDAP_ORG_BASE;
+ const rdapServer = `${base}/domain/${encodeURIComponent(domain)}`;
+
+ let status;
+ let body;
+ try {
+ ({ status, body } = await fetchJson(rdapServer));
+ } catch {
+ return emptyCheck(domain, 'unknown', { rdapServer, note: 'RDAP server unreachable or timed out' });
+ }
+
+ if (status === 404) {
+ return emptyCheck(domain, 'available', {
+ available: true,
+ rdapServer,
+ note: 'No registration found in the authoritative RDAP registry, the domain is likely available (registry-level reservations may still apply).',
+ });
+ }
+
+ if (status !== 200 || !body || typeof body !== 'object') {
+ return emptyCheck(domain, 'unknown', {
+ rdapServer,
+ note: `RDAP query returned HTTP ${status}, this TLD may not support RDAP or rate limits applied`,
+ });
+ }
+
+ const registrar = findRegistrar(body.entities);
+ return {
+ domain,
+ status: 'registered',
+ available: false,
+ registrar: registrar.name,
+ registrarIanaId: registrar.ianaId,
+ createdAt: eventDate(body.events, 'registration'),
+ updatedAt: eventDate(body.events, 'last changed') ?? eventDate(body.events, 'last update of RDAP database'),
+ expiresAt: eventDate(body.events, 'expiration'),
+ nameservers: (body.nameservers ?? []).map((n) => String(n.ldhName || '').toLowerCase()).filter(Boolean),
+ statusFlags: body.status ?? [],
+ dnssecSigned: body.secureDNS?.delegationSigned ?? null,
+ rdapServer,
+ source: 'rdap',
+ checkedAt: new Date().toISOString(),
+ };
+}
+
+const BULK_MAX = 50;
+const BULK_CONCURRENCY = 8;
+
+export async function checkBulk(domains, max = BULK_MAX) {
+ if (!Array.isArray(domains) || domains.length === 0) throw domainError('empty_list', 'Provide a non-empty array of domains', 400);
+ if (domains.length > max) throw domainError('too_many_domains', `Maximum ${max} domains per bulk request (got ${domains.length})`, 400);
+
+ const unique = [...new Set(domains.map((d) => String(d)))];
+ const results = new Array(unique.length);
+ let next = 0;
+ async function worker() {
+ while (next < unique.length) {
+ const i = next++;
+ try {
+ results[i] = await checkDomain(unique[i]);
+ } catch (err) {
+ results[i] = emptyCheck(unique[i], 'unknown', { note: err.message || 'lookup failed' });
+ }
+ }
+ }
+ await Promise.all(Array.from({ length: Math.min(BULK_CONCURRENCY, unique.length) }, worker));
+ return results;
+}
diff --git a/api/x402/domains-bulk.js b/api/x402/domains-bulk.js
new file mode 100644
index 000000000..ffdf23a3c
--- /dev/null
+++ b/api/x402/domains-bulk.js
@@ -0,0 +1,81 @@
+// POST /api/x402/domains-bulk body: {"domains":["example.com", ...]}
+//
+// Domain Check Bulk: $0.002 per domain, $0.005 USDC minimum per call, always
+// paid (the free quota lives on domains-check). Checks up to 50 domains in
+// one RDAP sweep with bounded concurrency.
+
+import { readBody } from '../_lib/http.js';
+import { paidEndpoint } from '../_lib/x402-paid-endpoint.js';
+import { buildBazaarSchema } from '../_lib/x402-spec.js';
+import { installAccessControl } from '../_lib/x402/access-control.js';
+import { withService } from '../_lib/x402/bazaar-helpers.js';
+import { priceFor } from '../_lib/x402-prices.js';
+import { checkBulk } from '../_lib/x402-services/domains.js';
+import listing from '../_lib/service-catalog/services/domains-bulk.js';
+
+const ROUTE = '/api/x402/domains-bulk';
+const DESCRIPTION = listing.description;
+
+export const INPUT_SCHEMA = { $schema: 'https://json-schema.org/draft/2020-12/schema', ...listing.inputSchema };
+export const OUTPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ required: ['count', 'registered', 'available', 'unknown', 'results'],
+ properties: {
+ count: { type: 'integer' },
+ registered: { type: 'integer' },
+ available: { type: 'integer' },
+ unknown: { type: 'integer' },
+ results: { type: 'array' },
+ },
+};
+
+export const BAZAAR = {
+ description: DESCRIPTION,
+ useCases: ['domain portfolio audit', 'brand protection', 'bulk availability scan'],
+ input: { type: 'body', example: listing.input, schema: INPUT_SCHEMA },
+ output: { type: 'json', example: listing.outputExample },
+ schema: buildBazaarSchema({ method: 'POST', bodySchema: INPUT_SCHEMA, outputSchema: OUTPUT_SCHEMA }),
+};
+
+async function readJsonBody(req) {
+ const chunk = await readBody(req, 500_000);
+ return JSON.parse((chunk ? chunk.toString('utf8') : '') || '{}');
+}
+
+export default paidEndpoint({
+ route: ROUTE,
+ method: 'POST',
+ priceAtomics: priceFor('domains-bulk', '5000'), // $0.005 USDC
+ networks: ['solana', 'base'],
+ description: DESCRIPTION,
+ bazaar: BAZAAR,
+ service: withService({ serviceName: listing.serviceName, tags: listing.tags }),
+ accessControl: installAccessControl({ requiredScope: 'x402:bypass' }),
+ async handler({ req }) {
+ let body;
+ try {
+ body = await readJsonBody(req);
+ } catch {
+ const err = new Error('request body must be valid JSON');
+ err.status = 400;
+ err.code = 'invalid_json';
+ throw err;
+ }
+ const domains = body?.domains;
+ if (!Array.isArray(domains) || domains.length === 0) {
+ const err = new Error('body must be {"domains": ["example.com", ...]} with 1-50 entries');
+ err.status = 400;
+ err.code = 'invalid_domains';
+ throw err;
+ }
+ const results = await checkBulk(domains.map(String));
+ return {
+ count: results.length,
+ registered: results.filter((r) => r.status === 'registered').length,
+ available: results.filter((r) => r.status === 'available').length,
+ unknown: results.filter((r) => r.status === 'unknown').length,
+ results,
+ };
+ },
+});
diff --git a/api/x402/domains-check.js b/api/x402/domains-check.js
new file mode 100644
index 000000000..637fecb24
--- /dev/null
+++ b/api/x402/domains-check.js
@@ -0,0 +1,89 @@
+// GET /api/x402/domains-check?domain=example.com
+//
+// Domain Check: $0.001 USDC per call (free daily per-IP quota runs first).
+// Live RDAP lookup, resolved via the IANA bootstrap registry. No API key,
+// no WHOIS scraping.
+
+import { cors, method, error, json, wrap } from '../_lib/http.js';
+import { clientIp, limits } from '../_lib/rate-limit.js';
+import { paidEndpoint } from '../_lib/x402-paid-endpoint.js';
+import { buildBazaarSchema } from '../_lib/x402-spec.js';
+import { installAccessControl } from '../_lib/x402/access-control.js';
+import { withService } from '../_lib/x402/bazaar-helpers.js';
+import { priceFor } from '../_lib/x402-prices.js';
+import { checkDomain } from '../_lib/x402-services/domains.js';
+import listing from '../_lib/service-catalog/services/domains-check.js';
+
+const ROUTE = '/api/x402/domains-check';
+const DESCRIPTION = listing.description;
+
+export const INPUT_SCHEMA = { $schema: 'https://json-schema.org/draft/2020-12/schema', ...listing.inputSchema };
+export const OUTPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ required: ['domain', 'status', 'available'],
+ properties: {
+ domain: { type: 'string' },
+ status: { type: 'string', enum: ['registered', 'available', 'unknown'] },
+ available: { type: ['boolean', 'null'] },
+ registrar: { type: ['string', 'null'] },
+ registrarIanaId: { type: ['string', 'null'] },
+ createdAt: { type: ['string', 'null'] },
+ updatedAt: { type: ['string', 'null'] },
+ expiresAt: { type: ['string', 'null'] },
+ nameservers: { type: 'array', items: { type: 'string' } },
+ statusFlags: { type: 'array', items: { type: 'string' } },
+ dnssecSigned: { type: ['boolean', 'null'] },
+ rdapServer: { type: ['string', 'null'] },
+ tier: { type: 'string', enum: ['free', 'paid'] },
+ free_remaining_today: { type: 'integer' },
+ },
+};
+
+export const BAZAAR = {
+ description: DESCRIPTION,
+ useCases: ['domain availability', 'portfolio monitoring', 'brand protection'],
+ input: { type: 'query', example: listing.input, schema: INPUT_SCHEMA },
+ output: { type: 'json', example: listing.outputExample },
+ schema: buildBazaarSchema({ method: 'GET', queryParamsSchema: INPUT_SCHEMA, outputSchema: OUTPUT_SCHEMA }),
+};
+
+let _paid = null;
+function paidHandler() {
+ if (_paid) return _paid;
+ _paid = paidEndpoint({
+ route: ROUTE,
+ method: 'GET',
+ priceAtomics: priceFor('domains-check', '1000'), // $0.001 USDC
+ networks: ['solana', 'base'],
+ description: DESCRIPTION,
+ bazaar: BAZAAR,
+ service: withService({ serviceName: listing.serviceName, tags: listing.tags }),
+ accessControl: installAccessControl({ requiredScope: 'x402:bypass' }),
+ async handler({ req }) {
+ const params = new URL(req.url, 'http://x').searchParams;
+ const data = await checkDomain(params.get('domain'));
+ return { ...data, tier: 'paid' };
+ },
+ });
+ return _paid;
+}
+
+export default wrap(async function handler(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const paymentPresent = Boolean(req.headers['x-payment'] || req.headers['payment-signature']);
+ if (paymentPresent) return paidHandler()(req, res);
+
+ const rl = await limits.domainsFreeIp(clientIp(req));
+ if (!rl.success) return paidHandler()(req, res);
+
+ try {
+ const params = new URL(req.url, 'http://x').searchParams;
+ const data = await checkDomain(params.get('domain'));
+ return json(res, 200, { ...data, tier: 'free', free_remaining_today: Math.max(0, rl.remaining) }, { 'cache-control': 'no-store' });
+ } catch (e) {
+ return error(res, e.status || 502, e.code || 'provider_error', e.message);
+ }
+});