3

I always worked on a private blockchain and I was just deploying a contract onto ethereum and the cost is 15 dollars! I was a little taken back.

Is there a more cost effective to deploy? Why is the cost so high. This is the txn - https://etherscan.io/tx/0x2985a711357089b3e5b5d5ac693f594e3491f7a09b8988d2f6ac98ef420b58a0

Trevor Lee Oakley
  • 2,327
  • 2
  • 19
  • 48

1 Answers1

3

You have two options:

  1. Reduce the gas price you are offering. You used 21GWei which is the network "standard" value, but if you don't mind waiting 2-3 minutes, then 1GWei is fine. See EthGasStation. That brings you to under a dollar.

  2. Make more compact code. The Solidity optimiser is not bad at this, if you trust it. I do some coding in LLL which typically results in a code size around 25% of that of unoptimised Solidity. But grappling with LLL may not be worth the other 75 cents you could save :-)

[Edit] I thought of another one:

  1. If your constructor were doing a lot of storage then that would cost 20k gas per word. In your case I can see only 7 SSTORE operations, so this is probably not a huge factor. In fact, your 7955 bytes of contract data costs about 7955 * (200 + 68) = 2.1Mgas to deploy, plus the contract creation fee, which accounts for most of your 2.2 million total gas.
benjaminion
  • 9,247
  • 1
  • 23
  • 36
  • Some good points. The contract is based on a standard one which circulates for presales. I think this it is called OpenZepplin or something like that. It is mostly all standard code. – Trevor Lee Oakley Aug 23 '17 at 12:56
  • Yeah, your only practical option is #1, but I just wanted to cover off other options for completeness. Incidentally, I can only see about 7 SSTORE operations in your constructor code, so I'll have to have a closer look at where the gas is actually going. – benjaminion Aug 23 '17 at 13:00