dAppBooster
    Preparing search index...

    Function getExplorerLink

    • Returns the explorer link for a given chain, hash or address.

      Generates a blockchain explorer URL based on the provided parameters. The function determines whether the input is an address or transaction hash and constructs the appropriate URL path.

      Parameters

      • params: GetExplorerUrlParams

        The parameters for generating the explorer link

        • chain: Chain
        • OptionalexplorerUrl?: string
        • hashOrAddress: Hash | Address

      Returns string

      The complete explorer URL for the given hash or address

      Throws an error if the provided hash or address is invalid

      Throws an error if no explorer URL is available (neither explorerUrl nor chain.blockExplorers)

      const addressLink = getExplorerLink({
      chain: mainnet,
      hashOrAddress: '0x71C7656EC7ab88b098defB751B7401B5f6d8976F'
      });
      // Returns: "https://etherscan.io/address/0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
      // Get link for a transaction hash with custom explorer
      const txLink = getExplorerLink({
      chain: optimism,
      hashOrAddress: '0x123...abc',
      explorerUrl: 'https://optimistic.etherscan.io'
      });
      // Returns: "https://optimistic.etherscan.io/tx/0x123...abc"