2

I would like to be able to simulate transactions with smart contracts based on their solidity source code. The process should be entirely automated.

While I am aware that some tools allow forking the chain at a given point in time, this generally requires me to start local nodes. It also does not scale well if I need information from many contracts at random block numbers.

Would there be some tool (ideally usable with Python) that allows mimicking a smart contract's state locally (and offline) based on its solidity source code? The idea would be that I can recreate transactions submitted to it and "roll-forward" its state to any point of time that I need it to without the need of forking and node providers. E.g., something like a local EVM runtime may do the trick but I am not sure how to set one up without also needing to run a node.

NOTE: Upon researching this question I came across py-evm, which seems to offer something in the direction I am looking for. The project looks solid, but it seems to still be under development and the documentation is a little sparse. Is there possibly a more mature tool around?

1
  • tenderly.co might be what you're looking for
    – Foxxxey
    Commented Jun 18, 2023 at 16:09

1 Answer 1

0

There are dump and dump-restore commands in 0xweb CLI tool. Depending on the local setup, here is an example for hardhat:

$ npm i 0xweb -g
$ 0xweb c dump 0x... --sources ./contracts/DumpDemo.sol --output ./dump/data/DumpDemo --chain hardhat

This generates two files:

  1. ./dump/data/DumpDemo.json - the key-value json of all contract's state variables
  2. ./dump/data/DumpDemo.csv - raw slot-value csv of contract's storage

Now, when you have deployed same contract under another address, you can populate the contracts storage with the dump back on-chain:

$ 0xweb c dump-restore 0x... --sources ./contracts/DumpDemo.sol --file ./dump/data/DumpDemo.csv --chain hardhat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.