Skip to main content

Method Signature

align.blockchain.providers.getNetworkInfo(
  network: Network
): NetworkConfig

Parameters

network
string
required
Network identifier

Returns

chainId
number
Network chain ID
name
string
Network name
rpcUrl
string
Default RPC URL
nativeCurrency
object
Currency info (name, symbol, decimals)
blockExplorer
string
Block explorer URL

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

const config = align.blockchain.providers.getNetworkInfo("polygon");

console.log(`Chain ID: ${config.chainId}`);        // 137
console.log(`Name: ${config.name}`);               // Polygon
console.log(`Currency: ${config.nativeCurrency.symbol}`); // MATIC
console.log(`Explorer: ${config.blockExplorer}`);  // https://polygonscan.com
function getExplorerLink(txHash: string, network: string) {
  const config = align.blockchain.providers.getNetworkInfo(network);
  return `${config.blockExplorer}/tx/${txHash}`;
}

const link = getExplorerLink("0x123...", "polygon");
// https://polygonscan.com/tx/0x123...

Supported Networks

NetworkChain IDCurrency
ethereum1ETH
polygon137MATIC
base8453ETH
arbitrum42161ETH
optimism10ETH