I am running a local Hardhat network to test my contracts. I want my contract to eventually be able to swap existing ERC20 tokens, for example WETH/USDC on Uniswap.

Is there a way to test this in my local Hardhat network?

As a complete beginner to the world of blockchain, I would very much appreciate your answers!

1 Answer 1


You need to enable mainnet forking in Hardhat network to be able to access a copy of mainnet-deployed contracts in your local running instance. You could enable mainnet forking with the following Hardhat config:

const config = {
  networks: {
    hardhat: {
      chainId: 1337,
      forking: {
        enabled: true,
        url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.