ethereumgo-ethereumgeth

Fork the actual mainnet from a specific block


I would like to test some imbrications between many smartcontract on Ethereum, but :

So, in order to get as close as possible to the actual mainnet, is there a way to copy the current state of the entire blockchain, with all the transactions, and fork it at a specific block to test some features ?

The official documentation explains how to create a private network, but how can we create a private network based on a specific mainnet's block ?

Thank you


Solution

  • You can run Ganache with the --fork option.

    Fork from another currently running Ethereum client at a given block. Input should be the HTTP location and port of the other client, e.g. http://localhost:8545. You can optionally specify the block to fork from using an @ sign: http://localhost:8545@1599200.

    So the actual command could look like this:

    ganache-cli --fork https://mainnet.infura.io/v3/<your_infura_id>