I am trying to deploy contracts on a mainnet fork. I have my fork running with the command

ganache --fork https://mainnet.infura.io/v3/$INFURA_API_KEY --wallet.unlockedAccounts=$MY_ACCOUNT --chain.networkId=1

where INFURA_API_KEY and MY_ACCOUNT are variables that I set. The fork works, and I can send tx's and see it working in the console. But I get the following error when running in a separate console truffle migrate --network mainnet_fork

I have successfully deplyed these contracts on sepolia using the sepolia infura url and truffle migrate --network sepolia

So I dont see why this is working on sepolia and not my mainnet fork. My mainnet truffle config is below and the first migration this is failing on is the out of box truffle 1_inital_migration.js. So its not even getting to the custom code. Any thoughts on why this would be?

I have my truffle config compiler set to "pragma" and everything does compile. I've also updated ganace to the latest version ganache v7.9.0 (@ganache/cli: 0.10.0, @ganache/core: 0.10.0)

Truffle config for mainnet fork

mainnet_fork: {
      host: "",
      port: 8545,
      gas: 4000000, // Adjust the gas limit as per your requirements
      gasPrice: 10000000000, // Set the gas price to an appropriate value
      confirmations: 2, // Set the number of confirmations needed for a transaction
      timeoutBlocks: 200, // Set the timeout for transactions
      network_id: "1"


Your Answer

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