bluealloy / revm

Ethereum Virtual Machine written in rust that is fast and simple to use
https://bluealloy.github.io/revm/
MIT License
1.57k stars 511 forks source link

Instatiating a contract from an ABI locally #1594

Open CadeMichael opened 1 month ago

CadeMichael commented 1 month ago

I'm digging through some of the documentation to build a Contract object from an abi and execute transactions with it on the Evm. It seems like all of the docs and tutorials I've found point to using a contract from a pre existing chain and then running tests / simulations with it. Is there a standard approach to get a contract locally for running with REVM? Some of the relevant docs I've found include 'BundleState' but I'm not sure how to properly tie this into an 'Evm::builder()' to have the contract exist in the running Evm instance.

https://bluealloy.github.io/revm/docs/revm/db/states/bundle_state/struct.BundleBuilder.html#method.contract

I see that you can use a BundleBuilder and use 'build()' to get the BundleState out of it, but I'm getting lost on going from BundleState to changing the Evm. I'm thinking possibly BundleState::extend() but I'm not sure. If there is a clear solution that's going over my head I'd be happy to add it to the docs.

DaniPopes commented 1 month ago

An ABI just tells you what inputs are valid for a certain bytecode, it doesn't say anything about the environment. You need to get that information either from an rpc or build it yourself locally

CadeMichael commented 1 month ago

Are there any docs on building it locally ?