Skip to content

feat: link tokenId in ERC-721 Transfer events to the token page#610

Merged
davidecarpini merged 2 commits into
mainfrom
feat/tx-event-nft-link
Jul 14, 2026
Merged

feat: link tokenId in ERC-721 Transfer events to the token page#610
davidecarpini merged 2 commits into
mainfrom
feat/tx-event-nft-link

Conversation

@Agilulfo1820

@Agilulfo1820 Agilulfo1820 commented Jul 14, 2026

Copy link
Copy Markdown
Member

What & why

Follow-up to #609. In a transaction's decoded events, an ERC-721 Transfer now renders its tokenId as a link to /nft/{contract}/{tokenId}, so you can navigate from a transfer straight to the token page. Closes the last gap in the NFT ⇄ contract ⇄ transaction navigation loop.

How

  • ERC-721 vs ERC-20 is decided from the decoded ABI alone: the ERC-721 Transfer tokenId is indexed (3 indexed params), whereas the ERC-20 value is not. No extra chain call.
  • ParamRows (shared by input-data and event rendering) gains an optional per-row href; when present the value renders as a link. Only the tokenId row of a detected ERC-721 Transfer gets one.
  • The link target is network-aware (useNetworkAwareHref) and built from the event's emitter address + tokenId.

Notes

  • The tokenId is taken from the raw decoded arg (a bigint → decimal string), matching the NFT page's tokenId route validation (/^\d+$/).
  • Scoped to ERC-721 Transfer. ERC-1155 (TransferSingle/TransferBatch) is out of scope — its ids aren't indexed and the token page is ERC-721.
image

Validation

New unit test covers ERC-721 vs ERC-20 vs non-Transfer discrimination. Full suite (238 tests), ts-check, lint, knip, prettier all pass.

In a transaction's decoded events, an ERC-721 `Transfer` now renders its
tokenId as a link to /nft/{contract}/{tokenId}, so you can navigate from a
transfer straight to the token.

ERC-721 is told apart from ERC-20 purely from the decoded ABI: the ERC-721
`Transfer` tokenId is indexed (3 indexed params) whereas the ERC-20 `value`
is not — no extra chain call needed. ParamRows gains an optional per-row
`href` so a value can render as a link; the emitter address + tokenId form
the network-aware target.

Adds a unit test covering ERC-721 vs ERC-20 vs non-Transfer discrimination.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Agilulfo1820 Agilulfo1820 added the increment:minor PR adds functionality in a backwards compatible manner label Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Block explorer – Preview

Name Status Preview Updated (UTC)
block-explorer-preview 🗑️ Destroyed (c6ff7b2) Preview deleted 2026-07-14 13:19:25

Preview environment destroyed after PR was closed

ERC-20 and ERC-721 Transfer share one signature hash, differing only in
indexed layout. Without a verified ABI the fallback decoders (b32/selector)
picked the ERC-20 shape, reading the tokenId from the empty data as `value`
=> "N/A", so the tokenId (and thus the token link) never appeared.

A Transfer log with 4 topics is unambiguously ERC-721 (from/to/tokenId all
indexed), so decode it deterministically with the ERC-721 fragment before
the ambiguous fallbacks. This makes the tokenId render (and become a link).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@davidecarpini davidecarpini merged commit 71efa25 into main Jul 14, 2026
15 checks passed
@davidecarpini davidecarpini deleted the feat/tx-event-nft-link branch July 14, 2026 13:18
@davidecarpini davidecarpini deployed to preview-pr-610 July 14, 2026 13:18 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

increment:minor PR adds functionality in a backwards compatible manner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants