Example

Using DotNames SDK in Typescript

Here's an example of how to use the DotNames in your project:

import { DotNamesSDK } from "@dotnames/dotnames-js/dist/src/index";
import { SupportedNS } from "@dotnames/dotnames-js/dist/src/types";

const DotNamesSDK = require('@dotnames/dotnames-js'); // Import the SoW SDK

const dotnames = new DotNamesSDK();

dotnames
  .resolveDomainNameFromAddress("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", SupportedNs.ENS)
  .then((res) => {
    console.log(`Resolved Domain Name: ${res}`);
  })
  .catch((err) => {
    console.error(`Error: ${err}`);
  });

dotnames
  .resolveAddressFromDomainName("vitalik.eth")
  .then((res) => {
    console.log(`Resolved Address: ${res}`);
  })
  .catch((err) => {
    console.error(`Error: ${err}`);
  });

dotnames
	.getRecords('homecakes.crypto', SupportedNS.UnstoppableDomains).then((records: any) => {
		console.log(records);
    })
		.catch((err) => {
    console.error(`Error: ${err}`);
  });

Response

Resolved Domain Name: vitalik.eth
Resolved Address: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
{
  text: {},
  address: '0xe7474D07fD2FA286e7e0aa23cd107F8379085037',
  contentHash: 'QmQ38zzQHVfqMoLWq2VeiMLHHYki9XktzXxLYTWXt8cydu'
}