-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(cast) add deploydata method #8973
Comments
pawurb
added
T-feature
Type: feature
T-needs-triage
Type: this issue needs to be labelled
labels
Sep 27, 2024
pawurb
changed the title
feat(
feat(cast) add deploydata method
Sep 27, 2024
cast
) add deploydata method
Hi @pawurb |
zerosnacks
added
C-cast
Command: cast
and removed
T-needs-triage
Type: this issue needs to be labelled
labels
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 4, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 10, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 10, 2024
pawurb
added a commit
to pawurb/foundry
that referenced
this issue
Oct 16, 2024
grandizzy
pushed a commit
that referenced
this issue
Oct 29, 2024
* feat(cast) add creation-code method [#8973] * Fix typo * Fix CI * Code review fixes * Add creation-code flags and creation-args * Update comments * eyre style fixes * typo * use r#".."# for snapbox * Apply suggestions from code review * fix test regression * tag arguments as mutually exclusive * use unreachable! * Rename and add abi_path param * Decode constructor args * Update crates/cast/bin/cmd/constructor_args.rs * fix test * Update crates/cast/bin/args.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Fix formatting * Code review fixes --------- Co-authored-by: zerosnacks <zerosnacks@protonmail.com> Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
rplusq
pushed a commit
to rplusq/foundry
that referenced
this issue
Nov 29, 2024
* feat(cast) add creation-code method [foundry-rs#8973] * Fix typo * Fix CI * Code review fixes * Add creation-code flags and creation-args * Update comments * eyre style fixes * typo * use r#".."# for snapbox * Apply suggestions from code review * fix test regression * tag arguments as mutually exclusive * use unreachable! * Rename and add abi_path param * Decode constructor args * Update crates/cast/bin/cmd/constructor_args.rs * fix test * Update crates/cast/bin/args.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Fix formatting * Code review fixes --------- Co-authored-by: zerosnacks <zerosnacks@protonmail.com> Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Component
Cast
Describe the feature you would like
Hi. One way to deploy a contract with Alloy is to use an artifact. It requires an artifact file by compiling the contracts locally. Other methods require manually embedding the API and bytecode.
Maybe I've overlooked something but I did not find a simple way to get bytecode without local compilation or
forge inspect
that also require local setup. Etherscan showsbytecode
(asContract Creation Code
) in the UI but I could not find an API to get it directly.eth_getCode
returns the deployed bytecode.I want to propose adding
cast deploydata <address>
method. It would produce a file which contains the contracts ABI and bytecode fetched from the etherscan API in this format. This data is all that's necessary to deploy a contract with Alloysol!
macro. I've created a POC here: https://github.com/pawurb/alloy_deploydata .ABI fetching is already implemented. Tx where a contract was created can be fetched from etherscan like this:
https://api.etherscan.io/api?module=contract&action=getcontractcreation&contractaddresses=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&apikey=API_KEY
Returning:
Later we can call:
https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash=0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3&apikey=API_KEY
If in the result
to
isnull
it means thatinput
is the bytecode we need.If result is not
null
means that contract was deployed with some factory pattern orcreate2
. In the case it's still possible to get the bytecode withdebug_traceTransaction/callTracer
. But it would require an rpc and could work as a fallback.This feature would allow users to easily deploy and test contracts without compiling them locally.
We could also add
cast bytecode
which would return contract's bytecode.Let me know if you'd accept this feature and I can look into creating a PR.
Additional context
No response
The text was updated successfully, but these errors were encountered: