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: {
       uns: {
          url: "https://mainnet.infura.io/v3/<infura_api_key>",
          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, ticker: string): Promise<string | undefined>
  • 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

    • ticker: string

      currency ticker like BTC, ETH, ZIL

    Returns Promise<string | undefined>

    A promise that resolves in an address

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

    deprecated

    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: string

      namehash of a parent domain

    • label: string

      subdomain name

    • namingService: NamingServiceName

      "ENS", "UNS" or "ZNS" (uses keccak256 or sha256 algorithm respectively)

    • Default value options: NamehashOptions = NamehashOptionsDefault

      formatting options

    Returns string

    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

getAddress

  • getAddress(domain: string, network: string, token: string): Promise<string | null>
  • Parameters

    • domain: string

      domain name

    • network: string

      network name

    • token: string

      token ticker

    Returns Promise<string | null>

    An owner address of the domain

getEnsConfig

getZnsConfig

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>

isAvailable

  • isAvailable(domain: string): Promise<boolean>
  • Parameters

    • domain: string

      domain name

    Returns Promise<boolean>

    A Promise of whether or not the domain is available

isRegistered

  • isRegistered(domain: string): Promise<boolean>
  • Parameters

    • domain: string

      domain name

    Returns Promise<boolean>

    A Promise of whether or not the domain belongs to a wallet

isSupportedDomain

  • isSupportedDomain(domain: string): Promise<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 Promise<boolean>

isValidHash

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

    Parameters

    • domain: string

      domain name to check against

    • hash: string

      hash obtained from the blockchain

    • namingService: NamingServiceName

      "UNS" or "ZNS" (uses keccak256 or sha256 algorithm respectively)

    Returns boolean

locations

  • locations(domains: string[]): Promise<Locations>
  • Retrieves address of registry contract used for domain

    Parameters

    • domains: string[]

      domain name

    Returns Promise<Locations>

    Promise - A map of domain name and Location (a set of attributes like blockchain,

multiChainAddr

  • multiChainAddr(domain: string, ticker: string, chain: string): Promise<string | undefined>
  • Read multi-chain currency address if exists

    async
    throws

    ResolutionError if address is not found

    Parameters

    • domain: string

      domain name to be resolved

    • ticker: string

      currency ticker (USDT, FTM, etc.)

    • chain: string

      chain version, usually means blockchain ( ERC20, BEP2, OMNI, etc. )

    Returns Promise<string | undefined>

    A promise that resolves in an adress

namehash

  • throws

    ResolutionError with UnsupportedDomain error code if domain extension is unknown

    Parameters

    • domain: string

      domain name to be converted

    • namingService: NamingServiceName

      "UNS" or "ZNS" (uses keccak256 or sha256 algorithm respectively)

    • 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 UNS.

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

registryAddress

  • registryAddress(domain: string): Promise<string>
  • Retrieves address of registry contract used for domain

    Parameters

    • domain: string

      domain name

    Returns Promise<string>

    Registry contract address

resolver

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

    • domain: string

      domain to look for

    Returns Promise<string>

    the resolver address for a specific domain

reverse

  • Returns the domain that is the primary resolution of the provided address

    Parameters

    Returns Promise<string | null>

    Promise - domain URL that is the primary resolution of the provided address

reverseTokenId

  • Returns the token ID that is the primary resolution of the provided address

    Parameters

    Returns Promise<string | null>

    Promise - token ID that is the primary resolution of the provided address

tokenURI

  • tokenURI(domain: string): Promise<string>
  • Retrieves the tokenURI from the registry smart contract.

    Parameters

    • domain: string

      domain name

    Returns Promise<string>

    the ERC721Metadata#tokenURI contract method result

tokenURIMetadata

  • Retrieves the data from the endpoint provided by tokenURI from the registry smart contract.

    Parameters

    • domain: string

      domain name

    Returns Promise<TokenUriMetadata>

    the JSON response of the token URI endpoint

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

unhash

  • Retrieves the domain name from tokenId by parsing registry smart contract event logs.

    throws

    {ResolutionError} if returned domain name doesn't match the original namehash.

    Parameters

    • hash: string

      domain name hash or label hash.

    • service: NamingServiceName

      name service which is used for lookup.

    Returns Promise<string>

    the domain name retrieved from token metadata.

Static alchemy

  • alchemy(alchemy: string, networks?: undefined | { uns?: undefined | { locations: { Layer1: { network: UnsSupportedNetwork }; Layer2: { network: UnsSupportedNetwork } } } }): Resolution
  • Creates a resolution with configured alchemy API keys for uns

    Parameters

    • alchemy: string

      alchemy API keys

    • Optional networks: undefined | { uns?: undefined | { locations: { Layer1: { network: UnsSupportedNetwork }; Layer2: { network: UnsSupportedNetwork } } } }

      an optional object that describes what network to use when connecting UNS default is mainnet

    Returns Resolution

Static autoNetwork

  • AutoConfigure the blockchain network between different testnets for ENS and UNS We make a "net_version" JSON RPC call to the blockchain either via url or with the help of given provider.

    Parameters

    Returns Promise<Resolution>

    configured Resolution object

Static fromEthereumEip1193Provider

  • fromEthereumEip1193Provider(networks: { ens?: undefined | { network?: undefined | string; provider: Provider }; uns?: undefined | { locations: { Layer1: { network?: undefined | string; provider: Provider }; Layer2: { network?: undefined | string; provider: Provider } } } }): Resolution
  • Creates a resolution instance with configured provider

    see

    https://eips.ethereum.org/EIPS/eip-1193

    Parameters

    • networks: { ens?: undefined | { network?: undefined | string; provider: Provider }; uns?: undefined | { locations: { Layer1: { network?: undefined | string; provider: Provider }; Layer2: { network?: undefined | string; provider: Provider } } } }

      an object that describes what network to use when connecting UNS and ENS default is mainnet

      • Optional ens?: undefined | { network?: undefined | string; provider: Provider }
      • Optional uns?: undefined | { locations: { Layer1: { network?: undefined | string; provider: Provider }; Layer2: { network?: undefined | string; provider: Provider } } }

    Returns Resolution

Static fromEthersProvider

Static fromResolutionProvider

  • fromResolutionProvider(networks: { ens?: undefined | { network: string; provider: Provider }; uns?: undefined | { locations: { Layer1: { network: string; provider: Provider }; Layer2: { network: string; provider: Provider } } }; zns?: undefined | { network: string; provider: Provider } }): Resolution
  • Creates a resolution instance with configured provider

    see

    https://eips.ethereum.org/EIPS/eip-1193

    Parameters

    • networks: { ens?: undefined | { network: string; provider: Provider }; uns?: undefined | { locations: { Layer1: { network: string; provider: Provider }; Layer2: { network: string; provider: Provider } } }; zns?: undefined | { network: string; provider: Provider } }

      an object that describes what network to use when connecting UNS, ENS, or ZNS default is mainnet

      • Optional ens?: undefined | { network: string; provider: Provider }
      • Optional uns?: undefined | { locations: { Layer1: { network: string; provider: Provider }; Layer2: { network: string; provider: Provider } } }
      • Optional zns?: undefined | { network: string; provider: Provider }

    Returns Resolution

Static fromWeb3Version0Provider

Static fromWeb3Version1Provider

Static fromZilliqaProvider

  • fromZilliqaProvider(provider: Provider, networks?: undefined | { zns?: undefined | { network: string } }): Resolution

Static infura

  • infura(infura: string, networks?: undefined | { ens?: undefined | { network: string }; uns?: undefined | { locations: { Layer1: { network: UnsSupportedNetwork }; Layer2: { network: UnsSupportedNetwork } } } }): Resolution
  • Creates a resolution with configured infura id for ens and uns

    Parameters

    • infura: string

      infura project id

    • Optional networks: undefined | { ens?: undefined | { network: string }; uns?: undefined | { locations: { Layer1: { network: UnsSupportedNetwork }; Layer2: { network: UnsSupportedNetwork } } } }

      an optional object that describes what network to use when connecting ENS or UNS default is mainnet

    Returns Resolution

Generated using TypeDoc