Problem about Create a uniswap pair in smart contract constructor!

guys , i want deploy my contract on forked mainnet in local network , but i get thhis error :

Error: * Deployment Failed *

"myToken" ran out of gas. Something in the constructor (ex: infinite loop) caused gas estimation to fail. Try:

  • Making your contract constructor more efficient
  • Setting the gas manually in your config or as a deployment parameter
  • Using the solc optimizer settings in 'truffle-config.js'
  • Setting a higher network block limit if you are on a
    private network or test client (like ganache).

and i know it's because of this line :
// // Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(_uniswapV2Router.WETH(), address(this));


anyone can please help to solve this .Thanks

Hi, welcome! :wave:

If possible, could you please share the full contract code at here?

1 Like