0

I just tried to deploy a smart contract to the mainnet. The transaction failed: Etherscan link

The error is

Warning! Error encountered during contract execution [Reverted]

Before I tried to deploy this on the mainnet, I had tried it on Ropsten (same code), and it worked perfectly. The gas consumed on ropsten was 5,694,718. The gas limit set for the mainnet transaction was 6,000,000, but clearly the failure is not because of gas anyway, as the failed transaction consumed only 731,989.

Given the size of the transaction (and the unused gas in the transaction), I was expecting the gas used on the block overall to be less. The block gas limit was 7,959,257 out of which 7,976,645 was consumed (99.78%). Given that my transaction had more than 5,000,000 of unused gas, shouldn't the block's gas utilization by less as well?

Could that be a possible reason for the failure? That my contract creation never got to use all the gas it needed and the block gas limit got reached before? It would be strange behavior if that was the case.

I did try to debug the transaction in remix, but not very useful. The debugger loads but when I click on next, it doesn't even appear to hit the smart contract constructor.

Any thoughts on the problem would be very welcome.

0

From the geth trace in etherscan it seems your constructor is reverting because it is expecting a zero value but you are sending 3 wei.

If you send ether with your contract deployment the constructor should be made payable.

| improve this answer | |
  • Perfect, that was exactly the problem, thanks Ismael. I always thought the value field in remix specifies the gwei you want to use for the contract creation transaction. Never knew it was passed into the constructor. – Mohammad Khalid Jun 13 '18 at 5:43
-1

You'll not be able to deploy that contract on the mainnet, because it consumes too much gas.

Ethereum blocks don't have a limit in size, but do have a limit for the gas used in all the transactions in that block. And that limit is called block gas limit.

Currently, the block gas limits for the two networks are:

Deploying your contract is taking 100% of the available gas for the entire block, and it seems that those 500.000 gas difference between the two networks is what allows you to deploy to ropsten, but not to the mainnet.

You should check your contract, it's a lot of gas.

| improve this answer | |
  • thanks for the reply. Actually the gas used to create the smart contract is 5,694,718 (on ropsten), which is less than the 8,000,000 limit on mainnet, so it's around 70% of the block gas limit – Mohammad Khalid Jun 12 '18 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.