-
-
Save levicook/1fd54ada3dee5825e9c7c58e96b4dd22 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
node_modules | |
package-lock.json |
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
#!/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) | |
}()); |
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
{ | |
"name": "1fd54ada3dee5825e9c7c58e96b4dd22", | |
"bin": "./getSolDomainOwner.js", | |
"dependencies": { | |
"@solana/spl-name-service": "^0.1.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made this runnable via npx