Skip to content

[#32] Add agent registration wizard#125

Merged
realproject7 merged 3 commits intomainfrom
task/32-agent-registration-wizard
Mar 15, 2026
Merged

[#32] Add agent registration wizard#125
realproject7 merged 3 commits intomainfrom
task/32-agent-registration-wizard

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Fixes #32

Summary

  • Add 3-step /register-agent wizard for ERC-8004 agent registration
  • Step 1: Agent profile form (name, description, genre, LLM model) with auto-generated agentURI metadata JSON
  • Step 2: On-chain register(agentURI) call, parses AgentRegistered event to extract agentId
  • Step 3: EIP-712 typed data signing + setAgentWallet(agentId, newWallet, signature, deadline) call (with skip option)
  • Add register, setAgentWallet, and AgentRegistered ABI entries to lib/contracts/erc8004.ts
  • Redirects to /create on completion
  • Follows existing dark theme, Tailwind patterns, wagmi/viem usage from the codebase

Test plan

  • Connect wallet and navigate to /register-agent
  • Fill out agent profile and verify metadata JSON preview
  • Confirm register() tx submits and agentId is displayed
  • Verify EIP-712 signature prompt and setAgentWallet() tx
  • Verify skip button redirects to /create
  • Verify lint and typecheck pass

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The Step 1/2 wizard structure looks reasonable, but Step 3 is currently wired to sign the EIP-712 payload with the connected wallet from wagmi, not with the agentWallet being bound. That makes the core setAgentWallet flow fail for the intended owner-wallet -> agent-wallet registration path described in issue #32.

Findings

  • [high] Step 3 signs with the wrong account, so setAgentWallet cannot complete the intended wallet-binding flow
    • File: src/app/register-agent/page.tsx:65
    • Suggestion: useSignTypedData() signs with the currently connected wallet, while the typed message says newWallet: agentWallet. Unless the connected account is literally switched to agentWallet, the signature will not be from newWallet and the contract should reject it. But if the user does switch to agentWallet, the subsequent writeContractAsync(setAgentWallet) tx is no longer sent by the owner wallet that just registered the agent. Rework Step 3 so the signature is produced by the target agent wallet and the tx submission remains owned by the correct caller, or explicitly redesign the UX around the required wallet switching.

Decision

Request changes because the current implementation does not satisfy issue #32's required setAgentWallet flow in a real two-wallet setup.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review: REQUEST CHANGES

This is a solid start but has security and robustness issues to address:

Critical

  1. Missing nonce in EIP-712 SetAgentWallet type — The typed data includes agentId, newWallet, deadline but no nonce. If the ERC-8004 contract expects a nonce field, the signature will be invalid. If it doesn't, the signed message is replayable by anyone before deadline expires. Either add the nonce field to match the contract, or document why replay is safe (e.g., contract invalidates after first use). This must be verified against the actual contract.

High

  1. No address validation in handleSetWallet() — Validation only exists on the button's disabled prop. If bypassed (keyboard submit, future refactor), an invalid address flows into the signature. Add a guard at the top of the handler, ideally using viem's isAddress().
  2. Stale registeredAt in agentURInew Date().toISOString() in useMemo captures memo evaluation time, not submission time. If user waits before submitting, timestamp is stale. Move it into handleRegister() or drop it in favor of on-chain block.timestamp.

Medium

  1. Wallet disconnect mid-flow loses agentId — If wallet disconnects after Step 2, component remounts and agentId state is lost. User can't resume Step 3 without checking the chain. Consider persisting agentId to URL params or localStorage.
  2. Empty agentURI crash — If user goes Back from Step 2, clears name, the agentURI memo returns "". The metadata preview JSON.parse("") throws. Add profileValid check to Step 2's register button disabled condition.

Low

  1. No maxLength on form inputs — very long names/descriptions increase gas costs.
  2. Hardcoded 1-hour signature deadline — consider making it a named constant or extending to 24h.

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) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The Step 3 wallet-switching flow is directionally better, but the implementation still does not match the deployed ERC-8004 registry interface. I verified this against the contract definition: the current ABI and EIP-712 payload shape are still wrong, so setAgentWallet will not validate the signature correctly.

Findings

  • [high] setAgentWallet ABI parameter order is incorrect
    • File: lib/contracts/erc8004.ts:33
    • Suggestion: The PR defines setAgentWallet(agentId, newWallet, signature, deadline), and Step 3 submits args in that order from src/app/register-agent/page.tsx:227. The deployed registry interface is setAgentWallet(agentId, wallet, deadline, sig). Update the ABI and call site to match the real contract.
  • [high] The EIP-712 domain and typed message do not match the registry contract
    • File: src/app/register-agent/page.tsx:42
    • Suggestion: The wizard signs domain name ERC8004AgentRegistry and message { agentId, newWallet, deadline } at src/app/register-agent/page.tsx:192, but the registry contract expects a different EIP-712 payload for setAgentWallet (including the owner and nonce, with the registry's actual domain name). As written, the agent wallet signs a payload the contract will not recover/accept. Rebuild the typed data from the real contract spec before re-review.

Decision

Request changes because the current Step 3 implementation still cannot complete a valid setAgentWallet flow against the deployed ERC-8004 registry.

…oyed 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) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The follow-up fixes align the wizard with the deployed ERC-8004 registry contract: the Registered event, setAgentWallet ABI order, and EIP-712 domain/message now match the contract shape. The Step 3 wallet-switch flow is coherent for the two-wallet registration path, and CI passed.

Findings

  • None.

Decision

Approve because the contract-facing correctness issues are resolved, the PR satisfies issue #32 end-to-end, and lint-and-typecheck passed.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Re-review: APPROVE

Critical and high issues from my first review are resolved or downgraded:

  • EIP-712 nonce: Struct verified against deployed contract (Sourcify) — no nonce field exists on-chain. Not a frontend bug.
  • ABI/domain/event corrections: All look correct per on-chain source.
  • Wallet-switch flow: ownerAddress now persisted in state, Step 3 split correctly handles agent-sign then owner-submit.

Remaining non-blocking items (follow-up):

  • Add a comment explaining why no nonce is needed in the EIP-712 type
  • Add handler-level address validation in handleAgentSign() (defense-in-depth)
  • Move registeredAt from useMemo to submission time in handleRegister()

@realproject7 realproject7 merged commit af11607 into main Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P6-1] Agent Registration Wizard (Web)

2 participants