Direct Lookup
import { getDomainKeySync, NameRegistryState } from "@bonfida/spl-name-service";
const domainName = "bonfida"; // With or without the .sol at the end
// Step 1
const { pubkey } = getDomainKeySync(domainName);
// Step 2
// The registry object contains all the info about the domain name
// The NFT owner is of type PublicKey | undefined
const { registry, nftOwner } = await NameRegistryState.retrieve(
connection,
pubkey
);
// Subdomain derivation
const subDomain = "dex.bonfida"; // With or without the .sol at the end
const { pubkey: subKey } = getDomainKeySync(subDomain);
// Record derivation (e.g IPFS record)
const record = "IPFS.bonfida"; // With or without the .sol at the end
const { pubkey: recordKey } = getDomainKeySync(record, true);
Last updated