Registration

SNS Widget

Easily integrate SNS domain registrations into your applications using our SNS Widget React Component. See a default usage example below. You can also customize the widget to fit your unique needs. More information is available at the link below -

import Widget from "@bonfida/sns-widget";
// Apart from the component itself, you also need to import styles separately
import "@bonfida/sns-widget/style.css";

// Link to public RPC for Solana connection. Solana provides free public RPCs
// with rate limiters, so you might want to use your own RPC Node provider
const PUBLIC_RPC = "https://api.mainnet-beta.solana.com";

export const Component = () => {
  return <Widget endpoint={PUBLIC_RPC} />;
};

SNS Widget Walkthrough

The video walk through below details integration using the SNS Widget.

Register Domain Name

If you opt not to use our out of the box SNS Widget React component, the registerDomainNameV2function can be used instead.

The last 2 arguments to the function are optional in both the web.js v1 and v2 (@solana/kit) versions. The fifth argument is the token mint to purchase the domain, which defaults to USDC. The sixth argument is the referrers key. If you've been approved as a registration referrer, add the approved public key as the last argument.

If you'd like to integrate registrations into your dApp and would like to discuss becoming a referrer, please reach out to the SNS team via Discord or Twitter.

import { registerDomainNameV2, USDC_MINT } from "@bonfida/spl-name-service";

const name = "sns"; // We want to register sns.sol
const space = 0; // Default to 0 (Max 10kb)

const buyer = new PublicKey("..."); // Publickey of the buyer
const buyerTokenAccount = new PublicKey("..."); // Publickey of the token account of the buyer (USDC)
const refKey = new PublicKey("...") // If approved as a registration referrer, add your referral key

const ix = await registerDomainNameV2(
connection,
name, 
space, 
buyer, 
buyerTokenAccount, 
USDC_MINT, 
refKey
);

// sign and send the instruction

Last updated