Skip to main content

Overview

The SNS SDK is a JavaScript/TypeScript library for integrating with Sonic Name Service, the decentralized domain name system for the Sonic blockchain.

Key Features

Simple API

Unified interface for domain resolution and management

TypeScript Support

Full TypeScript support with comprehensive type definitions

Batch Operations

Resolve multiple domains efficiently in a single call

Error Handling

Detailed error handling with clear messages
Additional features:
  • Built-in caching and retry mechanisms
  • Support for address, content, and text records

Installation

npm install sns-sdk ethers@^6.0.0
Requires ethers.js v6 - If you’re using ethers v5, you’ll need to upgrade.

Core Functionality

Resolution Methods

  • resolve() - Convert domain names to Ethereum addresses
  • reverseResolve() - Convert addresses back to domain names
  • getContent() - Retrieve content hashes
  • getText() - Get text records by key

Batch Operations

  • resolveBatch() - Resolve multiple domains simultaneously
  • reverseResolveBatch() - Reverse resolve multiple addresses

Domain Management

  • isAvailable() - Check registration availability
  • getPrice() - Calculate registration costs
  • register() - Register new domains
  • renew() - Extend domain registrations

Record Management

  • setAddress() - Update address records
  • setText() - Set text records (email, social media, etc.)
  • setContent() - Update content hashes

Utilities

  • getDomainInfo() - Retrieve comprehensive domain data
  • validateDomain() - Validate domain names per SNS rules

Pricing Structure

Base Rates (per year)

Domain LengthPrice (S)
3 characters15 S
4 characters10 S
5 characters7.5 S
6+ characters5 S

Multi-Year Discounts

YearsDiscount
2 years5%
3 years10%
4 years15%
5 years20%

Contract Addresses (Sonic Mainnet)

const contracts = {
  registry: '0x3D9D5ACc7dBACf1662Bc6D1ea8479F88B90b3cfb',
  registrar: '0xc50DBB6F0BAab19C6D0473B225f7F58e4a2d440b',
  resolver: '0x90DB11399F3577BeFbF5B8E094BcaD35DA348Fc9'
};

Support & Community