Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
node_modules
package-lock.json
#!/usr/bin/env node
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;
};
(async function() {
const args = process.argv.slice(2)
await Promise.all(args.map(async arg => {
const owner = await getSolDomainOwner(arg);
console.log(arg, '\t', owner.toString())
}))
process.exit(0)
}());
{
"name": "1fd54ada3dee5825e9c7c58e96b4dd22",
"bin": "./getSolDomainOwner.js",
"dependencies": {
"@solana/spl-name-service": "^0.1.3"
}
}
@levicook
Copy link
Author

levicook commented Dec 10, 2021

Made this runnable via npx

➜  ~ npx https://gist.github.com/levicook/1fd54ada3dee5825e9c7c58e96b4dd22 levi.sol korg.sol
Need to install the following packages:
  gist:1fd54ada3dee5825e9c7c58e96b4dd22
Ok to proceed? (y) y
korg.sol 	 JUskoxS2PTiaBpxfGaAPgf3cUNhdeYFGMKdL6mZKKfR
levi.sol 	 JUskoxS2PTiaBpxfGaAPgf3cUNhdeYFGMKdL6mZKKfR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment