X Handle Methods

SNS supports the registration of Twitter handles, allowing users to connect their Twitter profile to their wallet as described in this section: X (formerly Twitter) TLD.

X (formerly Twitter) root TLD

const TWITTER_ROOT_PARENT_REGISTRY_KEY = new PublicKey(
  "4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"
);

The .twitter TLD is owned by the root TLD and all twitter handles are subdomains of the .twitter TLD.

Direct look up

To find the Twitter handle associated to a public key

import { getHandleAndRegistryKey } from "@bonfida/spl-name-service";

const pubkey = new PublicKey("FidaeBkZkvDqi1GXNEwB8uWmj9Ngx2HXSS5nyGRuVFcZ");

const [handle] = await getHandleAndRegistryKey(connection, pubkey);

Reverse look up

To find the public key associated to a Twitter handle

import { getTwitterRegistry } from "@bonfida/spl-name-service";

const handle = "bonfida";

const registry = await getTwitterRegistry(connection, handle);
const owner = registry.owner.toBase58()

Last updated