2

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?

Mustafa Khan
  • 249
  • 2
  • 7

1 Answers1

1

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.

goodvibration
  • 26,003
  • 5
  • 46
  • 86