dAppBooster
    Preparing search index...

    Function detectEnsName

    • Attempts to resolve an ENS name to its corresponding Ethereum address.

      This function takes an ENS name (e.g., "vitalik.eth"), normalizes it according to ENS standards, and attempts to resolve it to an Ethereum address using the provided public client. It returns both the resolved address and a type classification.

      Parameters

      • publicClient: {}

        The Viem public client instance

      • ensName: string

        The ENS name to resolve

      Returns Promise<{ data: HashData; type: HashType }>

      Object containing the type ('ENS' if valid, null if invalid) and data (resolved address if valid, null if invalid)

      // For a valid ENS name
      const client = createPublicClientInstance(mainnet);
      const result = await detectEnsName(client, 'vitalik.eth');
      console.log(result);
      // { type: 'ENS', data: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' }
      // For an invalid ENS name
      const result = await detectEnsName(client, 'nonexistent-name.eth');
      console.log(result);
      // { type: null, data: null }