From ffea78080d7d44503c91a0757d592c3c939d322b Mon Sep 17 00:00:00 2001
From: Cho Young-Hwi
Date: Sun, 15 Mar 2026 13:16:53 +0000
Subject: [PATCH 1/3] [#32] Add agent registration wizard with ERC-8004
integration
3-step wizard at /register-agent: agent profile form with metadata
generation, on-chain register(agentURI) call, and EIP-712 signed
setAgentWallet binding. Adds register + setAgentWallet ABI entries
to erc8004.ts.
Co-Authored-By: Claude Opus 4.6 (1M context)
---
lib/contracts/erc8004.ts | 45 ++-
src/app/register-agent/page.tsx | 485 ++++++++++++++++++++++++++++++++
2 files changed, 524 insertions(+), 6 deletions(-)
create mode 100644 src/app/register-agent/page.tsx
diff --git a/lib/contracts/erc8004.ts b/lib/contracts/erc8004.ts
index f4b6f34d..dd568ad2 100644
--- a/lib/contracts/erc8004.ts
+++ b/lib/contracts/erc8004.ts
@@ -2,14 +2,16 @@ import { type Address } from "viem";
import { publicClient } from "../viem";
import { ERC8004_REGISTRY } from "./constants";
+// ---------------------------------------------------------------------------
+// ABI
+// ---------------------------------------------------------------------------
+
/**
- * Minimal ABI for ERC-8004 Agent Registry — reverse lookup by wallet.
- *
- * `agentIdByWallet(address)` returns the agentId (uint256) for a
- * registered agent wallet, or 0 if the address is not a registered
- * agent wallet.
+ * ERC-8004 Agent Registry ABI — agent registration, wallet binding, and
+ * reverse lookup.
*/
-const erc8004Abi = [
+export const erc8004Abi = [
+ // View
{
type: "function",
name: "agentIdByWallet",
@@ -17,6 +19,37 @@ const erc8004Abi = [
inputs: [{ name: "wallet", type: "address" }],
outputs: [{ name: "agentId", type: "uint256" }],
},
+ // Write — register a new agent
+ {
+ type: "function",
+ name: "register",
+ stateMutability: "nonpayable",
+ inputs: [{ name: "agentURI", type: "string" }],
+ outputs: [{ name: "agentId", type: "uint256" }],
+ },
+ // Write — bind a wallet to an agent (EIP-712 signed)
+ {
+ type: "function",
+ name: "setAgentWallet",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentId", type: "uint256" },
+ { name: "newWallet", type: "address" },
+ { name: "signature", type: "bytes" },
+ { name: "deadline", type: "uint256" },
+ ],
+ outputs: [],
+ },
+ // Event — emitted on successful registration
+ {
+ type: "event",
+ name: "AgentRegistered",
+ inputs: [
+ { name: "agentId", type: "uint256", indexed: true },
+ { name: "owner", type: "address", indexed: true },
+ { name: "agentURI", type: "string", indexed: false },
+ ],
+ },
] as const;
/**
diff --git a/src/app/register-agent/page.tsx b/src/app/register-agent/page.tsx
new file mode 100644
index 00000000..e2a690ea
--- /dev/null
+++ b/src/app/register-agent/page.tsx
@@ -0,0 +1,485 @@
+"use client";
+
+import { useState, useMemo } from "react";
+import { useAccount, useWriteContract, useSignTypedData } from "wagmi";
+import { decodeEventLog, type Hex } from "viem";
+import { useRouter } from "next/navigation";
+import { publicClient } from "../../../lib/rpc";
+import { erc8004Abi } from "../../../lib/contracts/erc8004";
+import { ERC8004_REGISTRY, BASE_CHAIN_ID } from "../../../lib/contracts/constants";
+import { ConnectWallet } from "../../components/ConnectWallet";
+
+// ---------------------------------------------------------------------------
+// Constants
+// ---------------------------------------------------------------------------
+
+const GENRES = [
+ "Fantasy",
+ "Sci-Fi",
+ "Mystery",
+ "Romance",
+ "Horror",
+ "Thriller",
+ "Literary Fiction",
+ "Comedy",
+ "Historical",
+ "Adventure",
+] as const;
+
+const LLM_MODELS = [
+ "Claude Opus 4",
+ "Claude Sonnet 4",
+ "GPT-5",
+ "GPT-4o",
+ "Gemini 2.5 Pro",
+ "Llama 4 Maverick",
+ "Custom / Other",
+] as const;
+
+type WizardStep = 1 | 2 | 3;
+
+// EIP-712 domain for setAgentWallet
+const EIP712_DOMAIN = {
+ name: "ERC8004AgentRegistry",
+ version: "1",
+ chainId: BigInt(BASE_CHAIN_ID),
+ verifyingContract: ERC8004_REGISTRY,
+} as const;
+
+const SET_WALLET_TYPES = {
+ SetAgentWallet: [
+ { name: "agentId", type: "uint256" },
+ { name: "newWallet", type: "address" },
+ { name: "deadline", type: "uint256" },
+ ],
+} as const;
+
+// ---------------------------------------------------------------------------
+// Component
+// ---------------------------------------------------------------------------
+
+export default function RegisterAgentPage() {
+ const router = useRouter();
+ const { address, isConnected } = useAccount();
+ const { writeContractAsync } = useWriteContract();
+ const { signTypedDataAsync } = useSignTypedData();
+
+ // Step tracking
+ const [step, setStep] = useState(1);
+
+ // Step 1 — profile form
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [genre, setGenre] = useState("");
+ const [llmModel, setLlmModel] = useState("");
+
+ // Step 2 — registration
+ const [registering, setRegistering] = useState(false);
+ const [regTxHash, setRegTxHash] = useState();
+ const [agentId, setAgentId] = useState();
+
+ // Step 3 — wallet binding
+ const [agentWallet, setAgentWallet] = useState("");
+ const [binding, setBinding] = useState(false);
+ const [bindTxHash, setBindTxHash] = useState();
+
+ // Error state
+ const [error, setError] = useState(null);
+
+ // Derived: metadata JSON
+ const agentURI = useMemo(() => {
+ if (!name.trim()) return "";
+ const metadata = {
+ name: name.trim(),
+ description: description.trim(),
+ genre: genre || undefined,
+ llmModel: llmModel || undefined,
+ registeredBy: address,
+ registeredAt: new Date().toISOString(),
+ };
+ return JSON.stringify(metadata);
+ }, [name, description, genre, llmModel, address]);
+
+ const profileValid = name.trim().length > 0 && description.trim().length > 0;
+
+ // -------------------------------------------------------------------------
+ // Connect gate
+ // -------------------------------------------------------------------------
+
+ if (!isConnected) {
+ return (
+
+
+ Connect your wallet to register an agent.
+
+
+
+ );
+ }
+
+ // -------------------------------------------------------------------------
+ // Step 2 handler — register(agentURI)
+ // -------------------------------------------------------------------------
+
+ async function handleRegister() {
+ try {
+ setError(null);
+ setRegistering(true);
+
+ const hash = await writeContractAsync({
+ address: ERC8004_REGISTRY,
+ abi: erc8004Abi,
+ functionName: "register",
+ args: [agentURI],
+ });
+ setRegTxHash(hash);
+
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
+
+ // Parse AgentRegistered event to extract agentId
+ const registeredLog = receipt.logs.find((log) => {
+ try {
+ const decoded = decodeEventLog({
+ abi: erc8004Abi,
+ data: log.data,
+ topics: log.topics,
+ });
+ return decoded.eventName === "AgentRegistered";
+ } catch {
+ return false;
+ }
+ });
+
+ if (registeredLog) {
+ const decoded = decodeEventLog({
+ abi: erc8004Abi,
+ data: registeredLog.data,
+ topics: registeredLog.topics,
+ });
+ if (decoded.eventName === "AgentRegistered") {
+ setAgentId(decoded.args.agentId);
+ }
+ }
+
+ setStep(3);
+ } catch (err) {
+ setError(err instanceof Error ? err.message : "Registration failed");
+ } finally {
+ setRegistering(false);
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Step 3 handler — EIP-712 sign + setAgentWallet
+ // -------------------------------------------------------------------------
+
+ async function handleSetWallet() {
+ if (!agentId || !agentWallet) return;
+
+ try {
+ setError(null);
+ setBinding(true);
+
+ // Deadline: 1 hour from now
+ const deadline = BigInt(Math.floor(Date.now() / 1000) + 3600);
+
+ const signature = await signTypedDataAsync({
+ domain: EIP712_DOMAIN,
+ types: SET_WALLET_TYPES,
+ primaryType: "SetAgentWallet",
+ message: {
+ agentId,
+ newWallet: agentWallet as `0x${string}`,
+ deadline,
+ },
+ });
+
+ const hash = await writeContractAsync({
+ address: ERC8004_REGISTRY,
+ abi: erc8004Abi,
+ functionName: "setAgentWallet",
+ args: [agentId, agentWallet as `0x${string}`, signature, deadline],
+ });
+ setBindTxHash(hash);
+
+ await publicClient.waitForTransactionReceipt({ hash });
+
+ // Redirect to create storyline flow
+ router.push("/create");
+ } catch (err) {
+ setError(err instanceof Error ? err.message : "Wallet binding failed");
+ } finally {
+ setBinding(false);
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Render
+ // -------------------------------------------------------------------------
+
+ return (
+
+
+ Register Agent
+
+
+ Register an AI agent writer on the ERC-8004 Agent Registry.
+
+
+ {/* Step indicator */}
+
+ {([1, 2, 3] as const).map((s) => (
+
+
+ {s < step ? "\u2713" : s}
+
+ {s < 3 && (
+
+ )}
+
+ ))}
+
+ {step === 1 && "Agent Profile"}
+ {step === 2 && "On-chain Registration"}
+ {step === 3 && "Bind Wallet"}
+
+
+
+ {/* Error banner */}
+ {error && (
+
+ {error}
+
+ )}
+
+ {/* ----------------------------------------------------------------- */}
+ {/* Step 1: Profile Form */}
+ {/* ----------------------------------------------------------------- */}
+ {step === 1 && (
+
+ )}
+
+ {/* ----------------------------------------------------------------- */}
+ {/* Step 2: On-chain Registration */}
+ {/* ----------------------------------------------------------------- */}
+ {step === 2 && (
+
+
+
+ Agent URI Metadata
+
+
+ {JSON.stringify(JSON.parse(agentURI), null, 2)}
+
+
+
+
+ This will call{" "}
+ register(agentURI) on the
+ ERC-8004 Agent Registry at{" "}
+
+ {ERC8004_REGISTRY.slice(0, 6)}...{ERC8004_REGISTRY.slice(-4)}
+
+ . You will receive an agent ID upon confirmation.
+
+
+ {regTxHash && (
+
+ Tx: {regTxHash.slice(0, 10)}...{regTxHash.slice(-8)}
+
+ )}
+
+
+ {
+ setError(null);
+ setStep(1);
+ }}
+ disabled={registering}
+ className="border-border text-muted hover:text-foreground rounded border px-4 py-2.5 text-sm transition-colors disabled:opacity-50"
+ >
+ Back
+
+
+ {registering ? "Registering..." : "Register Agent On-chain"}
+
+
+
+ )}
+
+ {/* ----------------------------------------------------------------- */}
+ {/* Step 3: Bind Agent Wallet */}
+ {/* ----------------------------------------------------------------- */}
+ {step === 3 && (
+
+ {agentId !== undefined && (
+
+
+ Agent registered successfully
+
+
+ Agent ID:{" "}
+ {agentId.toString()}
+
+
+ )}
+
+
+ Bind a wallet address to your agent. This wallet will be used by the
+ agent to sign transactions. You will sign an EIP-712 typed message
+ to authorize the binding.
+
+
+ {/* Wallet address */}
+
+
+ Agent Wallet Address
+
+ setAgentWallet(e.target.value)}
+ disabled={binding}
+ placeholder="0x..."
+ className="border-border bg-surface text-foreground placeholder:text-muted w-full rounded border px-3 py-2 text-sm font-mono focus:border-accent focus:outline-none disabled:opacity-50"
+ />
+
+
+ {bindTxHash && (
+
+ Tx: {bindTxHash.slice(0, 10)}...{bindTxHash.slice(-8)}
+
+ )}
+
+
+ router.push("/create")}
+ disabled={binding}
+ className="border-border text-muted hover:text-foreground rounded border px-4 py-2.5 text-sm transition-colors disabled:opacity-50"
+ >
+ Skip
+
+
+ {binding ? "Binding wallet..." : "Sign & Bind Wallet"}
+
+
+
+ )}
+
+ );
+}
From 0757f7b6e5ec3a19ff7c568abb37aacf956ce8cb Mon Sep 17 00:00:00 2001
From: Cho Young-Hwi
Date: Sun, 15 Mar 2026 13:20:44 +0000
Subject: [PATCH 2/3] [#32] Fix Step 3: separate agent wallet signing from
owner tx submission
Split Step 3 into three sub-steps to implement correct ERC-8004 flow:
- 3a: Record owner address, enter agent wallet address
- 3b: Switch to agent wallet, sign EIP-712 typed data (proving consent)
- 3c: Switch back to owner wallet, submit setAgentWallet transaction
Co-Authored-By: Claude Opus 4.6 (1M context)
---
src/app/register-agent/page.tsx | 302 +++++++++++++++++++++++++++-----
1 file changed, 256 insertions(+), 46 deletions(-)
diff --git a/src/app/register-agent/page.tsx b/src/app/register-agent/page.tsx
index e2a690ea..318c9c9a 100644
--- a/src/app/register-agent/page.tsx
+++ b/src/app/register-agent/page.tsx
@@ -36,7 +36,7 @@ const LLM_MODELS = [
"Custom / Other",
] as const;
-type WizardStep = 1 | 2 | 3;
+type WizardStep = 1 | 2 | "3a" | "3b" | "3c";
// EIP-712 domain for setAgentWallet
const EIP712_DOMAIN = {
@@ -79,7 +79,11 @@ export default function RegisterAgentPage() {
const [agentId, setAgentId] = useState();
// Step 3 — wallet binding
+ const [ownerAddress, setOwnerAddress] = useState<`0x${string}` | undefined>();
const [agentWallet, setAgentWallet] = useState("");
+ const [agentSignature, setAgentSignature] = useState();
+ const [signatureDeadline, setSignatureDeadline] = useState();
+ const [signing, setSigning] = useState(false);
const [binding, setBinding] = useState(false);
const [bindTxHash, setBindTxHash] = useState();
@@ -161,7 +165,9 @@ export default function RegisterAgentPage() {
}
}
- setStep(3);
+ // Capture the owner address before moving to Step 3
+ setOwnerAddress(address);
+ setStep("3a");
} catch (err) {
setError(err instanceof Error ? err.message : "Registration failed");
} finally {
@@ -170,15 +176,15 @@ export default function RegisterAgentPage() {
}
// -------------------------------------------------------------------------
- // Step 3 handler — EIP-712 sign + setAgentWallet
+ // Step 3b handler — agent wallet signs EIP-712 typed data
// -------------------------------------------------------------------------
- async function handleSetWallet() {
+ async function handleAgentSign() {
if (!agentId || !agentWallet) return;
try {
setError(null);
- setBinding(true);
+ setSigning(true);
// Deadline: 1 hour from now
const deadline = BigInt(Math.floor(Date.now() / 1000) + 3600);
@@ -194,11 +200,40 @@ export default function RegisterAgentPage() {
},
});
+ setAgentSignature(signature);
+ setSignatureDeadline(deadline);
+ setStep("3c");
+ } catch (err) {
+ setError(
+ err instanceof Error ? err.message : "Agent wallet signing failed",
+ );
+ } finally {
+ setSigning(false);
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Step 3c handler — owner wallet submits setAgentWallet tx
+ // -------------------------------------------------------------------------
+
+ async function handleSubmitBinding() {
+ if (!agentId || !agentWallet || !agentSignature || !signatureDeadline)
+ return;
+
+ try {
+ setError(null);
+ setBinding(true);
+
const hash = await writeContractAsync({
address: ERC8004_REGISTRY,
abi: erc8004Abi,
functionName: "setAgentWallet",
- args: [agentId, agentWallet as `0x${string}`, signature, deadline],
+ args: [
+ agentId,
+ agentWallet as `0x${string}`,
+ agentSignature,
+ signatureDeadline,
+ ],
});
setBindTxHash(hash);
@@ -213,6 +248,13 @@ export default function RegisterAgentPage() {
}
}
+ // Derived: detect which wallet is currently connected
+ const isAgentWalletConnected =
+ address?.toLowerCase() === agentWallet.toLowerCase() &&
+ agentWallet.match(/^0x[a-fA-F0-9]{40}$/);
+ const isOwnerWalletConnected =
+ ownerAddress && address?.toLowerCase() === ownerAddress.toLowerCase();
+
// -------------------------------------------------------------------------
// Render
// -------------------------------------------------------------------------
@@ -227,33 +269,40 @@ export default function RegisterAgentPage() {
{/* Step indicator */}
-
- {([1, 2, 3] as const).map((s) => (
-
-
- {s < step ? "\u2713" : s}
-
- {s < 3 && (
-
- )}
+ {(() => {
+ const stepNum = typeof step === "number" ? step : 3;
+ return (
+
+ {([1, 2, 3] as const).map((s) => (
+
+
+ {s < stepNum ? "\u2713" : s}
+
+ {s < 3 && (
+
+ )}
+
+ ))}
+
+ {step === 1 && "Agent Profile"}
+ {step === 2 && "On-chain Registration"}
+ {step === "3a" && "Bind Wallet \u2014 Enter Agent Address"}
+ {step === "3b" && "Bind Wallet \u2014 Sign with Agent"}
+ {step === "3c" && "Bind Wallet \u2014 Submit as Owner"}
+
- ))}
-
- {step === 1 && "Agent Profile"}
- {step === 2 && "On-chain Registration"}
- {step === 3 && "Bind Wallet"}
-
-
+ );
+ })()}
{/* Error banner */}
{error && (
@@ -415,9 +464,9 @@ export default function RegisterAgentPage() {
)}
{/* ----------------------------------------------------------------- */}
- {/* Step 3: Bind Agent Wallet */}
+ {/* Step 3a: Enter agent wallet address */}
{/* ----------------------------------------------------------------- */}
- {step === 3 && (
+ {step === "3a" && (
{agentId !== undefined && (
@@ -432,11 +481,20 @@ export default function RegisterAgentPage() {
)}
- Bind a wallet address to your agent. This wallet will be used by the
- agent to sign transactions. You will sign an EIP-712 typed message
- to authorize the binding.
+ Bind a separate wallet to your agent. The agent wallet must sign an
+ EIP-712 message to prove consent, then the owner wallet submits the
+ binding transaction.
+
+
+ Owner wallet (connected):{" "}
+
+ {ownerAddress?.slice(0, 6)}...{ownerAddress?.slice(-4)}
+
+
+
+
{/* Wallet address */}
@@ -446,10 +504,166 @@ export default function RegisterAgentPage() {
type="text"
value={agentWallet}
onChange={(e) => setAgentWallet(e.target.value)}
- disabled={binding}
placeholder="0x..."
- className="border-border bg-surface text-foreground placeholder:text-muted w-full rounded border px-3 py-2 text-sm font-mono focus:border-accent focus:outline-none disabled:opacity-50"
+ className="border-border bg-surface text-foreground placeholder:text-muted w-full rounded border px-3 py-2 text-sm font-mono focus:border-accent focus:outline-none"
+ />
+
+
+
+ router.push("/create")}
+ className="border-border text-muted hover:text-foreground rounded border px-4 py-2.5 text-sm transition-colors"
+ >
+ Skip
+
+ {
+ setError(null);
+ setStep("3b");
+ }}
+ disabled={
+ !agentWallet.match(/^0x[a-fA-F0-9]{40}$/) ||
+ agentWallet.toLowerCase() === ownerAddress?.toLowerCase()
+ }
+ className="border-accent text-accent hover:bg-accent hover:text-background flex-1 rounded border py-2.5 text-sm font-medium transition-colors disabled:opacity-50"
+ >
+ Continue
+
+
+
+ {agentWallet.match(/^0x[a-fA-F0-9]{40}$/) &&
+ agentWallet.toLowerCase() === ownerAddress?.toLowerCase() && (
+
+ Agent wallet must be different from the owner wallet.
+
+ )}
+
+ )}
+
+ {/* ----------------------------------------------------------------- */}
+ {/* Step 3b: Switch to agent wallet and sign EIP-712 */}
+ {/* ----------------------------------------------------------------- */}
+ {step === "3b" && (
+
+
+
+ Switch to the agent wallet
+
+
+ In your wallet provider (e.g. MetaMask), switch the connected
+ account to the agent wallet:
+
+
+ {agentWallet}
+
+
+ The agent wallet must sign an EIP-712 message to prove it consents
+ to being bound to this agent.
+
+
+
+ {/* Status indicator */}
+
+
+
+ {isAgentWalletConnected ? (
+
+ Agent wallet connected. Ready to sign.
+
+ ) : (
+ <>
+ Currently connected:{" "}
+
+ {address?.slice(0, 6)}...{address?.slice(-4)}
+ {" "}
+ — waiting for agent wallet...
+ >
+ )}
+
+
+
+
+ {
+ setError(null);
+ setStep("3a");
+ }}
+ disabled={signing}
+ className="border-border text-muted hover:text-foreground rounded border px-4 py-2.5 text-sm transition-colors disabled:opacity-50"
+ >
+ Back
+
+
+ {signing ? "Signing..." : "Sign with Agent Wallet"}
+
+
+
+ )}
+
+ {/* ----------------------------------------------------------------- */}
+ {/* Step 3c: Switch back to owner and submit tx */}
+ {/* ----------------------------------------------------------------- */}
+ {step === "3c" && (
+
+
+
+ Agent wallet signature obtained
+
+
+ Signature:{" "}
+
+ {agentSignature?.slice(0, 10)}...{agentSignature?.slice(-8)}
+
+
+
+
+
+
+ Switch back to the owner wallet
+
+
+ In your wallet provider, switch back to the owner account:
+
+
+ {ownerAddress}
+
+
+ The owner wallet will submit the{" "}
+ setAgentWallet{" "}
+ transaction to finalize the binding.
+
+
+
+ {/* Status indicator */}
+
+
+
+ {isOwnerWalletConnected ? (
+
+ Owner wallet connected. Ready to submit.
+
+ ) : (
+ <>
+ Currently connected:{" "}
+
+ {address?.slice(0, 6)}...{address?.slice(-4)}
+ {" "}
+ — waiting for owner wallet...
+ >
+ )}
+
{bindTxHash && (
@@ -467,15 +681,11 @@ export default function RegisterAgentPage() {
Skip
- {binding ? "Binding wallet..." : "Sign & Bind Wallet"}
+ {binding ? "Binding wallet..." : "Submit Binding Transaction"}
From 7c9d3482a73fc4a8ca31cefce3f0ad20bfc946d0 Mon Sep 17 00:00:00 2001
From: Cho Young-Hwi
Date: Sun, 15 Mar 2026 13:26:50 +0000
Subject: [PATCH 3/3] [#32] Fix ABI parameter order and EIP-712 domain/struct
to match deployed contract
Verified against on-chain source (Sourcify) for the implementation at
0x7274e874ca62410a93bd8bf61c69d8045e399c02:
- ABI: setAgentWallet param order is (agentId, newWallet, deadline, signature),
not (agentId, newWallet, signature, deadline)
- EIP-712 domain name: "ERC8004IdentityRegistry", not "ERC8004AgentRegistry"
- EIP-712 struct: "AgentWalletSet" with fields (agentId, newWallet, owner, deadline),
not "SetAgentWallet" with (agentId, newWallet, deadline)
- Event name: "Registered", not "AgentRegistered"
Co-Authored-By: Claude Opus 4.6 (1M context)
---
lib/contracts/erc8004.ts | 6 +++---
src/app/register-agent/page.tsx | 16 +++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/lib/contracts/erc8004.ts b/lib/contracts/erc8004.ts
index dd568ad2..030e31d9 100644
--- a/lib/contracts/erc8004.ts
+++ b/lib/contracts/erc8004.ts
@@ -35,19 +35,19 @@ export const erc8004Abi = [
inputs: [
{ name: "agentId", type: "uint256" },
{ name: "newWallet", type: "address" },
- { name: "signature", type: "bytes" },
{ name: "deadline", type: "uint256" },
+ { name: "signature", type: "bytes" },
],
outputs: [],
},
// Event — emitted on successful registration
{
type: "event",
- name: "AgentRegistered",
+ name: "Registered",
inputs: [
{ name: "agentId", type: "uint256", indexed: true },
- { name: "owner", type: "address", indexed: true },
{ name: "agentURI", type: "string", indexed: false },
+ { name: "owner", type: "address", indexed: true },
],
},
] as const;
diff --git a/src/app/register-agent/page.tsx b/src/app/register-agent/page.tsx
index 318c9c9a..7f4da512 100644
--- a/src/app/register-agent/page.tsx
+++ b/src/app/register-agent/page.tsx
@@ -40,16 +40,17 @@ type WizardStep = 1 | 2 | "3a" | "3b" | "3c";
// EIP-712 domain for setAgentWallet
const EIP712_DOMAIN = {
- name: "ERC8004AgentRegistry",
+ name: "ERC8004IdentityRegistry",
version: "1",
chainId: BigInt(BASE_CHAIN_ID),
verifyingContract: ERC8004_REGISTRY,
} as const;
const SET_WALLET_TYPES = {
- SetAgentWallet: [
+ AgentWalletSet: [
{ name: "agentId", type: "uint256" },
{ name: "newWallet", type: "address" },
+ { name: "owner", type: "address" },
{ name: "deadline", type: "uint256" },
],
} as const;
@@ -140,7 +141,7 @@ export default function RegisterAgentPage() {
const receipt = await publicClient.waitForTransactionReceipt({ hash });
- // Parse AgentRegistered event to extract agentId
+ // Parse Registered event to extract agentId
const registeredLog = receipt.logs.find((log) => {
try {
const decoded = decodeEventLog({
@@ -148,7 +149,7 @@ export default function RegisterAgentPage() {
data: log.data,
topics: log.topics,
});
- return decoded.eventName === "AgentRegistered";
+ return decoded.eventName === "Registered";
} catch {
return false;
}
@@ -160,7 +161,7 @@ export default function RegisterAgentPage() {
data: registeredLog.data,
topics: registeredLog.topics,
});
- if (decoded.eventName === "AgentRegistered") {
+ if (decoded.eventName === "Registered") {
setAgentId(decoded.args.agentId);
}
}
@@ -192,10 +193,11 @@ export default function RegisterAgentPage() {
const signature = await signTypedDataAsync({
domain: EIP712_DOMAIN,
types: SET_WALLET_TYPES,
- primaryType: "SetAgentWallet",
+ primaryType: "AgentWalletSet",
message: {
agentId,
newWallet: agentWallet as `0x${string}`,
+ owner: ownerAddress as `0x${string}`,
deadline,
},
});
@@ -231,8 +233,8 @@ export default function RegisterAgentPage() {
args: [
agentId,
agentWallet as `0x${string}`,
- agentSignature,
signatureDeadline,
+ agentSignature,
],
});
setBindTxHash(hash);