Question about Forking using Ganache?


I just read @spalladino’s new post:

What a great way to test out if your contract upgrades are going to work on the main-net, prior to actually DOING it on the main net. Forking allows you to test out your upgrade on the current status of your smart contracts.

What is the best way to connet to a Rinkeby node? The tutorial says:

$ ganache-cli --fork $RINKEBYNODE --unlock "$USER" --unlock "$ADMIN" --port 9545 --networkId 1004 --deterministic

What should we use for $RINKEBYNODE ? For example if we connet via infura:

--fork '<<infura API key here>>'

but how do we then unlock $USER and $ADMIN? (and be sure we have those private keys in ganace?) Should we rather than use --deterministic, should we use --mnemonic and then use our development memonic? To be be sure we have access to $USER and $ADMIN?


Hey @Dennison! Thanks for the questions.

I used a private node I run myself, but you could very well connect to Infura as you say! In that case, the '<<infura API key here>>' string should work perfectly.

That’s the beauty of ganache! Since ganache is not a real node but a testing tool, you can ask it to --unlock an account without having its private keys. You just instruct it to unlock the $USER and $ADMIN addresses, and then you can freely send transactions from those addresses!