@xns/xnsjs
v1.0.3
Published
XNS javascript library for domain name resolution
Downloads
11
Readme
XNS JavaScript/TypeScript SDK
This is the official JavaScript/TypeScript SDK for interacting with the XRP Name service. XNS is a domain name resolution system for the XRPL ledger.
Features
- Resolve XRPL address given an XNS domain
- Resolve XNS domain given an XRPL address
- Verify ownership of the domain/address association through XRPL NFT ownership.
By cross-referencing XNS data against the XRP Ledger, accurate name resolution is ensured and trust against a centralized authority minimized.
Installation
npm install @xns/xnsjs
Usage
import { Xns } from '@xns/xnsjs';
import { Client } from 'xrpl';
async function main() {
// Create an XRPL Client instance
const client = new Client('wss://xrplcluster.com'); // Use the appropriate XRPL server URL
await client.connect();
// Initialize Xns with the client
const xns = new Xns(client);
// Resolve address given a domain
const resolvedAddress = await xns.resolveDomain('example-domain');
console.log(`Address associated with domain 'example-domain':`, resolvedAddress);
// Resolve domain given an address
const resolvedDomain = await xns.resolveAddress('rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(`Domain associated with address 'rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX':`, resolvedDomain);
// Disconnect from the XRPL server
await client.disconnect();
}
main();
Replace example-domain
and rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
with the domain and address you want to resolve.
Individual Functions
async resolveDomain(domain: string): Promise<string | null>
Resolve the XRPL address associated with the given domain. Returns the address if found and NFT ownership is verified.
domain
: The domain name to resolve.
async resolveAddress(address: string): Promise<string | null>
Resolve the domain name associated with the given XRPL address. Returns the domain name if found and NFT ownership is verified.
Contributing
If you have any issues, questions, or suggestions, please open an issue on the repository.
License
This project is licensed under the MIT License.