1

I have a simple contract that I've tested on my ganache network, and now I'd like to push it to the mainnet. So I funded my Metamask with around $100 or 0.025 eth, figured that would be enough to cover the gas fees.

However I am seeing the following:

enter image description here

Then this popup appears:

enter image description here

Then on MetaMask:

enter image description here

What on earth, is it really this expensive? Are there some settings I can change? I don't mind if it takes longer, even a day or more, to get onto the mainnet. I don't want to spend $500 for a test project, honestly I was ok with like 50 bucks.

Any insights or help appreciated! Thanks.

2 Answers 2

3

Sorry, that's the cost of working on L1. Consider how today's average gas for all transactions was ~130 gwei or ~$150 USD: https://ycharts.com/indicators/ethereum_average_gas_price. This includes simple send and cheap calls.

I suggest deploying to an L2.

4
  • Thanks for your answer, I'm new to this. If I want to deploy to an L2, is it the same solidity code? Does my same web3 code work? Little lost on this concept.
    – JDS
    Jan 20, 2022 at 17:11
  • 1
    Yes, it's the same solidity code. Everything will work the same, the only thing to be aware of is that L2s use a different native token than L1s. So instead of paying fees in ETH/gwei, you use FTM or AVAX or whatever the L2 uses.
    – ori
    Jan 21, 2022 at 1:41
  • Thanks, that's great to know. Would you have any resources on examples of deploying to L2s given existing Solidity contracts? I'm pretty agnostic to whichever one as long as it's fairly popular
    – JDS
    Jan 21, 2022 at 3:26
  • 1
    The process to deploy to a L2 is exactly the same as L1, you just point to a different endpoint. Per hardhat.org/guides/deploying.html, instead of pointing to ETH url, point to an L2 url (e.g. for Avalanche: api.avax.network/ext/bc/C/rpc )
    – ori
    Jan 22, 2022 at 5:30
2
  • Before doing anything, I suggest first take a look at this to get familiar with contract deployment's gas calculation.

  • After reading the aforementioned link, I suggest (if it is possible for you), minimize your solidity code. Removing extra codes, results in less bytecodes, which means you will pay less for the deployment. Be warned that decreasing the volume of your code should not result in decreasing the security and functionality of your code.

  • Another suggestion would be waiting for the lowest gas price and then deploying the contract. These links will help you to track down the gas price: 1, 2. You could also check deployment details of contracts with verified source codes on etherscan to find out the deployment's fee range.

  • You could also set/edit gas config ("Gas limit" refers to the maximum amount of gas (or energy) that you're willing to spend on a particular transaction) in your remix/metamask (see this and this).

  • If the fee is still high for you, take a look at @mikko-ohtamaa's suggestion here for using alternative EVM compatible chains like Avalanche, Polygon, etc.

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.