fix: lookup registry NFT at script address, not wallet

The registry NFT is locked at the registry script address with
the 10 AP3X deposit, not in the agent's wallet. Use getUtxoByUnit
to find it on-chain regardless of address.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
david
2026-04-09 14:34:00 +02:00
parent 0bf2d5230c
commit 52420c3cad

View File

@@ -610,12 +610,14 @@ Each batch UTxO holds ~30 AP3X for adoption rewards.`,
]); ]);
// Find agent's registry NFT UTxO for DID validation (CIP-31 reference input) // Find agent's registry NFT UTxO for DID validation (CIP-31 reference input)
// The NFT lives at the registry script address (locked with deposit), not the wallet
const nftUnit = AGENT_REGISTRY_POLICY + agentDid; const nftUnit = AGENT_REGISTRY_POLICY + agentDid;
const walletUtxos = await lucid.wallet().getUtxos(); let nftUtxo;
const nftUtxo = walletUtxos.find(u => u.assets[nftUnit] === 1n); try {
if (!nftUtxo) { nftUtxo = await provider.getUtxoByUnit(nftUnit);
} catch {
throw new Error( throw new Error(
`Agent registry NFT not found in wallet. Expected token: ${AGENT_REGISTRY_POLICY.slice(0, 12)}...${agentDid.slice(0, 12)}... ` + `Agent registry NFT not found on-chain. Expected token: ${AGENT_REGISTRY_POLICY.slice(0, 12)}...${agentDid.slice(0, 12)}... ` +
`The agent may need to re-register with vector_register_agent.` `The agent may need to re-register with vector_register_agent.`
); );
} }