# Forking with hardhat **Published by:** [N00b21337](https://paragraph.com/@n00b21337/) **Published on:** 2023-08-07 **URL:** https://paragraph.com/@n00b21337/forking-with-hardhat ## Content To fork a network in hardhat you need to change config that adds this line to your networks networks: { hardhat: { forking: { enabled: true, url: 'https://rpc.gnosischain.com', blockNumber: 29279000, }, .... With that, when you run hardhat node or hardhat test you will have your local node running at snapshot of whatever chain url rpc you put into config. This will give you different output when running tests it('return data for forked network, async function () { console.log(await getBlockNumber()); console.log(network.config.forking.enabled); await mineNBlocks(150); console.log(await getBlockNumber()); }); This will output info about forked network and you should be able to run tests on forked network state. Another option is to have tests setup with this snippet and run them on forked network so you can combined local tests and forked network tests. Put this into before blockawait hre.network.provider.request({ method: "hardhat_reset", params: [{forking: { jsonRpcUrl: "https://eth-mainnet.alchemyapi.io/v2/xxxxxx", blockNumber:14768690 },},], }); ## Publication Information - [N00b21337](https://paragraph.com/@n00b21337/): Publication homepage - [All Posts](https://paragraph.com/@n00b21337/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@n00b21337): Subscribe to updates - [Twitter](https://twitter.com/0xCardinalError): Follow on Twitter