-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(forge verify-contract): --guess-constructor-args
#6334
Comments
This feature would be extraordinarily helpful. The most difficult part about verifying contracts is the ABI-encoding of the constructor params. We need to resort to complicated nested terminal commands like this:
|
agreed this would be super helpful—are you up for it @klkvr ? |
sure! but i have a lot of stuff on me atm, so i could start with it in a week or two |
yep no rush—everyone's on the holidays rn. Feel free to go at it whenever! will assign so we don't lose track |
Hey @Evalir I have opened PR to support fetching of contract creation tx for block-explorers. I will also need to somehow be able to get access to RPC-endpoint of the corresponding network to get/trace deployment tx. It seems that it is not possible to get rpc endpoint from configuration by chain_id without iterating over each of endpoints and comparing eth_chainId response. I can see 2 ways to solve this:
Option 1 messes up UX a little bit. But it might be a good thing because it will be clear that there is some additional RPC stuff going on under the hood. Option 2 is better for UX but hard to implement in a clean way because Etherscan Geth proxy doesn't work as a standard RPC-endpoint, you have to specify method as a query parameter, so we can't just reuse the same logic as for usual RPC-endpoints. Also, Etherscan doesn't support archive eth_getStorageAt queries, so verification of contracts created by contracts won't work. Do you see any other options and what do you think about those? |
Hmmm, yeah I think we can go with option one—we can add a little note on the |
This PR adds binding for [getcontractcreation](https://docs.etherscan.io/api-endpoints/contracts#get-contract-creator-and-creation-tx-hash) method which returns contract deployer and creation tx. I will need this to complete [#6344 foundry issue](foundry-rs/foundry#6334). I have only added binding and support for fetching data for single contract but Etherscan supports fetching those for up to 5 contracts at a time. Considering such small restriction, does it make sense to implement binding for multi-contract requests too? --------- Co-authored-by: evalir <hi@enriqueortiz.dev>
Component
Forge
Describe the feature you would like
It would be convenient to have an option to specify
--guess-constructor-args
flag onforge 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:
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 UIAdditional context
No response
The text was updated successfully, but these errors were encountered: