Skip to content

feat: add Blockscout platform, support all 700+ Blockscout chains, shared explorer utilities.#665

Open
thevolcanomanishere wants to merge 9 commits intocrytic:masterfrom
thevolcanomanishere:feat/blockscout-platform
Open

feat: add Blockscout platform, support all 700+ Blockscout chains, shared explorer utilities.#665
thevolcanomanishere wants to merge 9 commits intocrytic:masterfrom
thevolcanomanishere:feat/blockscout-platform

Conversation

@thevolcanomanishere
Copy link

@thevolcanomanishere thevolcanomanishere commented Mar 6, 2026

Summary

  • New Blockscout platform (platform/blockscout.py) — fetches verified contracts from Blockscout-based block explorers using the blockscout-<chainid>:0xAddress target syntax. Supports all 700+ Blockscout-indexed chains via dynamic discovery from the Blockscout chain directory API, with hardcoded overrides for chains not yet in the directory (e.g. Flow, Plume).
  • Custom Blockscout URL--blockscout-url flag for targeting self-hosted or unlisted Blockscout instances.
  • Sourcify fallback — Blockscout compilation tries Sourcify first for richer metadata, falling back to Blockscout's API transparently.
  • Shared explorer utilities (platform/explorer_utils.py) — extracts helpers previously private to etherscan.py (handle_bytecode, handle_single_file, handle_multiple_files, sanitize_remappings, convert_version) into a common module reused by Etherscan, Sourcify, and Blockscout.
  • Blockscout API normalisation — translates Blockscout's response format (different field names, "true"/"false" vs "1"/"0", separate AdditionalSources array) into Etherscan-compatible conventions so the existing compilation pipeline works unchanged.
  • Generic explorer CLI flags — renamed --etherscan-only-source-code, --etherscan-only-bytecode, --etherscan-export-directory to --explorer-* equivalents so they apply to all block explorer platforms.
  • Type.BLOCKSCOUT = 14 added to the platform type enum.
  • Proxy detection — detects proxy contracts and tracks implementation addresses.
  • CI coverage — Blockscout tests across multiple chains in scripts/ci_test_blockscout.sh.

- Add new `Blockscout` platform (`platform/blockscout.py`) that fetches
  verified contracts from Blockscout-based explorers using the same
  `chain:0xAddress` target syntax as Etherscan. Supports Flow, Ink,
  Metis, Plume, and Story chains out of the box.

- Add `_normalize_blockscout_result` to translate Blockscout's API field
  conventions (e.g. `"true"`/`"false"` OptimizationUsed, split
  AdditionalSources) into Etherscan-compatible format so the existing
  compilation pipeline works unchanged.

- Extract shared block-explorer helpers into `platform/explorer_utils.py`
  (`handle_bytecode`, `handle_single_file`, `handle_multiple_files`,
  `sanitize_remappings`, `convert_version`, `EXPLORER_BASE_BYTECODE`).
  Etherscan and Sourcify now import from this module instead of having
  private copies. `ETHERSCAN_BASE_BYTECODE` kept as a backwards-compat alias.

- Add `Type.BLOCKSCOUT = 14` to the platform type enum.

- Add Monad mainnet (`"monad"`, chain ID 143) to SUPPORTED_NETWORK_V2.

- Add CI integration tests for five Blockscout chains in
  `scripts/ci_test_etherscan.sh` (no API key required).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Mar 6, 2026

CLA assistant check
All committers have signed the CLA.

@thevolcanomanishere thevolcanomanishere marked this pull request as draft March 6, 2026 13:53
@thevolcanomanishere thevolcanomanishere changed the title feat: add Blockscout platform and shared explorer utilities feat: add Blockscout platform, shared explorer utilities, support Monad/Flow/Ink/Metis/Plume/Story chain support Mar 6, 2026
…back

- Rename `--etherscan-only-source-code`, `--etherscan-only-bytecode`,
  `--etherscan-export-directory` to `--explorer-*` equivalents so they
  apply cleanly to all block explorer platforms (Etherscan, Blockscout).
  Add `--explorer-ignore` flag (was previously undocumented/unconfigured).
  Rename CLI group from "Etherscan options" to "Block explorer options".

- Each platform now defaults to its own export subdirectory name:
  `etherscan-contracts`, `blockscout-contracts`, `sourcify-contracts`.
  `--explorer-export-directory` overrides the default for all of them.

- Add `try_compile_from_sourcify()` helper to sourcify.py. Blockscout's
  compile() now tries Sourcify first for each chain; if the contract is
  verified there (e.g. Metis chain 1088), it compiles via Sourcify for
  richer metadata. Falls back to Blockscout silently on 404 or unsupported
  chain.

- Add chain IDs to SUPPORTED_NETWORK_BLOCKSCOUT for Sourcify lookup.

- Update stale bzzr1 hash in test_metadata.py.

- Add .env and crytic-export/ to .gitignore.

- Update README to list Blockscout as a supported platform.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thevolcanomanishere thevolcanomanishere marked this pull request as ready for review March 9, 2026 16:38
@thevolcanomanishere thevolcanomanishere changed the title feat: add Blockscout platform, shared explorer utilities, support Monad/Flow/Ink/Metis/Plume/Story chain support feat: add Blockscout platform, support all 700+ Blockscout chans, shared explorer utilities. Mar 9, 2026
@thevolcanomanishere thevolcanomanishere changed the title feat: add Blockscout platform, support all 700+ Blockscout chans, shared explorer utilities. feat: add Blockscout platform, support all 700+ Blockscout chains, shared explorer utilities. Mar 17, 2026
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.

3 participants