Skip to content

getExplorerUrl

Generates a URL to a transaction, address, or CTAG token on the block explorer for a given chain. This function is mainly meant for internal use, generating URLs for the ETS Explorer.

Usage

import { getExplorerUrl } from '@ethereum-tag-service/contracts/utils'
 
const url = getExplorerUrl('84532', 'tx', '0x123...')
// @log: Output: Returns block explorer URL for the transaction
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 31 - Cannot find module '@ethereum-tag-service/contracts/utils' or its corresponding type declarations.

Returns

string

A string representing the full URL to the block explorer.

Parameters

chainId

  • Type: SupportedChainId
  • Description: The ID of the chain. Must be an ETS supported chain ID.

type

  • Type: "tx" | "nft" | "address" | "token"
  • Default: "tx"
  • Description: The type of URL to generate. When type is "nft" or "token", hash must be CTAG token ID.

hash

  • Type: string
  • Optional: Yes
  • Description: Hash or identifier for the transaction, address, or token

Examples

import { getExplorerUrl } from '@ethereum-tag-service/contracts/utils'
 
// Get transaction URL on Arbitrum Sepolia
const txUrl = getExplorerUrl('84532', 'tx', '0x123...')
// @log: Output: https://sepolia.basescan.org/tx/0x123...
 
// Get CTAG token URL on Base Sepolia
const nftUrl = getExplorerUrl('84532', 'nft', '123456...')
// @log: Output: https://sepolia.basescan.org/nft/0x0300c9f3FE108bf683D03005B6B66EA1db74007A/123456...
 
// Get address URL on Arbitrum Sepolia
const addressUrl = getExplorerUrl('84532', 'address', '0x456...')
// @log: Output: https://sepolia.basescan.org/address/0x456...
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 31 - Cannot find module '@ethereum-tag-service/contracts/utils' or its corresponding type declarations.