madlabman / diffyscan

Diff your Github against Etherscan.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Diffyscan

python >=3.10,<4 poetry ^1.8 license MIT Code style: black

Diff your Ethereum smart contracts code from GitHub against Blockchain explorer verified source code.

Install

pipx install git+https://github.com/lidofinance/diffyscan

Usage

Set your Etherscan token to fetch verified source code,

export ETHERSCAN_EXPLORER_TOKEN=<your-etherscan-token>

Set your Github token to query API without strict rate limiting,

export GITHUB_API_TOKEN=<your-github-token>

Start script with one of the examples provided

diffyscan config_samples/lido_dao_sepolia_config.json

Alternatively, create a new config file named config.json,

{
    "contracts": {
        "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8": "OssifiableProxy",
        "0xDba5Ad530425bb1b14EECD76F1b4a517780de537": "LidoLocator"
    },
    "explorer_hostname": "api-holesky.etherscan.io",
    "explorer_token_env_var": "ETHERSCAN_EXPLORER_TOKEN",
    "github_repo": {
        "url": "https://github.com/lidofinance/lido-dao",
        "commit": "cadffa46a2b8ed6cfa1127fca2468bae1a82d6bf",
        "relative_root": ""
    },
    "dependencies": {
        "@openzeppelin/contracts-v4.4": {
            "url": "https://github.com/OpenZeppelin/openzeppelin-contracts",
            "commit": "6bd6b76d1156e20e45d1016f355d154141c7e5b9",
            "relative_root": "contracts"
        }
    }
}

Start the script

dyffyscan

Note: Brownie verification tooling might rewrite the imports in the source submission. It transforms relative paths to imported contracts into flat paths ('./folder/contract.sol' -> 'contract.sol'), which makes Diffyscan unable to find a contract for verification.

For contracts whose sources were verified by brownie tooling:

diffyscan --support-brownie

ℹ️ See more config examples inside the config_samples dir.

Development setup

Prerequisites

This project was developed using these dependencies with their exact versions listed below:

  • Python 3.12
  • Poetry 1.8

Other versions may work as well but were not tested at all.

Setup

  1. Install Poetry

Use the following command to install poetry:

pip install --user poetry~=1.8

alternatively, you could proceed with pipx:

pipx install poetry~=1.8
  1. Activate poetry virtual environment,
poetry shell
  1. Install poetry-dynamic-versioning
  • In most cases: poetry self add "poetry-dynamic-versioning[plugin]"
  • If you installed Poetry with Pipx: pipx inject poetry "poetry-dynamic-versioning[plugin]"
  1. Install Python dependencies
poetry install

About

Diff your Github against Etherscan.

License:MIT License


Languages

Language:Python 100.0%