enter image description here

I just deployed NFT Dapp on mainnet.

Estimated gas fee is too High. It's almost $10000

How can i fix it?

I never knew on local canache or rinkeby testnet

There was fine gas fee..

is it depend on truffle-config.js gas price?

I learn that based on complex of .sol code...

I use @openzapplin ERC-721, ERC721Enumerable, ERC721URIStorage, Ownable

and solc ^0.8.11

Here is my react web3 javascript for minting

await token.methods.createToken(uri, amount).send({from: account, value: tokens(_value)})
.on('receipt', (receipt) => {
    window.alert('Praying Bear successfully minted!')
    console.log("resultado =", receipt)
.on('error', (error, receipt) => {
  console.log('Participate Error - Receipt', error, receipt)
  console.log('Error - Message', error.message)

And my token.sol minttoken function is here

function createToken (string memory _uri, uint256 _amount) public payable returns (uint) {
    require(totalSupply() < maxSupply - (_amount - 1), "Sorry, it just sold out");
    uint256 currentprice = _amount == 1 ? soloPrice : _amount == 4 ? quatroPrice : tenPrice;
    require(msg.value == currentprice, "Price must be equal to listing price");
    uint newItemId = 0;
    for (uint i=0; i<_amount; i++) {
        newItemId = minttoken(_uri); 
    return newItemId;
function minttoken (string memory _uri) private returns (uint) {
    uint256 newItemId = totalSupply() + 1;
    _mint(msg.sender, newItemId);
    _uri = "ipfs://<HARDCODEDMYIPFSTOKEN>";
    _uri = string(abi.encodePacked(_uri,"/",Strings.toString(newItemId),".json"));
    _setTokenURI(newItemId, _uri);
    return newItemId;

++ To fix this am I truffle migrate --reset do?

  • I encountered a very similar problem. In my case, I was referring to a contract from a testnet and that got deployed to mainnet. The gas estimations were obviously fine on test but started to fail on mainnet making Metamask show enormous values (5ETH+). Please see my thread here.
    – Tali Oat
    Commented Feb 9, 2022 at 7:57

1 Answer 1


It is something normal to have such a high gas fee for deployment. I would suggest moving your contract to a L2 like polygon or arbitrum for cheaper deployment.

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.