Skip to content

Quickstart

In this guide you will find the address that holds a GitHub handle, and then the handle that address shows as its name. You only read from the chain, so you need no wallet and no tokens.

You need Node.js 22.12 or later, and a network that runs libID. Set RPC_URL and IDENTITY_REGISTRY for it. For Sepolia:

Terminal window
export RPC_URL=https://sepolia.gateway.tenderly.co
export IDENTITY_REGISTRY=0x58Ac0CD5eC19C850A75D6183b3C3B2DE692FB20D

The other networks are listed under Networks. The guides use the GitHub handle testyakly, which is bound on Sepolia.

Create a project and install viem and the libID contracts package:

Terminal window
mkdir libid-quickstart && cd libid-quickstart
npm init -y
npm install viem @libid/contracts

IdentityRegistry is the contract that stores which address holds which identity: a platform account it has proved.

Create index.mjs:

import { createPublicClient, http } from 'viem';
import { platformId, primaryHandleOf, resolveHandle } from '@libid/contracts';
const registry = {
client: createPublicClient({ transport: http(process.env.RPC_URL) }),
address: process.env.IDENTITY_REGISTRY,
};
const github = platformId('github');

Every platform has an id. platformId('github') is the keccak256 hash of the string github. The other platforms are 'x' and 'google'.

Add this to index.mjs:

const holder = await resolveHandle(registry, github, 'testyakly');
console.log(holder);

resolveHandle returns the address that proved it holds the handle, or null if nobody has. Only A to Z are folded to lowercase, so TestYakly finds testyakly. @testyakly is different text, and nobody holds it.

Now go the other way:

if (holder) {
const primary = await primaryHandleOf(registry, holder);
console.log(primary?.handle);
}

primaryHandleOf returns the one handle the holder chose as its name, and its platformId. A holder has at most one, on any platform. It returns null if the holder has not chosen one, or if the handle now belongs to someone else.

Terminal window
node index.mjs

On Sepolia you will see:

0xB2C7C8eA84932a0dADf8F6f0550cFc89A345540c
testyakly

On another network, nobody may hold testyakly, and it prints null. Try a handle that someone has bound there.

You can make the same call with Foundry’s cast:

Terminal window
cast call $IDENTITY_REGISTRY 'resolveHandle(bytes32,string)(address)' \
$(cast keccak github) testyakly --rpc-url $RPC_URL

See Addresses for every contract on every network.