Diff your Ethereum smart contracts code from GitHub against Blockchain explorer verified source code.
This project was developed using these dependencies with their exact versions listed below:
- Python 3.10
- Poetry 1.6
Other versions may work as well but were not tested at all.
- Install Poetry
Use the following command to install poetry:
pip install --user poetry~=1.6
alternatively, you could proceed with pipx
:
pipx install poetry~=1.6
- Activate poetry virtual environment,
poetry shell
- Install Python dependencies
poetry install
Set your Etherscan token to fetch verified source code,
export ETHERSCAN_TOKEN=<your-etherscan-token>
Set your Github token to query API without strict rate limiting,
export GITHUB_API_TOKEN=<your-github-token>
Create a config file named config.json
,
{
"contracts": {
"0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8": "OssifiableProxy",
"0xDba5Ad530425bb1b14EECD76F1b4a517780de537": "LidoLocator"
},
"explorer_hostname": "api-holesky.etherscan.io",
"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
python3 main.py
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:
python3 main.py --support-brownie
ℹ️ See more config examples inside the config_samples dir.