I am trying to deploy pancakeSwapv3 contracts on goerli network. I have been able to do it successfully on hardhat network and also on BSCtestnet, using the pre existing deploy script provided in the repository.

However, when running the deploy script on Goerli, a few of the contracts get deployed succesfully then i get this error :

C:\Users\****\Desktop\pancakev3\pancake-v3-contracts\node_modules\.bin\hardhat run scripts/deploy2.ts --network goerli

owner 0x6A0FEb874D3C7448e6b1d9F7a0B4A60A664c8011
swapRouter 0x3Ddc55412c7fe6EC3650Ad7206bA34c62b6057e8
nonfungibleTokenPositionDescriptor 0x8abfCEB7b172899cD90f39EAc2004F3788C57bF6
nonfungiblePositionManager 0x07b95D428999FaA743f1311eC0DDEA0fd818a1aE
ProviderError: INTERNAL_ERROR: could not replace existing tx
    at HttpProvider.request (C:\Users\****\Desktop\pancakev3\pancake-v3-contracts\node_modules\hardhat\src\internal\core\providers\http.ts:88:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at EthersProviderWrapper.send (C:\Users\****\Desktop\pancakev3\pancake-v3-contracts\node_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20)
error Command failed with exit code 1.

What could be the cause of this error? and why is etherscan considering that i am replacing a transaction? here is the deploying script until the point of failure(to save space):

import bn from 'bignumber.js'
import { Contract, ContractFactory, utils, BigNumber } from 'ethers'
import { ethers, upgrades, network } from 'hardhat'
import { linkLibraries } from '../util/linkLibraries'
import { tryVerify } from '@pancakeswap/common/verify'
import { configs } from '@pancakeswap/common/config'
import fs from 'fs'

type ContractJson = { abi: any; bytecode: string }
const artifacts: { [name: string]: ContractJson } = {
  QuoterV2: require('../artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json'),
  TickLens: require('../artifacts/contracts/lens/TickLens.sol/TickLens.json'),
  V3Migrator: require('../artifacts/contracts/V3Migrator.sol/V3Migrator.json'),
  PancakeInterfaceMulticall: require('../artifacts/contracts/lens/PancakeInterfaceMulticall.sol/PancakeInterfaceMulticall.json'),
  // eslint-disable-next-line global-require
  SwapRouter: require('../artifacts/contracts/SwapRouter.sol/SwapRouter.json'),
  // eslint-disable-next-line global-require
  NFTDescriptor: require('../artifacts/contracts/libraries/NFTDescriptor.sol/NFTDescriptor.json'),
  // eslint-disable-next-line global-require
  NFTDescriptorEx: require('../artifacts/contracts/NFTDescriptorEx.sol/NFTDescriptorEx.json'),
  // eslint-disable-next-line global-require
  NonfungibleTokenPositionDescriptor: require('../artifacts/contracts/NonfungibleTokenPositionDescriptor.sol/NonfungibleTokenPositionDescriptor.json'),
  // eslint-disable-next-line global-require
  NonfungibleTokenPositionDescriptorOffChain: require('../artifacts/contracts/NonfungibleTokenPositionDescriptorOffChain.sol/NonfungibleTokenPositionDescriptorOffChain.json'),
  // eslint-disable-next-line global-require
  NonfungiblePositionManager: require('../artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'),

bn.config({ EXPONENTIAL_AT: 999999, DECIMAL_PLACES: 40 })
function encodePriceSqrt(reserve1: any, reserve0: any) {
  return BigNumber.from(
    // eslint-disable-next-line new-cap
    new bn(reserve1.toString())
      // eslint-disable-next-line new-cap
      .multipliedBy(new bn(2).pow(96))

function isAscii(str: string): boolean {
  return /^[\x00-\x7F]*$/.test(str)
function asciiStringToBytes32(str: string): string {
  if (str.length > 32 || !isAscii(str)) {
    throw new Error('Invalid label, must be less than 32 characters')

  return '0x' + Buffer.from(str, 'ascii').toString('hex').padEnd(64, '0')

async function main() {
  const [owner] = await ethers.getSigners()
  const networkName = network.name
  console.log('owner', owner.address)

  const config = configs[networkName as keyof typeof configs]

  if (!config) {
    throw new Error(`No config found for network ${networkName}`)

  const deployedContracts = await import(`@pancakeswap/v3-core/deployments/${networkName}.json`)

  const pancakeV3PoolDeployer_address = deployedContracts.PancakeV3PoolDeployer
  const pancakeV3Factory_address = deployedContracts.PancakeV3Factory

  const SwapRouter = new ContractFactory(artifacts.SwapRouter.abi, artifacts.SwapRouter.bytecode, owner)
  const swapRouter = await SwapRouter.deploy(pancakeV3PoolDeployer_address, pancakeV3Factory_address, config.WNATIVE)

  // off chain version
  const NonfungibleTokenPositionDescriptor = new ContractFactory(
  const baseTokenUri = 'https://nft.pancakeswap.com/v3/'
  const nonfungibleTokenPositionDescriptor = await upgrades.deployProxy(NonfungibleTokenPositionDescriptor, [
  await nonfungibleTokenPositionDescriptor.deployed()
  console.log('nonfungibleTokenPositionDescriptor', nonfungibleTokenPositionDescriptor.address)

  // await tryVerify(nonfungibleTokenPositionDescriptor)

  const NonfungiblePositionManager = new ContractFactory(
  const nonfungiblePositionManager = await NonfungiblePositionManager.deploy(

I have tried adding a big gas limit in my hardhat.config

const goerli: NetworkUserConfig = {
  url: 'https://rpc.ankr.com/eth_goerli',
  chainId: 5,
  accounts: [process.env.KEY_GOERLI!],
  gasPrice: 1000000000, // 1 gwei
  gas: 8000000,

which gives me the error...

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
Error: Error: overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="BigNumber.from", value=1e+27, code=NUMERIC_FAULT, version=bignumber/5.7.0)
    at Logger.makeError (C:\Users\****\Desktop\pancakev3\pancake-v3-contracts\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)

1 Answer 1


It would be gasPrice you need to increase in order to replace a transaction, not limit. 1 gwei will often not be enough on goerli. Consider calling your endpoint for the current gas prices.

Around 70 gwei currently:

>>> w3.eth.gas_price
  • apparently this creates an overflow due to the big number library. So i might have to fix this. It's been suggested to me that this is an rpc provider issue since i am able to deploy on BSCtestnet, or it might as well be a gas issue due to goerli being more demanding in fees?
    – Yann
    Sep 1 at 6:48
  • You will need a way to handle big numbers, like a BigInt library, if working with web3 or crypto from a language that cannot natively handle larger than unsigned long long.
    – Maka
    Sep 1 at 9:46

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.

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