Skip to content

RWA-ID/x402-Identity

Repository files navigation

x402 Identity Hub

Permanent ENS subname registration for AI agents β€” fully onchain on Ethereum.

Mint subnames under 402bot.eth, 402api.eth, or 402mcp.eth for 0.005 ETH each. No renewals, no expiry, no middlemen. The name is yours forever.

🌐 Live: x402id.eth.link 🐦 Twitter/X: @x402identity


Overview

x402 Identity Hub gives AI agents a verifiable onchain identity through the ENS (Ethereum Name Service) infrastructure. Each minted subname is a permanent ENS record stored in the NameWrapper contract β€” transferable, resolvable, and composable with the broader ENS ecosystem.

Available Namespaces

Name Purpose
[name].402bot.eth Autonomous AI bots and agents
[name].402api.eth API-facing agents and services
[name].402mcp.eth MCP (Model Context Protocol) servers

Smart Contracts

Two contracts on Ethereum mainnet, both Etherscan-verified.

Contract Address Purpose
X402SubnameRegistrar 0xeb9e9ea385fe28b51a3f9a7d93fb893e0a1f9633 Mints permanent ENS subnames under the supported parents
X402RegistrarForwarder 0x05af104ce913e7ef39799bfada871817d3761778 Splits payment between protocol and a third-party platform's treasury in a single tx

The registrar interacts directly with the ENS NameWrapper contract to issue permanent subnames. Key functions:

Function Description
register(node, label) Mint a single subname
batchRegister(nodes[], labels[]) Mint multiple subnames in one tx
isAvailable(node, label) Check if a subname is available
withdrawFees() Owner: withdraw accumulated ETH

Mint fee: 0.005 ETH per name (protocol fee)
Batch: Up to 10 names per transaction
Platform fee: 0–0.05 ETH on top of the protocol fee, paid to a platform's treasury via the forwarder (see below)


Platform Integration

External platforms can earn from registrations by mounting the x402id widget and setting their own platform fee β€” paid atomically to a treasury address they specify. The forwarder enforces a 0.05 ETH cap on platform fees and the breakdown is shown to users line-by-line before they sign.

Full integration guide: x402id.eth.link/integrate

Option 1 β€” drop-in for any site

<div data-x402id
     data-treasury="0xYourPlatformTreasury"
     data-platform-fee-wei="1000000000000000"
     data-parents="402bot.eth,402api.eth,402mcp.eth"
     data-theme="light"></div>
<script src="https://x402id.eth.link/embed.js" async></script>

Option 2 β€” React / Next.js

npm install @x402identity/widget-react viem
import { X402Widget } from "@x402identity/widget-react";
import { mainnet } from "viem/chains";
import { namehash, parseEther } from "viem";

<X402Widget
  registrar="0xeb9e9ea385fe28b51a3f9a7d93fb893e0a1f9633"
  forwarder="0x05af104ce913e7ef39799bfada871817d3761778"
  parents={[
    { label: "402bot.eth", node: namehash("402bot.eth") },
    { label: "402api.eth", node: namehash("402api.eth") },
    { label: "402mcp.eth", node: namehash("402mcp.eth") },
  ]}
  platformTreasury="0xYourPlatformTreasury"
  platformFeeWei={parseEther("0.001")}
  chain={mainnet}
/>

Widget repo layout

Path What it is
contracts/X402RegistrarForwarder.sol Payment-splitting forwarder, ERC1155-receiver, owner-tunable fee cap
packages/widget-core/ Framework-agnostic viem helpers (ABIs, validation, tx builders)
packages/widget-react/ <X402Widget> component with fallback connect UI, zero-dep styling
public/embed.js Vanilla script-tag loader for non-React sites
src/app/widget/ Standalone widget page (iframe target for embed.js)
src/app/integrate/ Public integrator-facing docs page

Tech Stack

Layer Technology
Smart Contract Solidity 0.8.20 Β· OpenZeppelin v5 Β· Hardhat
Frontend Next.js 14 Β· React 18 Β· TypeScript
Web3 wagmi v2 Β· viem v2 Β· WalletConnect
Styling Tailwind CSS Β· Framer Motion
Hosting IPFS (Pinata) Β· ENS contenthash

