원클릭으로
validate-config
// Validate a diffyscan config file for correctness before running verification. Checks schema, required fields, type correctness, and common mistakes.
// Validate a diffyscan config file for correctness before running verification. Checks schema, required fields, type correctness, and common mistakes.
Debug a failed diffyscan verification run. Analyzes diffs, identifies root causes. Use when diffyscan exits with non-zero or shows unexpected diffs.
Add support for a new blockchain explorer API to diffyscan. Use when a new chain or explorer type needs to be supported.
Create a new diffyscan verification config file for a deployed smart contract. Use when the user wants to verify a new contract or deployment.
| name | validate-config |
| description | Validate a diffyscan config file for correctness before running verification. Checks schema, required fields, type correctness, and common mistakes. |
| argument-hint | ["config-path"] |
Validate the diffyscan config file at $ARGUMENTS (or ask for the path if not provided).
Read the config file using the Read tool. Use the TypedDict definitions in diffyscan/utils/custom_types.py as the schema reference.
The Config TypedDict (diffyscan/utils/custom_types.py) defines:
Required fields:
contracts — dict[str, str] mapping address to contract namenetwork — str (declared required in TypedDict but currently unused at runtime; include it for forward-compatibility)explorer_hostname — strgithub_repo — GithubRepo with required keys: url, commit, relative_rootOptional fields (NotRequired):
dependencies — dict[str, GithubRepo]explorer_token_env_var — strexplorer_chain_id — intbytecode_comparison — BinaryConfigfail_on_bytecode_comparison_error — boolsource_comparison — boolAdditional fields found in real configs but not in the TypedDict:
explorer_hostname_env_var — str (CI convention only — diffyscan does NOT resolve this at runtime; external tooling must set explorer_hostname before invoking)audit_url — strmetadata — dict (free-form project metadata)The BinaryConfig TypedDict has all-optional fields:
hardhat_config_name — str (deprecated, ignored at runtime)constructor_calldata — dict[str, str] mapping address to raw hex calldataconstructor_args — dict[str, list] mapping address to a list of ABI-encodable argumentslibraries — dict[str, dict[str, str]] mapping source path to {LibraryName: "0xAddress"}contracts must be present and be a non-empty dictexplorer_hostname must be a string (or alternatively explorer_hostname_env_var must be present; real configs use one or both -- see tests/test_configs.py line 32)github_repo must be present and contain all three keys: url, commit, relative_rootnetwork is declared required in the TypedDict. Warn if missing, noting it is not used at runtime today but may be in the futureThe function _validate_yaml_hex_keys in diffyscan/utils/common.py checks YAML configs for hex values that PyYAML silently coerced from strings to integers. It raises ValueError if any are found. Specifically it checks:
contracts keys (address) -- raises if parsed as intcontracts values (contract name) -- raises if parsed as intbytecode_comparison.constructor_args keys -- raises if parsed as intbytecode_comparison.constructor_calldata keys -- raises if parsed as intbytecode_comparison.libraries values (the library address strings) -- raises if parsed as intThis validation only runs for YAML files, not JSON. It only detects int coercion; it does NOT validate address format (0x prefix, 42 chars, valid hex, checksum).
The codebase does NOT validate address format at config load time. There is no runtime check for 0x prefix, 42-character length, or hex validity on addresses in the config. Addresses are passed directly to the explorer API and RPC node.
However, the test suite (tests/test_configs.py:test_contract_addresses_format) asserts all contracts keys start with 0x and are 42 characters. Recommend the same for any address in the config:
contracts keysbytecode_comparison.constructor_calldata keysbytecode_comparison.constructor_args keysbytecode_comparison.libraries valuesexplorer_token_env_var is missing, the runtime warns and falls back to ETHERSCAN_EXPLORER_TOKEN (see _load_explorer_token in diffyscan/diffyscan.py). Warn if absent.explorer_chain_id is optional; the runtime does not warn if missing (retrieved with warn_if_missing=False)explorer_hostname is retrieved with warn_if_missing=True; if absent the runtime logs a warninggithub_repo.url should look like a GitHub URLgithub_repo.commit should ideally be a full 40-character SHA hex string (warn if short or non-hex)github_repo.relative_root can be an empty string (commonly is for root-level repos)url, commit, relative_root (same GithubRepo shape)@openzeppelin/contracts, lib/openzeppelin-contracts-upgradeable/contracts)"{dep_name}/" (see resolve_dep in diffyscan/utils/github.py)constructor_calldata values should be hex strings (the runtime strips 0x prefix via normalize_calldata and validates hex content)constructor_args values must be lists (arrays of ABI-encodable values)constructor_calldata and constructor_args -- the runtime raises CalldataError if it does (see get_calldata in diffyscan/utils/calldata.py)libraries maps Solidity source file paths to {LibraryName: "0xAddress"} dictshardhat_config_name is deprecated and ignored at runtime (a warning is logged)What the runtime actually does:
bytecode_comparison.constructor_calldata and constructor_args are looked up by contract address at runtime -- if a contract has a constructor but its address is not in either dict and the explorer has no constructor arguments, the runtime raises CalldataErrorcontracts that have no corresponding entry in bytecode_comparison will still work -- they fall back to explorer-provided constructor argumentsRecommended cross-reference warnings:
constructor_calldata or constructor_args but not in contracts (it would be unused)constructor_calldata and constructor_args (runtime error)fail_on_bytecode_comparison_error defaults to true if absentsource_comparison defaults to true if absent; set to false to skip source diffsReport issues in two categories:
constructor_calldata and constructor_argsexplorer_token_env_var, short commit SHA, addresses not matching 0x/42-char format, missing network, deprecated hardhat_config_name, unused bytecode_comparison entriesIf the config looks good, confirm it passes validation.