Component
Forge
Describe the feature you would like
It would be convenient to have an option to specify --guess-constructor-args flag on forge verify-contract command which will try to find constructor arguments for contract without need to explicitly provide them when running the command.
It can be done in 3 steps:
- Fetch contract deployment transaction with Etherscan API: https://docs.etherscan.io/api-endpoints/contracts#get-contract-creator-and-creation-tx-hash
- Fetch contract creation code from transaction
- Use contract ABI to calculate length of abi-encoded constructor arguments and take a suffix of creation code with this length.
The most interesting part is fetching the creation code (step 2). For contracts deployed by EOAs it is pretty simple (we can just take tx.data field). But for contracts deployed with CREATE/CREATE2 it would require tracing of transaction execution which takes time and requires endpoint with archive data which is not available to everyone.
It might also make sense to add a CLI command forge get-constructor-args <CONTRACT> <CREATION_CODE> which will basically perform a step 3 above. This might be useful because users may have init code from broadcast artifacts or Etherscan UI
Additional context
No response
Component
Forge
Describe the feature you would like
It would be convenient to have an option to specify
--guess-constructor-argsflag onforge verify-contractcommand which will try to find constructor arguments for contract without need to explicitly provide them when running the command.It can be done in 3 steps:
The most interesting part is fetching the creation code (step 2). For contracts deployed by EOAs it is pretty simple (we can just take
tx.datafield). But for contracts deployed with CREATE/CREATE2 it would require tracing of transaction execution which takes time and requires endpoint with archive data which is not available to everyone.It might also make sense to add a CLI command
forge get-constructor-args <CONTRACT> <CREATION_CODE>which will basically perform a step 3 above. This might be useful because users may have init code from broadcast artifacts or Etherscan UIAdditional context
No response