Typescript SDK

MNS SDK Guide

The MNS SDK provides a powerful interface for interacting with the MNS. This TypeScript SDK enables seamless resolution between blockchain addresses and human-readable names across different chains.

circle-info

This SDK uses CAIP-2 standard for network identification. Make sure to familiarize yourself with CAIP-2 concepts before proceeding.

Overview

MNS SDK leverages the @snowballmoney/chain-agnostic-utilsarrow-up-right package for standardized blockchain network identification, making it easy to work with multiple chains using a consistent format.

Key Features

  • Full TypeScript support with comprehensive type definitions

  • Cross-chain identity resolution using CAIP-2 standard

  • Seamless integration with chain-agnostic-utils

  • Support for batch operations

  • Built-in error handling

  • Automatic caching

  • Standardized network identification

Getting Started

Installation

First, install both the SDK and chain-agnostic-utils:

Basic Usage

Here's a quick example to get you started:

Core Concepts

SDK Configuration

You can customize the SDK behavior during initialization:

Identity Resolution

The SDK supports both forward and reverse resolution:

Forward Resolution (Address to Name)

Reverse Resolution (Name to Address)

Batch Operations

For better performance when working with multiple identities:

Cross-Chain Resolution

You can use wildcard CAIP2 IDs to query across networks:

Error Handling

The SDK provides structured error handling:

API Reference

Methods

Identity Resolution

  • getIdentityName(address: string, caip2Id: CAIP2ID): Promise<IdentityName>

  • getIdentityAddress(name: string, caip2Id: CAIP2ID): Promise<IdentityAddress>

  • getIdentityMetadata(name: string): Promise<IdentityMetadata>

Batch Operations

  • getIdentityNames(params: GetIdentityNamesByAddressesRequest): Promise<BatchIdentityNames>

  • getIdentityAddresses(params: GetIdentityAddressesByNamesRequest): Promise<BatchIdentityAddresses>

Type Definitions

Best Practices

  1. Use Network Constants Always use the NETWORKS constant from chain-agnostic-utils for consistent network identification.

  2. Batch Operations When working with multiple identities, prefer batch operations over individual queries.

  3. Error Handling Implement proper error handling using the SnowstormError class.

  4. Caching Considerations The SDK includes built-in caching. Consider cache duration when implementing time-sensitive features.

Common Issues and Solutions

Network Identification

If you're experiencing issues with network identification, make sure you're using the correct CAIP2 ID format. Refer to the CAIP-2 documentation for details.

Timeout Errors

If you're experiencing timeout issues, adjust the timeout in the SDK configuration:

Batch Operation Limits

Be aware of batch operation limits when using getIdentityNames or getIdentityAddresses. It's recommended to keep batch sizes reasonable.

Need Help?

If you have any questions or need support:

  1. Check the Common Issues section

  2. Review the CAIP-2 documentation

  3. Submit an issue on our GitHub repository

Last updated