Skip to content

Instantly share code, notes, and snippets.

@johnrees
Last active December 10, 2021 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnrees/3c6943e00131aa8784efc97bffdabed1 to your computer and use it in GitHub Desktop.
Save johnrees/3c6943e00131aa8784efc97bffdabed1 to your computer and use it in GitHub Desktop.
const {
getHashedName,
getNameAccountKey,
NameRegistryState,
} = require("@solana/spl-name-service");
const {
Connection,
clusterApiUrl,
PublicKey,
} = require("@solana/web3.js");
const getSolDomainOwner = async (domain) => {
const { owner } = await NameRegistryState.retrieve(
new Connection(clusterApiUrl("mainnet-beta")),
await getNameAccountKey(
await getHashedName(domain.replace(".sol", "")),
null,
new PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx")
)
);
return owner;
};
getSolDomainOwner("levi.sol").then(x => console.log(x.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment