Integration
The JS library is available on NPM https://www.npmjs.com/package/@solana/spl-name-service

Resolve a Twitter handle

Direct look up

To resolve the public key associated to a Twitter handle
1
const pubkey = await getTwitterRegistry(connection, twitterHandle);
Copied!

Reverse look up

To resolve the Twitter handle associated to the public key
1
const [twitterHandle] = await getHandleAndRegistryKey(
2
connection,
3
pubkey
4
);
Copied!

Resolve a .sol domain name

To resolve the public key associated to a .sol domain name
1
// Address of the SOL TLD
2
export const SOL_TLD_AUTHORITY = new PublicKey(
3
"58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"
4
);
5
6
7
export const getInputKey = async (input: string) => {
8
let hashed_input_name = await getHashedName(input);
9
let inputDomainKey = await getNameAccountKey(
10
hashed_input_name,
11
undefined,
12
SOL_TLD_AUTHORITY
13
);
14
return { inputDomainKey: inputDomainKey, hashedInputName: hashed_input_name };
15
};
16
17
18
// ...
19
const { inputDomainKey } = await getInputKey(input);
20
const registry = await NameRegistryState.retrieve(
21
connection,
22
inputDomainKey
23
);
Copied!
Last modified 5mo ago