I've tried to deploy a contract based on openzeppelin library (see below). The fee I paid is about $146 and the contract didn't even deploy(i.e it run out of gas ). I find this unbelievable high. It really cut my enthusiasm about Ethereum as I regarded it more like a platform than a pozi/value-store (i.e bitcoin).

ethscan.io says the contract failed as it run out of gas.

 Warning! Error encountered during contract execution [Out of gas]
0 Ether ($0.00)
Transaction Fee:
0.034104011574 Ether ($146.01)
Gas Price:
0.00000011368003858 Ether (113.68003858 Gwei)
Gas Limit & Usage by Txn:
300,000 | 300,000 (100%)
Gas Fees:
Base: 104.963834926 Gwei

Did I do something foolish and the miners "stole" my fees or is this the market price?

Is there any way to estimate the cost of the contract creation/initialization ( I guess whatever it has in the init function) using Go ? I deploy it with Go anyway using the bindings generated by ethereum dev tools ( "github.com/ethereum/go-ethereum/accounts/abi/bind")

Source code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";

contract XYZXTESTToken is ERC20 {
        uint256 private constant TOTAL_SUPPLY = (18000 * 10000000 * (10**18));
    constructor() ERC20("XYZXTESTTOKEN", "XYZXTESTTOKEN") {
        _mint(msg.sender, TOTAL_SUPPLY);

1 Answer 1


Did I do something foolish and the miners "stole" my fees or is this the market price?

You didn't do anything foolish except setting a relatively low gas limit. The miners didn't steal your fee, you just used the wrong parameters, the tx can succeed or fail, but gas will have to be paid no matter what.

I deployed your contract using Remix and the tx gas cost is : 1,154,936

Which means, 3.8 times more that the limit of 300,000 that you used.

Now I'd like to get back a bit on what I said, you did something kind of foolish: not making sure that you'd get what you were paying for. This means making sure that your parameters (i.e., gas price / gas limit) have values allowing the deployment of your smart contract.

You should only deploy to mainnet when you are sure that everything is working, the mainnet is NOT a test sandbox.

If you didn't do it already, I would advise you to use local blockchains and / or tesnets such as Rinkeby or Ropsten. Alternatively, you can also deploy to L2 solutions such as Polygon where gas price is more affordable.

There are several development framework simplifying dev / test and deployment such as Truffle, Hardhat or Brownie to cite the most accessible ones but it's either JavaScript or Python.

However, if you absolutely want to stick with go, and go-ethereum bindings you could be interested by simulated clients or setting up a local blockchain with go-ethereum.

  • Is the deploy supposed to cost $438 ? That's really unbearable... I just deployed it on testnet and it gives me Gas Limit & Usage by Txn: 640,000 | 639,013 (99.85%) which is still too high for a hobby test. I will check the other chain offers (binance as seems to be compatible with ethereum ). Commented Nov 19, 2021 at 21:47
  • Yes that would be an approximate cost on mainnet given the current gas price. Keep in mind that testnets are basically free. The ETH on Rinkeby or Ropsten is worth nothing. I just find it strange that you see a different gas cost.. each OP_CODE has a fixed gas value, which is the same on both mainnet or testnets.
    – hroussille
    Commented Nov 19, 2021 at 22:01
  • Thanks for the reassurance about the price/deployment method. Perhaps the price depends a bit due the compiler w/o options. You may also have an older version of the openzeppelin library. Here are my commands `` solc --optimize --abi ./contracts/token.sol -o build solc --optimize --bin ./contracts/token.sol -o build abigen --abi=./build/XYZToken.abi --bin=./build/XYZToken.bin --pkg=api --out=./api/xyz.go`` Commented Nov 19, 2021 at 22:05
  • Yes could be, different bytecode would have different gas cost. I can only use remix right now so... Anyway my point still holds. Given a fixed bytecode gas cost should be the same for you no matter the network that you are using.
    – hroussille
    Commented Nov 19, 2021 at 22:32

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.