$npx -y skills add keep-starknet-strange/starknet-agentic --skill starknet-identityRegister AI agents on-chain using the ERC-8004 Trustless Agents standard. Manage agent identity as NFTs, build reputation through feedback, and request third-party validation.
| 1 | # Starknet Identity Skill |
| 2 | |
| 3 | Register and manage AI agent identities on Starknet using the ERC-8004 standard. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Registering agents on-chain, updating agent metadata, or managing reputation and validation flows. |
| 8 | - Building features that depend on ERC-8004 identity, feedback, or validator attestations. |
| 9 | |
| 10 | ## When NOT to Use |
| 11 | |
| 12 | - Simple wallet, payment, or DeFi flows that do not depend on ERC-8004 registries. |
| 13 | - Cairo contract authoring, deployment-only tasks, or security auditing. |
| 14 | |
| 15 | ## Quick Start |
| 16 | |
| 17 | 1. Install `starknet` and connect a funded account to the target ERC-8004 registry deployment. |
| 18 | 2. Use [skills catalog](../README.md) if the flow also needs wallet setup, deployment, or contract auditing. |
| 19 | |
| 20 | ## Overview |
| 21 | |
| 22 | ERC-8004 defines three interconnected on-chain registries for AI agents: |
| 23 | |
| 24 | 1. **Identity Registry** -- Agents as ERC-721 NFTs with metadata |
| 25 | 2. **Reputation Registry** -- Feedback system with cryptographic authorization |
| 26 | 3. **Validation Registry** -- Third-party assessments (zkML, TEE, staker) |
| 27 | |
| 28 | Reference implementation: [erc8004-cairo](https://github.com/Akashneelesh/erc8004-cairo) |
| 29 | |
| 30 | ## Prerequisites |
| 31 | |
| 32 | ```bash |
| 33 | npm install starknet |
| 34 | ``` |
| 35 | |
| 36 | ## Agent Registration |
| 37 | |
| 38 | ### Register a New Agent |
| 39 | |
| 40 | ```typescript |
| 41 | import { Account, RpcProvider, Contract, CallData } from "starknet"; |
| 42 | |
| 43 | const provider = new RpcProvider({ nodeUrl: process.env.STARKNET_RPC_URL }); |
| 44 | const account = new Account({ provider, address, signer: privateKey }); |
| 45 | |
| 46 | const identityRegistry = new Contract({ |
| 47 | abi: identityRegistryAbi, |
| 48 | address: registryAddress, |
| 49 | providerOrAccount: account, |
| 50 | }); |
| 51 | |
| 52 | // Register with metadata |
| 53 | const metadata = [ |
| 54 | { key: "agentName", value: "MyTradingAgent" }, |
| 55 | { key: "agentType", value: "defi-trader" }, |
| 56 | { key: "version", value: "1.0.0" }, |
| 57 | { key: "model", value: "claude-opus-4-5" }, |
| 58 | { key: "status", value: "active" }, |
| 59 | ]; |
| 60 | |
| 61 | const tokenUri = "ipfs://QmYourAgentSpecHash"; // IPFS link to full agent spec |
| 62 | |
| 63 | const { transaction_hash } = await account.execute({ |
| 64 | contractAddress: registryAddress, |
| 65 | entrypoint: "register_with_metadata", |
| 66 | calldata: CallData.compile({ |
| 67 | token_uri: tokenUri, |
| 68 | metadata: metadata, |
| 69 | }), |
| 70 | }); |
| 71 | |
| 72 | const receipt = await account.waitForTransaction(transaction_hash); |
| 73 | // Parse agent_id from events |
| 74 | ``` |
| 75 | |
| 76 | ### Query Agent Information |
| 77 | |
| 78 | ```typescript |
| 79 | // Check if agent exists |
| 80 | const exists = await identityRegistry.agent_exists(agentId); |
| 81 | |
| 82 | // Get total registered agents |
| 83 | const totalAgents = await identityRegistry.total_agents(); |
| 84 | |
| 85 | // Get agent metadata |
| 86 | const name = await identityRegistry.get_metadata(agentId, "agentName"); |
| 87 | const agentType = await identityRegistry.get_metadata(agentId, "agentType"); |
| 88 | |
| 89 | // Get agent owner (ERC-721) |
| 90 | const owner = await identityRegistry.owner_of(agentId); |
| 91 | ``` |
| 92 | |
| 93 | ### Update Agent Metadata |
| 94 | |
| 95 | ```typescript |
| 96 | // Only the agent owner can update metadata |
| 97 | await account.execute({ |
| 98 | contractAddress: registryAddress, |
| 99 | entrypoint: "set_metadata", |
| 100 | calldata: CallData.compile({ |
| 101 | agent_id: agentId, |
| 102 | key: "status", |
| 103 | value: "upgraded", |
| 104 | }), |
| 105 | }); |
| 106 | ``` |
| 107 | |
| 108 | ## Reputation System |
| 109 | |
| 110 | ### Authorize and Submit Feedback |
| 111 | |
| 112 | The reputation system uses a cryptographic authorization flow: |
| 113 | |
| 114 | 1. **Agent owner** creates a FeedbackAuth struct and signs it |
| 115 | 2. **Client** submits feedback with the authorization |
| 116 | |
| 117 | ```typescript |
| 118 | // Step 1: Agent owner creates authorization |
| 119 | const feedbackAuth = { |
| 120 | agent_id: agentId, |
| 121 | client_address: clientAddress, |
| 122 | index_limit: 10, // Max feedback entries allowed |
| 123 | expiry: Math.floor(Date.now() / 1000) + 3600, // 1 hour |
| 124 | chain_id: chainId, |
| 125 | identity_registry: registryAddress, |
| 126 | signer_address: ownerAddress, |
| 127 | }; |
| 128 | |
| 129 | // Sign the authorization (using agent owner's account) |
| 130 | const messageHash = computePoseidonHash(feedbackAuth); // EIP-712 style |
| 131 | const signature = await ownerAccount.signMessage(messageHash); |
| 132 | |
| 133 | // Step 2: Client submits feedback |
| 134 | await clientAccount.execute({ |
| 135 | contractAddress: reputationRegistryAddress, |
| 136 | entrypoint: "give_feedback", |
| 137 | calldata: CallData.compile({ |
| 138 | agent_id: agentId, |
| 139 | score: 85, // 0-100 |
| 140 | tag1: encodedTag("reliability"), |
| 141 | tag2: encodedTag("speed"), |
| 142 | fileuri: "", |
| 143 | filehash: 0, |
| 144 | feedback_auth: feedbackAuth, |
| 145 | signature: signature, |
| 146 | }), |
| 147 | }); |
| 148 | ``` |
| 149 | |
| 150 | ### Query Reputation |
| 151 | |
| 152 | ```typescript |
| 153 | const reputationRegistry = new Contract({ |
| 154 | abi: reputationAbi, |
| 155 | address: reputationAddress, |
| 156 | providerOrAccount: provider, |
| 157 | }); |
| 158 | |
| 159 | // Get summary for an agent (count + average score) |
| 160 | const [count, avgScore] = await reputationRegistry.get_summa |