Typescript SDK
Last updated
Last updated
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.
MNS SDK leverages the package for standardized blockchain network identification, making it easy to work with multiple chains using a consistent format.
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
First, install both the SDK and chain-agnostic-utils:
Here's a quick example to get you started:
You can customize the SDK behavior during initialization:
The SDK supports both forward and reverse resolution:
Forward Resolution (Address to Name)
Reverse Resolution (Name to Address)
For better performance when working with multiple identities:
You can use wildcard CAIP2 IDs to query across networks:
The SDK provides structured error handling:
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>
Use Network Constants Always use the NETWORKS
constant from chain-agnostic-utils for consistent network identification.
Batch Operations When working with multiple identities, prefer batch operations over individual queries.
Error Handling Implement proper error handling using the SnowstormError
class.
Caching Considerations The SDK includes built-in caching. Consider cache duration when implementing time-sensitive features.
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.
If you're experiencing timeout issues, adjust the timeout in the SDK configuration:
Be aware of batch operation limits when using getIdentityNames
or getIdentityAddresses
. It's recommended to keep batch sizes reasonable.
If you have any questions or need support:
Check the Common Issues section
Review the CAIP-2 documentation
Submit an issue on our GitHub repository
CAIP-2 Implementation