Bako Docs
  • Welcome
  • Developers
    • ID
      • Architecture
      • Contracts
      • SDK
        • Quickstart
        • Bako ID Client
        • Registry Contract
Powered by GitBook
On this page
  • Install
  • Address Resolution
  • Metadata
  1. Developers
  2. ID
  3. SDK

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:

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

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:

import { Provider } from 'fuels';

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

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

const registryContract = RegistryContract.create(provider);

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

const metadata = await registryContract.getMetadata(domain);
console.log(metadata);

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:

{
    "social:discord": "my_discord",
    "contact:email": "my@email.com",
    "contact:location": "Fuel - ETH"
}
PreviousSDKNextBako ID Client

Last updated 1 month ago