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.address(domain, "eth").then(addr => console.log(addr));;

Hierarchy

  • Resolution

Index

Constructors

constructor

Properties

Readonly blockchain

blockchain: boolean
returns

true if weather resolution library is configured to use blockchain for resolution.

Methods

address

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

    async

    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

    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

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

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

    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

  • namehash(domain: string): string
  • throws

    ResolutionError with UnsupportedDomain error code if domain extension is unknown

    Parameters

    • domain: string

      domain name to be converted

    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

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

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