SNS SDK monorepo
yarn add @bonfida/spl-name-service
npm i @bonfida/spl-name-service
The JS SDK is the most complete SDK, it contains all the utils methods to interact with domain names as well as instruction builders to register domain names.
The Rust SDK provides everything you need for resolving domain ownership and records within the Solana Name Service (SNS)
resolve_owner
: Resolves the owner of a given domainresolve_record
: Resolves a specific record of a given domainresolve_name_registry
: Resolves the name registry of a given public keyresolve_name_registry_batch
: Resolves the name registry of a given list of public keysresolve_reverse
: Resolves the reverse record of a given public keyresolve_reverse_batch
: Resolves the reverse records for a given list of public keysget_domains_owner
: Retrieves all domains owned by a given public keyget_subdomains
: Retrieves all subdomains of a given parent domainresolve_nft_owner
: Resolves the NFT owner of a given domain keyget_domain_key
: Takes a domain string and a boolean indicating whether it is a record. It returns the public key for the given domain, or an error if the domain is invalidget_reverse_key
: Takes a domain string and returns the public key for the reverse lookup account of the domain, or an error if the domain is invalidget_domain_mint
: Takes a domain key and returns the corresponding domain NFT mint's public key
The functions in this code are available in both blocking and non-blocking (asynchronous) versions. To use the blocking version one must enable the blocking
feature.
The SDK proxy is a Cloudflare worker that proxies the JS SDK via REST calls. It's meant to be used if you are programming in a language that is not supported. It currently supports the following endpoints:
GET /resolve/:domain
: Resolves the current owner ofdomain
GET /domain-key/:domain
: Returns the public key of thedomain
accountGET /domains/:owner
: Returns the list of domains (public keys) owned byowner
GET /reverse-key/:domain
Returns the key of the reverse account ofdomain
GET /record-key/:domain/:record
: Returns the public key of therecord
ofdomain
GET /record/:domain/:record
: Returns the content of therecord
ofdomain
. The result is a base64 encoded buffer.GET /favorite-domain/:owner
: Returns the favorite domain ofowner
. Ifowner
has not set up a favorite domain it returnsnull
GET /types/record
: Returns the list of supported recordsGET /reverse-lookup/:pubkey
: Returns the reverse lookup ofpubkey
GET /subdomains/:parent
: Returns all the subdomains ofparent
GET /register?buyer={buyer}&domain={domain}&space={space}&serialize={serialize}
: This endpoint can be used to registerdomain
forbuyer
. Additionaly, thebuyer
dans specify thespace
it wants to allocate for thedomain
account. In the case whereserialize
istrue
the endpoint will return the transaction serialized in the wire format base64 encoded. Otherwise it will return the instruction in the following format:{ programId: string, keys: {isWritable: boolean, isSigner: boolean, pubkey: string}[], data: string }
where data is base64 encoded. This endpoint also supports the optionalmint
parameter to change the mint of the token used for registration (currently supports USDC, USDT, FIDA and wSOL), ifmint
is omitted it defaults to USDC.
The SDK proxy is deployed at: https://sns-sdk-proxy.bonfida.workers.dev/
The CLI can be installed with:
cargo install --git https://github.com/Bonfida/sns-sdk.git sns
The CLI has the following commands:
sns resolve <domains>
sns domains <owners>
sns burn <domains> <keypair_path>
sns transfer <keypair_path> <new_owner_key> <domains>
sns lookup <domains>
sns reverse-lookup <key>
sns bridge <target_chain> <domain> <keypair_path>
sns register <keypair_path> <space> <domains>
For instance
$ sns resolve bonfida solana.sol coinbase
+------------+----------------------------------------------+----------------------------------------------------------------------------------+
| Domain | Owner | Explorer |
+------------+----------------------------------------------+----------------------------------------------------------------------------------+
| bonfida | HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA | https://explorer.solana.com/address/HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA |
+------------+----------------------------------------------+----------------------------------------------------------------------------------+
| solana.sol | 3Wnd5Df69KitZfUoPYZU438eFRNwGHkhLnSAWL65PxJX | https://explorer.solana.com/address/3Wnd5Df69KitZfUoPYZU438eFRNwGHkhLnSAWL65PxJX |
+------------+----------------------------------------------+----------------------------------------------------------------------------------+
| coinbase | 7sF2JumHpWiPjS3XtnQ8cKraTzzfcGSvQHcV3yTaPZ5E | https://explorer.solana.com/address/7sF2JumHpWiPjS3XtnQ8cKraTzzfcGSvQHcV3yTaPZ5E |
+------------+----------------------------------------------+----------------------------------------------------------------------------------+
Work in progress
Work in progress
Work in progress
This package contains a set of useful React hooks to help you build your perfect dApp. If you are interested in a hook that is not included in this package please open an issue to let us know!
npm i @bonfida/sns-react
yarn add @bonfida/sns-react
The following examples show how to resolve the domain bonfida.sol
:
- With the JS SDK
const connection = new Connection(clusterApiUrl("mainnet-beta"));
const owner = await resolve(connection, "bonfida");
expect(owner.toBase58()).toBe("HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA");
- With the Rust SDK
let client = RpcClient::new(std::env::var("RPC_URL").unwrap());
let res = resolve_owner(&client, "bonfida").await.unwrap();
assert_eq!(res, pubkey!("HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA"));
- With the CLI
$ sns resolve bonfida
+---------+----------------------------------------------+----------------------------------------------------------------------------------+
| Domain | Owner | Explorer |
+---------+----------------------------------------------+----------------------------------------------------------------------------------+
| bonfida | HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA | https://explorer.solana.com/address/HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA |
+---------+----------------------------------------------+----------------------------------------------------------------------------------+
- With the Cloudflare worker
GET https://sns-sdk-proxy.bonfida.workers.dev/resolve/bonfida
{ "s": "ok", "result": "HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA" }
- With the React SDK
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import { useDomainOwner, useDomainsForOwner } from "@bonfida/sns-react";
export const Example = () => {
const { connection } = useConnection();
const { publicKey, connected } = useWallet();
const { result } = useDomainOwner(connection, "bonfida");
// ...
};
Feature | Description | In progress | Completed | Bounty |
---|---|---|---|---|
Golang | Translate JS SDK into a robust, well-tested Golang SDK; high-quality code essential | β | β | β |
Python | Translate JS SDK into a robust, well-tested Python SDK; high-quality code essential | β | β | β |
Java | Translate JS SDK into a robust, well-tested Java SDK; high-quality code essential | β | β | β |
Swift | Translate JS SDK into a robust, well-tested Swift SDK; high-quality code essential | β | β | β |
If you have any questions or suggestions, feel free to open an issue or pull request, or simply contact us at @bonfida. We're always here for a good chat about Solana and the decentralized web!