Step 2: Fetch the Live Registry
Replace the contents of check.ts with this:
import { findRegistryCell, fetchRegistryPayload } from "@ckb-firewall/sdk";
const RPC_URL = "https://testnet.ckb.dev";
const REGISTRY_SPEC = { codeHash: "0x493f1700508125b0e281b8fb1d168b03bd5ef71480399dd59221224901a9cd09", hashType: "type" as const, typeIdValue: "0x9be0ad6e4e5039a64d9725ff037057c16ef59f126e3bdd9841b802f0e0a112fe", required: true,};
// Find the current registry cell outpoint via the indexerconst { txHash, index } = await findRegistryCell(RPC_URL, REGISTRY_SPEC);console.log(`Registry cell: ${txHash}:${index}`);
// Fetch and parse the BLKL v2 payloadconst registry = await fetchRegistryPayload(RPC_URL, txHash, index);console.log(`Active entries: ${registry.entries.length}`);Run it:
npx tsx check.tsYou should see something like:
Registry cell: 0xa3dcb46fdeb92735e7f9f0393811a8541b71e275e8f713e62ea35f59746c78a8:0Active entries: 2The exact entry count may differ — it reflects the live state of the testnet registry.
Notice two things:
- We used
findRegistryCellinstead of hardcoding a transaction hash. The registry outpoint changes every time a governance update is confirmed.findRegistryCellqueries the CKB indexer to find the current outpoint, so our code keeps working without configuration changes. fetchRegistryPayloadreturns a parsedRegistryPayloadobject — not raw bytes. The SDK parsed the BLKL v2 binary format and validated the sort order of entries. If the payload were malformed or unsorted, it would have thrown an error here.
Continue to Step 3.