feat(cli): add --verify-contract flag to rex deploy#220
Open
feat(cli): add --verify-contract flag to rex deploy#220
Conversation
…ation After deploying a contract via --contract-path, the new --verify-contract flag automatically verifies the source code on Etherscan using the V2 API. This submits the Standard JSON Input (matching the exact solc flags used during compilation) and polls until verification succeeds. New flags: - --verify-contract: enable post-deploy verification - --etherscan-api-key: API key (also reads ETHERSCAN_API_KEY env var) - --contract-name: override contract name for multi-contract files - --optimizations: number of optimizer runs passed to solc and Etherscan The compilation step is refactored to return a CompilationInfo struct so that remappings and optimizer settings can be forwarded to the verification module. Artifact cleanup is deferred until after verification completes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
After deploying a contract with
rex deploy --contract-path, there's no way to verify the source code on Etherscan. Users have to manually submit verification through the Etherscan web UI or a separate tool. This adds a one-command deploy+verify workflow.Description
Adds
--verify-contractflag torex deploythat automatically verifies the contract source code on Etherscan after deployment using the Etherscan V2 API.New CLI flags:
--verify-contract--etherscan-api-keyETHERSCAN_API_KEYenv var)--contract-name--optimizationsHow it works:
solcflags used during compilation (--via-ir,--no-cbor-metadata, optimizer settings)Changes:
cli/src/verify.rs— new module with all verification logiccli/src/common.rs— new flags onDeployArgscli/src/cli.rs— refactoredcompile_contract_from_pathto returnCompilationInfo(bytecode + remappings + optimizer settings), deferred artifact cleanup, wired verification after deploycli/Cargo.toml— addedreqwestandregexdependenciescli/README.md— documented the new flags with examplesTested on Sepolia: