Ganache CLI can fork an Ethereum network and run a local simulated Ethereum node based on EthereumJS.
This can especially useful if you want to interact with the complex decentralized finance (DeFi) contracts deployed on the Ethereum mainnet in a local simulated environment.
Deploy an Ethereum mainnet node with Chainstack
Deploy the node as described in Join a public network.
Get the RPC endpoint and access credentials of your deployed node as described in View node access and credentials.
Install Ganache CLI Beta
You must install Ganache CLI Beta as it has the basic authentication fix to work with the Ethereum nodes that require basic authentication.
npm install -g [email protected]
Fork the Ethereum mainnet through the Chainstack node
ganache-cli --fork https://USERNAME:[email protected]_ENDPOINT
- USERNAME — your Ethereum node access username.
- PASSWORD — your Ethereum node access password.
- RPC_ENDPOINT — your Ethereum node RPC endpoint.
ganache-cli --fork https://user-name:[email protected]
A forked Ethereum mainnet node is now running locally and you can interact with it.