Skip to content

fix: resolve NaN chainId when networkId is a slug#288

Merged
AugustoL merged 1 commit intoopenscan-explorer:devfrom
josealoha666:fix/nan-chainid-in-address-displays
Mar 10, 2026
Merged

fix: resolve NaN chainId when networkId is a slug#288
AugustoL merged 1 commit intoopenscan-explorer:devfrom
josealoha666:fix/nan-chainid-in-address-displays

Conversation

@josealoha666
Copy link
Collaborator

Problem

The address page receives the route parameter (e.g. eth, base, arb) as networkId and passes it to display components. Those components then call Number(networkId) to get a numeric chainId.

Number('eth') returns NaN, causing metadata fetches to build URLs with NaN as the chainId:

GET tokens/evm/NaN/0xdac17f958d2ee523a2206206994597c13d831ec7.json → 404

This means Token Info shows empty on address pages when accessed via slug routes (which is the default).

Fix

  • Added resolveChainId() utility to networkResolver.ts that properly resolves slugs, numeric strings, and CAIP-2 networkIds to a numeric chainId
  • Updated Address component to use resolveChainId() and pass the resolved numeric chainId (as string) to all display components

Changes

  • src/utils/networkResolver.ts — new resolveChainId() function
  • src/components/pages/evm/address/index.tsx — use resolveChainId() instead of Number(networkId) || 1

@github-actions
Copy link

github-actions bot commented Mar 10, 2026

🚀 Preview: https://pr-288--openscan.netlify.app
📝 Commit: 785ffcda321c78610d8c9d2cfbf840e5de7b43ab

The address page passes the route parameter (e.g. 'eth') as networkId to
display components, which call Number(networkId). Number('eth') returns NaN,
causing metadata fetches to use NaN as chainId (404s).

Fix: use existing getNetworkById() + getChainIdFromNetwork() to properly
resolve the slug to a numeric chainId before passing to display components.
@josealoha666 josealoha666 force-pushed the fix/nan-chainid-in-address-displays branch from 516626e to 785ffcd Compare March 10, 2026 11:35
@josealoha666
Copy link
Collaborator Author

josealoha666 commented Mar 10, 2026

✅ Fix verified

Tested on /eth/address/0xdAC17F958D2ee523a2206206994597C13D831ec7 (USDT contract via slug route).

Before (dev): Token Info section showed empty Token: with no name, decimals, or supply — metadata URL had NaN as chainId → 404.

After (this fix):

  • Token: Tether USD (USDT)
  • Decimals: 6
  • Total Supply: 96,117,790,049 USDT
  • Contract Info: Checking Sourcify ✅
  • Value: Showing ETH price correctly ✅

Root cause: Number('eth')NaN. Fix uses existing getNetworkById() + getChainIdFromNetwork() to properly resolve slug → chainId.

@AugustoL AugustoL merged commit 932c68a into openscan-explorer:dev Mar 10, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants