Hands-on examples for building with Agentic ID (ERC-7857 Intelligent NFTs) on the 0G Chain.
Agentic ID is an on-chain identity standard for AI agents. It extends ERC-721 with encrypted intelligent data -model weights, prompts, configurations -that can be securely transferred, cloned, and authorized using cryptographic proofs (TEE/ZKP). This repo provides three progressive examples that walk through the core capabilities.
Each example is fully self-contained with its own contracts, dependencies, and configuration.
Reference implementation: 0gfoundation/0g-agent-nft
examples/01-mint-and-manage/
A Next.js web application with RainbowKit wallet connection for registering and managing AI agent identities on-chain.
Stack: Next.js, RainbowKit, wagmi, viem, Tailwind CSS, Hardhat
Features:
- Register AI Agents - structured form with agent name, model selection, capabilities (multi-select), and system prompt. All fields are hashed on-chain as ERC-7857 intelligent data entries
- Agent Profile Cards - display registered agents with model badges, capability tags, owner/creator addresses, and on-chain data verification
- Authorization Management - grant and revoke usage rights to other addresses using the ERC-7857
authorizeUsage/revokeAuthorizationfunctions. Supports multiple authorized users per agent - Auto-load Owned Agents - fetches your agents from the contract on page load using ERC-721 Enumerable (
balanceOf+tokenOfOwnerByIndex) - Authorized to Me - see agents that other owners have authorized you to use via the
authorizedTokensOfreverse lookup - Transfer Ownership - transfer agents to other addresses directly from the UI
- On-chain Verification - expand the verification section on any agent card to see intelligent data hashes with click-to-copy
- Contract Address Display - header shows the deployed contract address linked to the 0G block explorer
Deployed Contract:
| Network | Address | Explorer |
|---|---|---|
| 0G Galileo Testnet | 0x2700F6A3e505402C9daB154C5c6ab9cAEC98EF1F |
View on Explorer |
cd examples/01-mint-and-manage
npm install
npm run dev
# Open http://localhost:3000The app points to the pre-deployed contract on 0G Galileo Testnet by default. Get a WalletConnect project ID at https://cloud.walletconnect.com and set
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID.
To deploy your own instance:
# Set PRIVATE_KEY in .env
npm run deploy:testnetexamples/02-authorization-and-delegation/
Demonstrates how an agent owner controls who can use their agents without transferring ownership:
- Mint three specialized agents (coding, research, writing) with intelligent data
- Grant a platform usage rights (
authorizeUsage) - Authorize multiple users for the same agent
- Query authorization state (
authorizedUsersOf,isAuthorizedUser) - Batch-authorize a service across all agents (
batchAuthorizeUsage) - Delegate signing to a hot wallet (
delegateAccess) - Clone an agent - shows authorizations are not inherited
- Transfer an agent - shows authorizations are cleared for security
- Revoke individual authorizations (
revokeAuthorization)
cd examples/02-authorization-and-delegation
npm install
npm startexamples/03-marketplace-trading/
End-to-end marketplace trading with EIP-712 signed orders and fee distribution:
- Deploy both AgenticID and AgenticIDMarket contracts
- Mint agent NFTs with capability metadata
- Configure partner/creator royalty rates (basis points)
- Deposit funds into marketplace escrow
- Create gasless EIP-712 signed sell orders and buy offers
- Execute atomic trades via
fulfillOrder - Verify ownership transfer, balance changes, and fee splits
- Withdraw seller proceeds from escrow
- Execute a second trade with nonce management
- Withdraw accumulated partner fees
cd examples/03-marketplace-trading
npm install
npm startexamples/
01-mint-and-manage/ # Beginner - Full-stack Next.js app
contracts/ # AgenticID.sol + interfaces
scripts/deploy.ts # Deploy to 0G testnet
src/ # Next.js app source
hardhat.config.ts
package.json
02-authorization-and-delegation/ # Intermediate - CLI script
contracts/ # AgenticID.sol + interfaces
scripts/index.ts # Example script
shared/config.ts # Logging helpers
hardhat.config.ts
package.json
03-marketplace-trading/ # Advanced - CLI script
contracts/ # AgenticID.sol + AgenticIDMarket.sol + interfaces
scripts/index.ts # Example script
shared/config.ts # Logging helpers
hardhat.config.ts
package.json
| Concept | Description |
|---|---|
| Intelligent Data | Encrypted metadata (model hashes, prompts, configs) attached to each NFT via ERC-7857 |
| iTransferFrom | Privacy-preserving transfer that re-encrypts data for the new owner, verified by TEE/ZKP oracle |
| iCloneFrom | Duplicates an agent's intelligent data to a new token without transferring the original |
| authorizeUsage | Grants per-token execution rights to other addresses (max 100 per token) |
| authorizedTokensOf | Reverse lookup - query which tokens a given address is authorized to use |
| delegateAccess | Registers an assistant/hot wallet to sign on the owner's behalf |
| EIP-712 Orders | Gasless, human-readable signed orders enabling off-chain listings and offers |
| Partner Fees | Configurable creator royalties distributed automatically on each marketplace trade |
- The contracts in this repo are simplified for demonstration. In production, use the full 0g-agent-nft contracts with TEE/ZKP proof verification.
- Transfer validity proofs in the examples use placeholder values. In production, these are generated by 0G's TEE infrastructure.
- The marketplace uses
address(0)to represent native token payments.