Skip to content

Instantly share code, notes, and snippets.

@levicook
Forked from johnrees/getSolDomainOwner.js
Last active December 10, 2021 18:54
Show Gist options
  • Save levicook/1fd54ada3dee5825e9c7c58e96b4dd22 to your computer and use it in GitHub Desktop.
Save levicook/1fd54ada3dee5825e9c7c58e96b4dd22 to your computer and use it in GitHub Desktop.
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

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