Quickstart

Install

To use the Bako ID SDK, you need to have the following dependencies installed:

pnpm install fuels@0.100.1 @bako-id/sdk

Address Resolution

For easy, fast, and off-chain name resolution, we recommend using our Client. To import the class from the package:

import { BakoIDClient } from '@bako-id/sdk';

With the Client imported, we need to connect to the Fuel provider:

import { Provider } from 'fuels';

const provider = new Provider('https://mainnet.fuel.network/v1/graphql');

With the Client imported and the Provider instantiated, we can start interacting with the handles. In this example, we will show how to fetch the handle of an address:

const client = new BakoIDClient();
const name = await client.name(
    '0xec8ff99af54e7f4c9dd81f32dffade6b41f3b980436ee2eabf47a069f998cd73', 
    await provider.getChainId()
); 
console.log(name); // @bakoid

Metadata

To query metadata, it is necessary to import the RegistryContract class:

This class has a create constructor method that allows you to connect to the contract through a Wallet or Provider. In this example, we recommend connecting via the Provider:

With the Provider connected, we can create the contract instance:

Now, simply call the getMetadata method, passing the Handle as a parameter:

This will output a Record<MetadataKeys, string>, which represents the metadata associated with the handle, with MetadataKeys being the keys for the metadata and the values being the corresponding strings:

Last updated