Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Resolution

Blockchain domain Resolution library - Resolution.

example
import Resolution from '@unstoppabledomains/resolution';

let resolution = new Resolution({ blockchain: {
       ens: {
          url: "https://mainnet.infura.io/v3/12351245223",
          network: "mainnet"
       }
     }
  });

let domain = "brad.zil";
resolution.addr(domain, "eth").then(addr => console.log(addr));;

Hierarchy

  • Resolution

Index

Constructors

constructor

Methods

addr

  • addr(domain: string, currrencyTicker: string): Promise<string>
  • Resolves given domain name to a specific currency address if exists

    async
    throws

    ResolutionError if address is not found

    Parameters

    • domain: string

      domain name to be resolved

    • currrencyTicker: string

    Returns Promise<string>

    A promise that resolves in an address

address

  • address(domain: string, currencyTicker: string): Promise<string | null>
  • Resolves given domain name to a specific currency address if exists

    async
    deprecated

    since Resolution v1.7.0

    Parameters

    • domain: string

      domain name to be resolved

    • currencyTicker: string

      currency ticker like BTC, ETH, ZIL

    Returns Promise<string | null>

    A promise that resolves in an address or null

addressOrThrow

  • addressOrThrow(domain: string, currencyTicker: string): Promise<string>
  • throws

    ResolutionError if address is not found

    deprecated

    since v1.7.0 use Resolution#addr instead

    Parameters

    • domain: string

      domain name

    • currencyTicker: string

      currency ticker such as

      • ZIL
      • BTC
      • ETH

    Returns Promise<string>

    A specific currency address or throws an error

allRecords

  • Returns all record keys of the domain. This method is strongly unrecommended for production use due to lack of support for many ethereum service providers and low performance Method is not supported by ENS

    Parameters

    • domain: string

      domain name

    Returns Promise<CryptoRecords>

chatId

  • chatId(domain: string): Promise<string>
  • Resolve a chat id from the domain record

    throws

    ResolutionError

    Parameters

    • domain: string

      domain name to be resolved

    Returns Promise<string>

    A promise that resolves in chatId

chatPk

  • chatPk(domain: string): Promise<string>
  • Resolve a gundb public key from the domain record

    throws

    ResolutionError

    Parameters

    • domain: string

      domain name to be resolved

    Returns Promise<string>

    a promise that resolves in gundb public key

childhash

  • Parameters

    • parent: nodeHash

      namehash of a parent domain

    • label: string

      subdomain name

    • method: NamingServiceName

      "ENS", "CNS" or "ZNS"

    • Default value options: NamehashOptions = NamehashOptionsDefault

      formatting options

    Returns nodeHash

    a namehash of a subdomain with name label

dns

email

  • email(domain: string): Promise<string>
  • Resolves the ipfs email field from whois configurations

    throws

    ResolutionError

    Parameters

    • domain: string

      domain name

    Returns Promise<string>

    A Promise that resolves in an email address configured for this domain whois

httpUrl

  • httpUrl(domain: string): Promise<string>
  • Resolves the httpUrl attached to domain

    Parameters

    • domain: string

      domain name

    Returns Promise<string>

ipfsHash

  • ipfsHash(domain: string): Promise<string>

ipfsRedirect

  • ipfsRedirect(domain: string): Promise<string>
  • Resolves the ipfs redirect url for a supported domain records

    deprecated

    since v1.0.15 use Resolution#httpUrl instead

    throws

    ResolutionError

    Parameters

    • domain: string

      domain name

    Returns Promise<string>

    A Promise that resolves in redirect url

isSupportedDomain

  • isSupportedDomain(domain: string): boolean
  • Checks if the domain name is valid according to naming service rules for valid domain names. Example: ENS doesn't allow domains that start from '-' symbol.

    Parameters

    • domain: string

      domain name to be checked

    Returns boolean

isSupportedDomainInNetwork

  • isSupportedDomainInNetwork(domain: string): boolean
  • Checks if the domain is supported by the specified network as well as if it is in valid format

    Parameters

    • domain: string

      domain name to be checked

    Returns boolean

isValidHash

  • isValidHash(domain: string, hash: string): boolean
  • Checks weather the domain name matches the hash

    Parameters

    • domain: string

      domain name to check againt

    • hash: string

      hash obtained from the blockchain

    Returns boolean

namehash

  • throws

    ResolutionError with UnsupportedDomain error code if domain extension is unknown

    Parameters

    • domain: string

      domain name to be converted

    • Default value options: NamehashOptions = NamehashOptionsDefault

      formatting options

    Returns string

    Produces a namehash from supported naming service in hex format with 0x prefix. Corresponds to ERC721 token id in case of Ethereum based naming service like ENS or CNS.

owner

  • owner(domain: string): Promise<string | null>
  • Parameters

    • domain: string

      domain name

    Returns Promise<string | null>

    An owner address of the domain

record

  • record(domain: string, recordKey: string): Promise<string>
  • Parameters

    • domain: string

      domain name

    • recordKey: string

      a name of a record to be resolved

    Returns Promise<string>

    A record value promise for a given record name

records

  • records(domain: string, keys: string[]): Promise<CryptoRecords>
  • Parameters

    • domain: string

      domain name

    • keys: string[]

      Array of record keys to be resolved

    Returns Promise<CryptoRecords>

    A Promise with key-value mapping of domain records

resolve

resolver

  • resolver(domain: string): Promise<string>
  • Parameters

    • domain: string

      domain to look for

    Returns Promise<string>

    the resolver address for a specific domain

reverse

  • reverse(address: string, currencyTicker: string): Promise<string | null>
  • This method is only for ens at the moment. Reverse the ens address to a ens registered domain name

    async

    Parameters

    • address: string

      address you wish to reverse

    • currencyTicker: string

      currency ticker like BTC, ETH, ZIL

    Returns Promise<string | null>

    Domain name attached to this address

serviceName

twitter

  • twitter(domain: string): Promise<string>
  • Resolves given domain name to a verified twitter handle

    async
    throws

    ResolutionError if twitter is not found

    Parameters

    • domain: string

      domain name to be resolved

    Returns Promise<string>

    A promise that resolves in a verified twitter handle

usdt

  • Resolves given domain name to a specific USDT chain address if exists

    async
    throws

    ResolutionError when domain is not from ZNS or CNS or such address doesn't exist

    Parameters

    • domain: string

      domain name to be resolved

    • version: TickerVersion

      chain version to look for such as ERC20, TRON, EOS, OMNI

    Returns Promise<string>

    A promise that resolves in an address

Static fromEip1193Provider

Static fromEthersProvider

Static fromWeb3Version0Provider

Static fromWeb3Version1Provider

Static infura

  • infura(infura: string, network?: string): Resolution
  • Creates a resolution with configured infura id for ens and cns

    Parameters

    • infura: string

      infura project id

    • Default value network: string = "mainnet"

      ethereum network name

    Returns Resolution

Generated using TypeDoc