const {ethers}=require("ethers");
const p=new ethers.JsonRpcProvider("https://forno.celo.org");

// Scan known 8004 prefix addresses
const addrs=[
  "0x8004C47bE24F8B2a7D7e5F3c1B9a6E2f4D8c0A1b",
  "0x8004000000000000000000000000000000000001",
  "0x8004000000000000000000000000000000000002",
  "0x8004000000000000000000000000000000000003",
  "0x80040000000000000000000000000000000000a1",
  "0x80040000000000000000000000000000000000a2",
  "0x80040000000000000000000000000000000000a3",
];

// Also check the ABI of the identity registry for validation hints
const identity = new ethers.Contract(
  "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
  ["function tokenURI(uint256) view returns (string)"],
  p
);

(async()=>{
  // Check agent 17 tokenURI
  try {
    const uri = await identity.tokenURI(17);
    console.log("Agent 17 URI (first 100 chars):", uri.substring(0,100));
  } catch(e) {
    console.log("tokenURI error:", e.message.substring(0,60));
  }

  // Scan for validation contracts
  for(const a of addrs){
    try {
      const code = await p.getCode(a);
      if(code.length > 2) console.log("FOUND CONTRACT:", a);
    } catch(e){}
  }
  console.log("Scan complete");
})();
