const labelHash = keccak256('custom');
const rootNode = '0x0000000000000000000000000000000000000000000000000000000000000000';
const nodeHash = keccak256(rootNode + labelHash);
// Deploy new registrar for your TLD
const baseRegistrar = await BaseRegistrar.deploy(
PNS_REGISTRY_ADDRESS,
nodeHash
);
// Through PNS Registry
await pnsRegistry.setSubnodeOwner(
rootNode,
labelHash,
baseRegistrar.address
);
// Set resolver
await baseRegistrar.setResolver(PUBLIC_RESOLVER_ADDRESS);
const PNS_REGISTRY = "0x123..."; // PNS Registry address
const PUBLIC_RESOLVER = "0x456..."; // Default resolver
// Deploy TLD Registrar
const customRegistrar = await BaseRegistrar.deploy(
PNS_REGISTRY,
namehash("custom")
);
// Set as owner in registry
await pnsRegistry.setSubnodeOwner(
"0x0",
keccak256("custom"),
customRegistrar.address
);