Code Monkey home page Code Monkey logo

sdk's Introduction

SDK for Clusters which resolves names, addresses, and wallets for finalized clusters.

Read more about the clusters.xyz via our documentation

Installation

npm install @clustersxyz/sdk

Setup

import { Clusters } from "@clustersxyz/sdk"

const clusters = new Clusters();

Usage

Check out our /examples folder for usage.

getName(address)

Get the cluster and wallet name based on an address

const clusterName = await clusters.getName('0x5755d1dcea21caa687339c305d143e6e78f96adf');

Returns

clusters/main

getAddress(name)

Get the wallet associated to a cluster name. You can pass just the cluster name or also include the wallet name as shown in the 2 examples.

const clusterAddress_Option1 = await clusters.getAddress('clusters/');
const clusterAddress_Option2 = await clusters.getAddress('clusters/main');

Returns

{
  "type": "evm",
  "address": "0x5755d1dcea21caa687339c305d143e6e78f96adf",
  "name": "clusters/main",
  "isVerified": true
}

getCluster(clusterName)

Get the cluster from a cluster name

const cluster = await clusters.getCluster('clusters/');

Returns

{
  "name": "clusters/",
  "wallets": [
    {
      "type": "evm",
      "address": "0x5755d1dcea21caa687339c305d143e6e78f96adf",
      "name": "clusters/main",
      "isVerified": true
    }
  ]
}

Bulk fetch

getNames(address[])

Get the cluster and wallet names from a list of addresses

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

Returns

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

getAddresses(name[])

Get the wallets associated to multiple cluster names. You can pass just the cluster name or also include the wallet name.

const clusterAddresses = await clusters.getAddresses([
    "clusters/",
    "clusters/main",
    "layerzero/",
    "layerzero/main"
]);

Returns

[
  {
    name: "clusters/",
    type: "evm",
    address: "0x5755d1dcea21caa687339c305d143e6e78f96adf",
    isVerified: true
  },
  {
    name: "clusters/main",
    type: "evm",
    address: "0x5755d1dcea21caa687339c305d143e6e78f96adf",
    isVerified: true
  },
  {
    name: "layerzero/",
    type: "evm",
    address: "0xccdead94e8cf17de32044d9701c4f5668ad0bef9",
    isVerified: true
  },
  {
    name: "layerzero/main",
    type: "evm",
    address: "0xccdead94e8cf17de32044d9701c4f5668ad0bef9",
    isVerified: true
  }
]

getClusters(clusterName[])

Get the clusters from a list of cluster names

const clusters = await clusters.getClusters([
    "clusters/",
    "layerzero/"
]);

Returns

[
  {
    name: "clusters/",
    wallets: [
      {
        name: "clusters/main",
        type: "evm",
        address: "0x5755d1dcea21caa687339c305d143e6e78f96adf",
        isVerified: true
      }
    ]
  },
  {
    name: "layerzero/",
    wallets: [
      {
        name: "layerzero/main",
        type: "evm",
        address: "0xccdead94e8cf17de32044d9701c4f5668ad0bef9",
        isVerified: true
      }
    ]
  }
]

Utilities

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

const imageUrl = getImageUrl("clusters/");
const profileUrl = getProfileUrl("clusters/");

sdk's People

Contributors

ryespresso avatar zodomo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.