Skip to main content

EVM explorer

EvmExplorer provides methods for EVM-compatible networks like Ethereum. It queries data through the ChainGate API, offering richer responses than raw JSON-RPC (token balances, transaction history, network status, etc.).

import { ChainGate } from 'chaingate'

const cg = new ChainGate({ apiKey: 'your-api-key' })
const eth = cg.explore(cg.networks.ethereum)

Available methods

MethodDescription
getAddressBalance(address)Confirmed and unconfirmed balances
getAddressHistory(address, page?)Paginated transaction history
getAddressTokenBalances(address)ERC-20/ERC-721/ERC-1155 token balances
getAddressTransactionCount(address)Transaction count (nonce)
getTransactionDetails(txId)Full transaction details
getLatestBlock()Latest block header
getBlockByHeight(height)Fetch block by height
getBlockByHash(hash)Fetch block by hash
estimateGas(params)Estimate gas for a transaction
getFeeRate()Current gas prices by tier (low/normal/high/maximum)
getNetworkStatus()Real-time metrics: block time, EIP-1559 fees, congestion, costs
broadcastTransaction(rawTx)Broadcast a signed raw transaction
callSmartContract(params)Read-only smart contract call
getTokenData(contractAddress)Token metadata (name, symbol, decimals)
getTokenLogoUrl(contractAddress)Token logo URL
getNftMetadata(contractAddress, tokenId)NFT metadata
getNetworkLogoUrl()Network logo URL

Example

const eth = cg.explore(cg.networks.ethereum)

// Balance
const balance = await eth.getAddressBalance('0x...')
console.log('ETH balance:', balance.confirmed.base(), balance.confirmed.symbol)

// Token balances
const tokens = await eth.getAddressTokenBalances('0x...')
for (const token of tokens) {
console.log(token.symbol, token.base())
}

// Network status
const status = await eth.getNetworkStatus()
console.log('Gas price:', status.baseFeeGwei, 'gwei')

// Read a smart contract
const result = await eth.callSmartContract({
to: '0xContractAddress...',
data: '0xEncodedCallData...',
})

// Token metadata
const tokenData = await eth.getTokenData('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')
console.log(tokenData.name) // 'USD Coin'
console.log(tokenData.symbol) // 'USDC'