I'm experiencing some weird behavior of the ERC721 contracts on the mainnet. I developed two very simple contracts using OpenZeppelin that are based on ERC721, ERC721URIStorage, and ERC721Enumerable. I deployed them using truffle 5.4.5 and successfully tested them on Rinkeby. However, when deployed to mainnet the first one demanded 5+ ETH (see picture) for minting a single token.

Metamask fee

After some time I redeployed the contract again and the minting fee became normal (something around 0.02). I deployed the second one and now experience the same issue: the gas fees are around 3 ETH. I tried different combinations of truffle config but no luck. The combinations I used:

  • All auto values for gas and gas price.
  • Set gas price to some average value.
  • Set high gas price.

That's my initial truffle networks config:

module.exports = {
  networks: {
    development: {
      host: "",
      port: 7545,
      network_id: "*" // Match any network id
    rinkeby: {
      provider: () => new HDWalletProvider({ mnemonic: {phrase: MNEMONIC}, providerOrUrl: rinkebyNodeUrl }),
      gas: 5000000,
      network_id: 4,
      from: OWNER_ADDRESS,
      networkCheckTimeout: 30000,
    mainnet: {
      provider: () => new HDWalletProvider({ mnemonic: {phrase: MNEMONIC}, providerOrUrl: mainnetNodeUrl }),
      network_id: 1,
      from: OWNER_ADDRESS,
  contracts_directory: './src/contracts/',
  contracts_build_directory: './src/abis/',
  compilers: {
    solc: {
      version: "0.8.4",
      optimizer: {
        enabled: true,
        runs: 200

Any help is really appreciated.

1 Answer 1


OK, I figured it out. If there's an obvious logical error or contract constraint violation, Metamask will show the proper error message "The transaction is expected to fail. Do you want to try anyway?". But in case the error is not so obvious, the gas estimation will fail, maximum gas fees will be applied, and the MM error will not be displayed. I discovered that when trying to manually estimate the gas fees with web3.eth.estimateGas(). In my case, I was referring to another contract inside my own and the external contract address was from a different network. When that was fixed the gas estimation started to work properly.

  • So inside your contract, you were calling an address of another contract that doesn't exist on the network you wanted to deploy at?
    – Sky
    Commented Feb 9, 2022 at 9:04
  • Exactly! So the thing is I had a system of two contracts (let's call them parent and child). Inside child, I was calling methods of the parent by direct instantiation of it. Both contracts were deployed to Rinkeby and tested flawlessly but then when deployed to mainnet the parent address remained the one from the Rinkeby.
    – Tali Oat
    Commented Feb 9, 2022 at 10:21

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.