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
  1. Integration Guides
  2. Registering a name

Solana

PreviousEthereum NetworksNextWhitelabel Communities Registration Flow

Last updated 1 month ago

  1. Let the user decide what name they want

You'll want to provide some sort of input box that allows a user to see if the name they want is available.

  1. Check if the name is valid

There are some restrictions for registering a name. In short, the name must fit in 32 bytes, must not have a space, or a /.

import { isNameValid } from "@clustersxyz/sdk"

const validName = "clusters";
console.log(isNameValid(validName)); // true

const invalidName = "c/c/c/c";
console.log(isNameValid(invalidName)); // false

  1. Once you know the name is valid, make sure the name is not taken

import { isNameValid } from "@clustersxyz/sdk"

const name = "clusters";
const nameAvailability = await clusters.getNameAvailability([name]);
console.log(nameAvailability[0].isAvailable) // false

  1. Get the raw transaction data for the on-chain transaction

This call will get you the on-chain transaction data to register the names you want at the minimum registration fee of 0.01 ETH (converted to lamports).

const names = [{ name: 'mynewname' }];
const signerAddress = 'A59..iHqw';
const data = await clusters.getRegistrationTransactionSolana(names, signerAddress);

  1. You can now display the registration fee

import { LAMPORTS_PER_SOL } from '@solana/web3.js';

const registrationFee = Number(data.registrationFee) / LAMPORTS_PER_SOL;

// Total Registration fee: 0.2248 SOL
console.log(`Total Registration fee: ${registrationFee} ${data.gasToken.symbol}`);

  1. Submit the transaction

// Example of a solana provider
// https://docs.phantom.app/solana/detecting-the-provider
const solanaProvider = window.phantom?.solana;

for (const transaction of data.transactionData) {
   const deserializedMessage = web3.VersionedMessage.deserialize(
      Buffer.from(transaction, 'base64')
   );
   const newTransaction = new web3.VersionedTransaction(deserializedMessage);
   
   const signedTransaction = await $Wallet.solanaProvider.signTransaction(newTransaction);
   const signature = await connection.sendTransaction(signedTransaction);
}

  1. Track the status of the transaction

Once the transaction is submitted, you can check when the registration has been processed. An alternative method is pinging the getNameAvailability() function to see when the name becomes taken.

const getStatus = await clusters.getTransactionStatus(signature);
console.log(getStatus.status) // finalized

If you want to impose a specific registration amount, you can do so in the names array. Input these amounts in Wei and they'll be converted to SOL. Check out the documentation on to learn more.

getting the transaction data