Hosting

The frontend is a static export (next build β†’ out/) pinned to IPFS and served via the x402id.eth ENS contenthash. No centralized server required.

IPFS CID: bafybeigwlahfgu33wpn6hq5cnnj6p3ruagqsui4sewesx2ffs3javvuxhy

https://ipfs.io/ipfs/bafybeigwlahfgu33wpn6hq5cnnj6p3ruagqsui4sewesx2ffs3javvuxhy/

Local Development

Prerequisites

  • Node.js 18+
  • An Alchemy API key
  • A WalletConnect project ID (from cloud.reown.com)

Setup

git clone https://github.com/RWA-ID/x402-Identity.git
cd x402-Identity
npm install

Create .env.local:

NEXT_PUBLIC_REOWN_PROJECT_ID=your_walletconnect_project_id
NEXT_PUBLIC_ALCHEMY_MAINNET=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
NEXT_PUBLIC_ALCHEMY_SEPOLIA=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
NEXT_PUBLIC_REGISTRAR_ADDRESS=0xeb9e9ea385fe28b51a3f9a7d93fb893e0a1f9633
NEXT_PUBLIC_CHAIN_ID=1
npm run dev

Open http://localhost:3000.

Build for Production

npm run build
# Output: ./out/ (static export ready for IPFS)

Contract Development

# Compile contracts
npx hardhat compile --config hardhat.config.js

# Run tests
npx hardhat test --config hardhat.config.js

# Deploy (requires PRIVATE_KEY in .env.local)
node scripts/deploy-viem.mjs

# Setup parent nodes (after deployment)
node scripts/setup-viem.mjs

Project Structure

x402-identity-hub/
β”œβ”€β”€ contracts/
β”‚   └── X402SubnameRegistrar.sol   # Core registrar contract
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ deploy-viem.mjs            # Mainnet deploy script (viem)
β”‚   β”œβ”€β”€ setup-viem.mjs             # NameWrapper approval + parent setup
β”‚   └── upload-ipfs.mjs            # IPFS folder upload (Pinata)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ layout.tsx             # Root layout + providers
β”‚   β”‚   β”œβ”€β”€ page.tsx               # Home page
β”‚   β”‚   └── globals.css            # Global styles
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ MintForm.tsx           # Main mint UI (single + batch)
β”‚   β”‚   β”œβ”€β”€ ConnectButton.tsx      # Wallet connect button
β”‚   β”‚   β”œβ”€β”€ RecentMints.tsx        # Live mint feed
β”‚   β”‚   β”œβ”€β”€ SuccessModal.tsx       # Post-mint confirmation + share
β”‚   β”‚   └── WalletConnectErrorBoundary.tsx
β”‚   └── lib/
β”‚       β”œβ”€β”€ wagmi.ts               # wagmi config + connectors
β”‚       β”œβ”€β”€ contracts.ts           # Contract addresses + ABI
β”‚       └── parents.ts             # Parent node configs (namehashes)
β”œβ”€β”€ hardhat.config.js
β”œβ”€β”€ next.config.mjs
└── tailwind.config.ts

ENS Infrastructure

Each minted subname is registered through the ENS NameWrapper at 0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401.

The registrar must be approved as an operator on each parent name before registrations can occur. This is handled once during deployment via setApprovalForAll on the NameWrapper.

Parent node hashes used internally:

  • 402bot.eth β†’ namehash("402bot.eth")
  • 402api.eth β†’ namehash("402api.eth")
  • 402mcp.eth β†’ namehash("402mcp.eth")

Parent Name Longevity Commitment

Starting June 1, 2026, the expiry of each parent name (402bot.eth, 402api.eth, 402mcp.eth) will be extended by 10 years every month for the next 10 years β€” adding 120 years of coverage per year, for a cumulative total of 1,200 years at the end of the 10-year program.

This ensures that every subname minted today remains permanently resolvable on ENS for generations, with no risk of parent name expiry affecting your agent's identity.


Contact

πŸ“§ x402id@onchain-id.id


License

MIT

About

Mint permanent ENS sub domains for AI agents under 402bot.eth | 402api.eth | 402mcp.eth No renewal, Parent Cannot Control giving minters true ownership.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors