I want to extract main net state at a specific block number using geth or parity. Then using the extracted state I want to interact with contracts deployed during that time using ethers js.

Can someone please point me to the easiest way to achieve that?

  • Can point you with Ganache. – goodvibration Nov 13 '20 at 10:23
  • @goodvibration Sure! That would be great! – Mustafa Khan Nov 13 '20 at 10:27
  • Are you on Truffle 5.x? – goodvibration Nov 13 '20 at 10:31
  • @goodvibration Yep! – Mustafa Khan Nov 13 '20 at 10:33

Here is how you can do it using Truffle & Ganache.

In truffle-config.js, extend the configuration of your network to something like this:

networks: {
    myNetwork: {
        host: ...,
        port: ...,
        network_id: ...,
        gas: ...,
        gasPrice: ...,
        networkCheckTimeout: 9000000000, // or some other large value
        provider: ganache.provider({
            gasLimit: ...,
            gasPrice: ...,
            default_balance_ether: ...,
            fork: "url of an archive node",
            fork_block_number: desiredBlockNumber

Update: you also need const ganache = require('ganache-core'); in this file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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