Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/onchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-2025"]
type: ["etherscan", "sourcify"]
type: ["etherscan", "sourcify", "blockscout"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ package-lock.json
result
env/
.coverage*
.env
crytic-export/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Library to help smart contract compilation. It includes support for:
- [Etherlime](https://github.com/LimeChain/etherlime)
- [Sourcify](https://sourcify.dev/)
- [Etherscan](https://etherscan.io/) (including several alt-chain explorers and testnets)
- [Blockscout](https://www.blockscout.com/) ([750+ chains](https://chains.blockscout.com/))
- [Truffle](https://truffleframework.com/)
- [Waffle](https://github.com/EthWorks/Waffle)

Expand Down
62 changes: 39 additions & 23 deletions crytic_compile/cryticparser/cryticparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def init(parser: ArgumentParser) -> None:
_init_brownie(parser)
_init_dapp(parser)
_init_etherlime(parser)
_init_etherscan(parser)
_init_explorer(parser)
_init_waffle(parser)
_init_npx(parser)
_init_buidler(parser)
Expand Down Expand Up @@ -299,51 +299,67 @@ def _init_etherlime(parser: ArgumentParser) -> None:
)


def _init_etherscan(parser: ArgumentParser) -> None:
"""Init etherscan arguments
def _init_explorer(parser: ArgumentParser) -> None:
"""Init block explorer arguments (Etherscan, Blockscout, Sourcify, etc.)

Args:
parser (ArgumentParser): argparser where the cli flags are added
"""
group_etherscan = parser.add_argument_group("Etherscan options")
group_etherscan.add_argument(
"--etherscan-only-source-code",
group = parser.add_argument_group("Block explorer options")
group.add_argument(
"--explorer-only-source-code",
help="Only compile if the source code is available.",
action="store_true",
dest="etherscan_only_source_code",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_only_source_code"],
dest="explorer_only_source_code",
default=DEFAULTS_FLAG_IN_CONFIG["explorer_only_source_code"],
)

group_etherscan.add_argument(
"--etherscan-only-bytecode",
group.add_argument(
"--explorer-only-bytecode",
help="Only looks for bytecode.",
action="store_true",
dest="etherscan_only_bytecode",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_only_bytecode"],
dest="explorer_only_bytecode",
default=DEFAULTS_FLAG_IN_CONFIG["explorer_only_bytecode"],
)

group_etherscan.add_argument(
group.add_argument(
"--explorer-ignore",
help="Ignore block explorer platforms (Etherscan, Blockscout, etc.).",
action="store_true",
dest="explorer_ignore",
default=DEFAULTS_FLAG_IN_CONFIG["explorer_ignore"],
)

group.add_argument(
"--explorer-export-directory",
help="Directory in which to save contracts fetched from block explorers.",
action="store",
dest="explorer_export_dir",
default=DEFAULTS_FLAG_IN_CONFIG["explorer_export_directory"],
)

group.add_argument(
"--etherscan-apikey",
help="Etherscan API key.",
action="store",
dest="etherscan_api_key",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
)

group_etherscan.add_argument(
"--avax-apikey",
help="Etherscan API key.",
group.add_argument(
"--blockscout-url",
help="Custom Blockscout explorer URL for chains not in the directory.",
action="store",
dest="avax_api_key",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
dest="blockscout_url",
default=DEFAULTS_FLAG_IN_CONFIG["blockscout_url"],
)

group_etherscan.add_argument(
"--etherscan-export-directory",
help="Directory in which to save the analyzed contracts.",
group.add_argument(
"--avax-apikey",
help="Avalanche (Snowtrace) API key.",
action="store",
dest="etherscan_export_dir",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_export_directory"],
dest="avax_api_key",
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
)


Expand Down
8 changes: 5 additions & 3 deletions crytic_compile/cryticparser/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"dapp_ignore_compile": False,
"etherlime_ignore_compile": False,
"etherlime_compile_arguments": None,
"etherscan_only_source_code": False,
"etherscan_only_bytecode": False,
"explorer_only_source_code": False,
"explorer_only_bytecode": False,
"explorer_ignore": False,
"explorer_export_directory": None,
"etherscan_api_key": None,
"etherscan_export_directory": "etherscan-contracts",
"blockscout_url": None,
"waffle_ignore_compile": False,
"waffle_config_file": None,
"npx_disable": False,
Expand Down
2 changes: 2 additions & 0 deletions crytic_compile/platform/all_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# crytic_compile.py uses dir(all_platforms) to find these classes
__all__ = [
"Archive",
"Blockscout",
"Brownie",
"Buidler",
"Dapp",
Expand All @@ -24,6 +25,7 @@
]

from .archive import Archive
from .blockscout import Blockscout
from .brownie import Brownie
from .buidler import Buidler
from .dapp import Dapp
Expand Down
Loading