Problem
After linking an OWS wallet via "Link AI Writer", the human wallet's profile shows "AI Writer" + "AI Agent" badge instead of the user's Farcaster name. Root cause: ERC-8004 registration is on the human wallet, creating a two-row DB conflict where getUserFromDB and getAgentUserFromDB return different rows.
Revised approach: ERC-8004 on OWS wallet, DB-only link for human
New architecture
- ERC-8004 registration goes on the OWS wallet — the agent identity NFT belongs to the wallet that actually signs transactions and publishes stories
- Human ↔ OWS link is DB-only — plotlink.xyz stores a
linked_agent_wallet mapping on the human's user row. No ERC-8004 involvement on the human side
- Binding proof still required — OWS wallet signs "I authorize {humanWallet} as my owner" to prevent anyone claiming someone else's OWS wallet
Updated flow
Step 1 — plotlink-ows (already exists):
User enters human wallet → OWS wallet signs binding proof → shows code to copy
Step 2 — plotlink.xyz "Link AI Writer":
User pastes OWS wallet address + binding signature → `ecrecover` verifies OWS wallet signed it → DB link created:
```sql
UPDATE users SET linked_agent_wallet = '0xdABF...' WHERE primary_address = '0x4d68...'
```
Step 3 — ERC-8004 registration (plotlink-ows, separate):
OWS wallet registers ITSELF on-chain via ERC-8004 `register()` — no human wallet involved. Uses existing ETH balance (already funded for publishing).
Profile display
- OWS wallet (`0xdABF...`): "AI Writer" + "AI Agent" badge + "Operated by: Project7" (lookup via DB link)
- Human wallet (`0x4d68...`): "Project7" + "Human" badge + "Operates: AI Writer" (lookup via `linked_agent_wallet`)
Benefits
- Human profile never gets agent fields — no two-row DB conflict
- ERC-8004 identity is on the correct wallet (the one that signs txs)
- No `agent_type` distinction needed on human row
- Simpler profile logic: `agentMeta` only returns non-null for actual agent wallets
Migration
- Existing registration (Agent ID 44545 on human wallet) needs to be unregistered and re-registered on OWS wallet
- DB: clear agent fields from human row, add `linked_agent_wallet` column
Implementation tickets (across both repos)
plotlink-ows:
- ERC-8004 self-registration: OWS wallet registers itself (not the human wallet)
- Remove "Generate Wallet Bind Code" step 2 (ERC-8004 setAgentWallet) — no longer needed
plotlink:
- Add `linked_agent_wallet` column to users table
- Update "Link AI Writer" endpoint: verify binding proof → set `linked_agent_wallet` (no ERC-8004)
- Update profile display: use `linked_agent_wallet` for "Operates: AI Writer" on human profiles
- Update WriterIdentity: lookup agent owner via `linked_agent_wallet` reverse lookup
- Migration: clean up existing mis-registered agent data
Files
- `lib/actions.ts` — profile/agent lookup logic
- `src/components/AgentRegister.tsx` — "Link AI Writer" UI
- `src/app/api/user/agent-register/route.ts` — registration endpoint
- `lib/contracts/erc8004.ts` — agent detection
- DB migration for `linked_agent_wallet` column
Problem
After linking an OWS wallet via "Link AI Writer", the human wallet's profile shows "AI Writer" + "AI Agent" badge instead of the user's Farcaster name. Root cause: ERC-8004 registration is on the human wallet, creating a two-row DB conflict where
getUserFromDBandgetAgentUserFromDBreturn different rows.Revised approach: ERC-8004 on OWS wallet, DB-only link for human
New architecture
linked_agent_walletmapping on the human's user row. No ERC-8004 involvement on the human sideUpdated flow
Step 1 — plotlink-ows (already exists):
User enters human wallet → OWS wallet signs binding proof → shows code to copy
Step 2 — plotlink.xyz "Link AI Writer":
User pastes OWS wallet address + binding signature → `ecrecover` verifies OWS wallet signed it → DB link created:
```sql
UPDATE users SET linked_agent_wallet = '0xdABF...' WHERE primary_address = '0x4d68...'
```
Step 3 — ERC-8004 registration (plotlink-ows, separate):
OWS wallet registers ITSELF on-chain via ERC-8004 `register()` — no human wallet involved. Uses existing ETH balance (already funded for publishing).
Profile display
Benefits
Migration
Implementation tickets (across both repos)
plotlink-ows:
plotlink:
Files