Clusters
  • Introduction
    • Overview
    • Concepts
      • Cluster Name
      • Wallet Name
    • Features
      • Communities
      • Multichain
      • Wallet Bundles
      • Antisquatting
      • Wallet Generation
      • Selective Wallet Sharing
  • Getting started
    • Javascript
      • Authentication
      • Clusters
      • Address → Cluster Name
      • Cluster Name → Address
      • Registration
        • Communities
      • Event Indexing
    • API
      • v1
        • Authentication
        • Clusters
        • Address → Cluster Name
        • Cluster Name → Address
        • Registration
          • Communities
        • Event Indexing
      • v0.1 (Deprecated)
        • Address → Cluster
        • Cluster → Address
        • Cluster → Metadata
        • Registration
        • Managing Wallets
  • Resources
    • Smart Contracts
    • Address Types
    • Using Clusters for ETH->SOL Airdrops
  • Integration Guides
    • Convert hex address to clusters name
    • Registering a name
      • Ethereum Networks
      • Solana
    • Whitelabel Communities Registration Flow
Powered by GitBook
On this page
  • Install the SDK
  • Setup your imports
  • A single address
  • Multiple addresses in one call
  1. Integration Guides

Convert hex address to clusters name

PreviousUsing Clusters for ETH->SOL AirdropsNextRegistering a name

Last updated 1 month ago

Before you begin, install & setup the cluster imports at the top of your code.

Install the SDK

npm install @clustersxyz/sdk viem

Setup your imports

import { Clusters } from "@clustersxyz/sdk";
const clusters = new Clusters();

A single address

This single address call is great for getting the name of a user's connected wallet or the name of an address on a profile page.

// This will return { clusterName: "clusters", walletName: "main" }
const { clusterName, walletName } = await clusters.getName('0x5755d1dcea21caa687339c305d143e6e78f96adf');

  1. Profile Information

You can use the following helper functions to help display the info you need. We offer 2 functions:

  • A synchronous function to get the profile image url of a cluster name

  • A function to navigate the user to their official clusters profile page on clusters.xyz

You can use the following helper functions to help display the info you need

import { getImageUrl, getProfileUrl } from "@clustersxyz/sdk";

// https://cdn.clusters.xyz/profile/clusters
const profileImage = getImageUrl(clusterName);

// https://clusters.xyz/clusters
const profileUrl = getProfileUrl(clusterName);

Clusters are a multi-wallet username. Sometimes you will want to display the other wallets a cluster has. By passing in the cluster name, you'll be able to retrieve an array of wallets along with their type.

When people create a cluster, they can add multiple addresses to it. If you want to be able to display this information, you can call the following function.

const cluster = await clusters.getClusterByName('clusters');

/*
{
  "id": "0xa8d12b92b91fe0db3651ff2d45c1f47b1bb343054e9cd1e556c73f2330269224",
  "createdBy": "0x5cff9c1362a71247da33887be2a44ac36a8724bb",
  "createdAt": "2024-02-14 21:39:05+00",
  "wallets": [
    {
      "address": "0x5cff9c1362a71247da33887be2a44ac36a8724bb",
      "name": "main",
      "isVerified": true,
      "isPrivate": false,
      "isBackedUp": false,
      "updatedAt": "2024-02-09 15:21:22+00",
      "updatedBy": "0x5cff9c1362a71247da33887be2a44ac36a8724bb",
      "createdAt": "2024-02-09 15:21:22+00"
    }
  ],
  "isTestnet": false
}
*/


Multiple addresses in one call

This is useful if you have 2 or more addresses on a page that you want to retrieve a cluster name for. You can get all the information you need in one call.

  1. Resolve multiple names

import { Clusters } from "@clustersxyz/sdk";
const clusters = new Clusters();

const clusterName = await clusters.getNames([
    '0x5755d1dcea21caa687339c305d143e6e78f96adf', 
    '0xccdead94e8cf17de32044d9701c4f5668ad0bef9'
]);

/*
[
  {
    "address": "0x5755d1dcea21caa687339c305d143e6e78f96adf",
    "name": "clusters/main"
  },
  {
    "address": "0xccdead94e8cf17de32044d9701c4f5668ad0bef9",
    "name": "layerzero/main"
  }
]
*/