I have the following example smart contract, where I cannot deploy using remix into my private network using environment Web3 provider. The error I am getting is Transaction mined but execution failed due to construction.

Please note, that my actual smart contract takes around 6.500.000 gas to deploy. I can deploy it if its constructor is empty, but I cannot if I set a storage variable in the constructor like I shown on the example.

Update: I am able to deploy my contract using solidity ^0.5.0 but higher versions does not work.

pragma solidity ^0.5.7;

contract Contract {
    address public owner;
    constructor() public
        owner = msg.sender;     

    function set() public {
        owner = msg.sender;

Transaction receipt:

enter image description here

When I comment out owner = msg.sender; the contract deploys successfully. But later if I call the set function, I get Gas estimation failed warning message and the set() does not deploy.

enter image description here

When I call the set() function warning message:

enter image description here

  • What is your gasLimit parameter? Only can reproduce your error with optimization enabled. – alberto Jul 9 '19 at 12:45
  • I have set gas limit as 8000000 @alberto – alper Jul 9 '19 at 12:46
  • remix has a lot of bugs – Majd TL Jul 9 '19 at 14:11
  • I've tested with a private blockchain (geth) setting differents gaslimit and the problem is related with the optimization option of the old layout. I don't know why, but Remix try to spend all the available gas of the block with the optimization enabled (doesn't matter how much gas you've set in the gaslimit). With the new layout everything goes well with optimization enabled or disabled. Also tested with Truffle and the contract was deployed correctly with optimization and without it. – alberto Jul 9 '19 at 15:51
  • I am having same error on the remix's new interface as well for main contract to deploy 6.500.000 gas and if constructor is empty it is deployed @alberto – alper Jul 9 '19 at 20:17

Update: I am able to deploy my contract using solidity ^0.5.0 but higher versions does not work.

Is your private network using the Constantinople EVM? If you can deploy 0.5.0 but not 0.5.7, you might be on Byzantium. In Remix, on the compiler tab, try changing the EVM version from "compiler default" to "Byzantium" and see if you're able to deploy successfully.

| improve this answer | |
  • My private chain uses Byzantium EVM, I am able to deploy successfully when I made the change as you recommended @iamdefinitelyahuman – alper Jul 10 '19 at 21:02

It works perfectly for me using Remix (compile 5.10) and parity private network. enter image description here

Try to enable/disable optimization it might help you.

enter image description here

| improve this answer | |
  • you can enable optimization in the new remix. you have to activate solidity compiler plugin then disable optimization. – Badr Bellaj Jul 9 '19 at 12:29
  • Please not that I am using old remix interface, my original contract was much complicated which consumes 6500000 gas with the same construction. When I remove construction I was able to deploy my contract but I cannot if I set storage on the construction. @Badr Bellaj♦ – alper Jul 9 '19 at 12:31
  • try to change the compiler – Badr Bellaj Jul 9 '19 at 12:32
  • I have tried 5.10 but still facing with the same error @Badr Bellaj♦ – alper Jul 9 '19 at 13:07
  • Which chain are you using? – Badr Bellaj Jul 9 '19 at 13:41

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.