/** * ROB Domains — Cursor MCP / Tool Integration Example * * This file shows how to call ROB Domains API endpoints directly from * Cursor's AI context or from any script running in a Cursor project. * Copy the helper functions below into your project, then call them * from Cursor chat or your own code. * * No SDK required — uses native fetch. * Base URL: https://robdn.com */ const BASE_URL = 'https://robdn.com'; // ─── Read Operations ────────────────────────────────────────────────────────── /** Search for a .rob domain. Returns availability, owner, and profile. */ export async function searchDomain(domain: string) { const res = await fetch(`${BASE_URL}/agent/search/${encodeURIComponent(domain)}`); return res.json(); } /** Get the full on-chain profile for a .rob domain. */ export async function getProfile(domain: string) { const res = await fetch(`${BASE_URL}/agent/profile/${encodeURIComponent(domain)}`); return res.json(); } /** Reverse-resolve a wallet address to its primary .rob domain. */ export async function reverseResolve(wallet: string) { const res = await fetch(`${BASE_URL}/agent/reverse/${encodeURIComponent(wallet)}`); return res.json(); } /** Get the primary .rob domain for a wallet. */ export async function getPrimaryDomain(wallet: string) { const res = await fetch(`${BASE_URL}/agent/primary/${encodeURIComponent(wallet)}`); return res.json(); } // ─── Transaction Builders ───────────────────────────────────────────────────── /** Generate an unsigned mint transaction payload. Wallet signs + broadcasts. */ export async function buildMintTx(domain: string) { const res = await fetch(`${BASE_URL}/agent/tx/mint`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain }), }); return res.json(); } /** Generate an unsigned set-primary-domain transaction payload. */ export async function buildSetPrimaryTx(tokenId: string, wallet: string) { const res = await fetch(`${BASE_URL}/agent/tx/set-primary`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tokenId, wallet }), }); return res.json(); } /** Generate unsigned update-profile transaction payload(s). */ export async function buildUpdateProfileTx(params: { tokenId: string; bio?: string; profilePicture?: string; coverImage?: string; background?: string; socialLinks?: { platform: string; url: string }[]; customLinks?: { title: string; url: string }[]; }) { const res = await fetch(`${BASE_URL}/agent/tx/update-profile`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); return res.json(); } // ─── Workflow ───────────────────────────────────────────────────────────────── /** Get a full multi-step execution plan for registering a .rob domain. */ export async function registerDomainPlan(params: { domain: string; wallet: string; setPrimary?: boolean; profile?: { bio?: string; profilePicture?: string; coverImage?: string; background?: string; socialLinks?: { platform: string; url: string }[]; customLinks?: { title: string; url: string }[]; }; }) { const res = await fetch(`${BASE_URL}/agent/workflow/register-domain`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); return res.json(); } // ─── Demo ───────────────────────────────────────────────────────────────────── async function main() { // Search const search = await searchDomain('alice'); console.log('Search result:', JSON.stringify(search, null, 2)); // Mint transaction const mintTx = await buildMintTx('alice'); console.log('\nMint transaction:', JSON.stringify(mintTx, null, 2)); // Full registration plan const plan = await registerDomainPlan({ domain: 'alice', wallet: '0xAbCd1234567890AbCd1234567890AbCd12345678', setPrimary: true, profile: { bio: 'Web3 builder', socialLinks: [{ platform: 'twitter', url: 'https://twitter.com/alice' }], }, }); console.log('\nExecution plan:', JSON.stringify(plan, null, 2)); } main().catch(console.error);