solana_kit_sns

pub package docs website CI coverage

Solana Name Service (.sol domains) client for the Solana Kit Dart SDK.

What you get

  • Domain hashinggetHashedName applies the protocol's exact SPL Name Service hash prefix (plus a dependency-free SHA-256), matching getHashedNameSync in the SNS TypeScript SDK
  • Domain key derivationfindDomainKey derives top-level domains, subdomains, and V1/V2 record accounts with the seed order [hash, class, parent]
  • Record keysfindRecordV1Address / findRecordV2Address for all 28 record identifiers (url, SOL, twitter, IPFS, ETH, …)
  • State codecsgetNameRegistryStateCodec parses the 96-byte name-registry header (parentName / owner / class + trailing data); getSnsRecordHeaderCodec and SnsRecordV2 parse SNS-IP 1 V2 record payloads, including staleness and Right-of-Association identifiers
  • Reverse lookupsfindReverseAddress (plain and subdomain variants) and reverse-value (de)serialization
  • Record content — encode/decode of UTF-8, Solana address, and 0x-prefixed EVM record content

Installation

Installation

Install the package directly:

dependencies:
  "solana_kit_sns": ^

If your app uses several Solana Kit packages together, you can also depend on the umbrella package instead:

dart pub add solana_kit

Inside this monorepo, Dart workspace resolution uses the local package automatically.

Documentation

For architecture notes, getting-started guides, and cross-package examples, start with the workspace docs site and then drill down into the package README and API reference.

Usage

Resolve a .sol domain key

Domain keys handle top-level domains, subdomains, and V1/V2 records with the same derivation the official SDK uses.

import 'package:solana_kit_sns/solana_kit_sns.dart';

Future<void> main() async {
  // Domain-key derivation expects the TLD-trimmed name; `.sol` is implied.
  final domainKey = await findDomainKey('mysite');
  print(domainKey);
}

Feed the derived keys to getNameRegistryStateCodec or the record codecs when you need parsed owner, class, and content data.

Key APIs

API Description
findDomainKey(domain, {record}) Derives a domain, subdomain, or V1/V2 record address from a TLD-trimmed name
findNameAccountKey(hashed, {classAddress, parentAddress}) Derives a name-account PDA from a hash with [hash, class, parent] seeds
getHashedName(name) / sha256(data) SNS name hashing with the SPL Name Service prefix
findRecordV1Address / findRecordV2Address V1 and SNS-IP 1 V2 record account derivation
getSnsRecordHeaderCodec / SnsRecordV2.deserialize V2 record header and payload decoding
decodeRecordContent / encodeRecordContent UTF-8, Solana, and EVM record content
getNameRegistryStateCodec 96-byte name-registry header + data parsing
findReverseAddress / findReverseAddressForDomain Reverse-lookup account derivation
decodeReverseValue / encodeReverseValue Reverse-lookup value (de)serialization
nameProgramAddressObject, snsRootDomainAddressObject, … Protocol address constants from the TS SDK

Upstream reference

Constants, hashing, and derivation algorithms mirror SolanaNameService/sns-sdk (js-kit plus the getSnsDomainKeySync helpers and RecordState / RegistryState codecs of js), and the V2 record derivation matches the getRecordKey primitive published in @bonfida/sns-records. Derivation vectors in the test suite are the TypeScript SDK's own derivation.test.ts expectations, cross-computed with @solana/web3.js.

Scope

This package covers the offline side of the protocol: address derivation, account-codec parsing, and record-content (de)serialization. It currently does not include:

  • RPC access or account fetching (use solana_kit_rpc and feed raw account data into the codecs here)
  • Name-program or SNS-registrar instruction builders
  • Signature verification for V2 records (verifyStaleness / verifyRightOfAssociation)
  • bech32 (Injective), punycode (CNAME/TXT), and raw IP (A / AAAA) content decoding, and V1 record payload parsing

Libraries

solana_kit_sns
Solana Name Service (SNS) client for the Solana Kit Dart SDK.