Last active
December 10, 2021 18:21
-
-
Save johnrees/3c6943e00131aa8784efc97bffdabed1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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