Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

oz create to private geth network: The contract code couldn't be stored, please check your gas limit. #1236

Closed
abcoathup opened this issue Sep 17, 2019 · 1 comment

Comments

@abcoathup
Copy link
Contributor

oz create with initialize to private geth network fails with "The contract code couldn't be stored, please check your gas limit."

Reported in the forum: https://forum.openzeppelin.com/t/openzeppelin-create-on-private-geth-check-your-gas-limit-error/1357

💻 Environment

“openzeppelin”: “2.5.3”,
“truffle”: “5.0.34”,
“solidity”: “0.4.24”
“web3”: “1.2.1”,
“private geth client”: “geth-darwin-amd64-1.8.22”

Truffle.js

        beta: { 
            provider: function() {  //below coinbase account has much ETH.           
                return new HDWalletProviderPriv(['..privatekey...'], "http://127.0.0.1:8545/");
            },
            gas:6000000,  //default 4712388
            gasPrice:3000000000, 
            network_id: 1990
        },

Logic.sol

pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";

contract Logic is Initializable {
    uint maxDeposit;    

    function initialize(uint _value) initializer public { 
        maxDeposit = _value;
    }
    function getMaxDeposit() public view returns(uint) {
        return maxDeposit;
    }
}

oz create and initialize

Fails with error: "The contract code couldn't be stored, please check your gas limit."

$ oz create
✓ Compiling contracts with Truffle, using settings from truffle.js file
Truffle output:

Compiling your contracts...
===========================
> Compiling ./contracts/Logic.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Test.sol
> Compiling @openzeppelin/upgrades/contracts/Initializable.sol
> Artifacts written to /Users/kimyong/workspace/blocery-mvp/truffle5/build/contracts
> Compiled successfully using:
   - solc: 0.5.0+commit.1d4f565a.Emscripten.clang


? Pick a contract to instantiate Logic
? Pick a network beta
All contracts are up to date
? Do you want to call a function on the instance after creating it? Yes
? Select which function * initialize(_value: uint256)
? _value (uint256): 42
✖ Creating instance for contract at 0x07118daA8212e33DADC538ca61a4787883b6e4aa and calling 'initialize' with:
- _value (uint256): "42"
The contract code couldn't be stored, please check your gas limit.

oz create then oz send-tx to initialize succeeds

$ oz create --network beta
✓ Compiling contracts with Truffle, using settings from truffle.js file
Truffle output:

Compiling your contracts...
===========================
> Compiling ./contracts/Logic.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Test.sol
> Compiling @openzeppelin/upgrades/contracts/Initializable.sol
> Artifacts written to /Users/kimyong/workspace/blocery-mvp/truffle5/build/contracts
> Compiled successfully using:
   - solc: 0.5.0+commit.1d4f565a.Emscripten.clang


? Pick a contract to instantiate Logic
All contracts are up to date
? Do you want to call a function on the instance after creating it? No
Possible initialization method (initialize) found in contract. Make sure you initialize your instance.
✓ Instance created at 0x5EA3A037454C7B4a3be2Eb32D54cB1DDbdE9F75e
0x5EA3A037454C7B4a3be2Eb32D54cB1DDbdE9F75e
$ oz send-tx --network beta
? Pick an instance Logic at 0x5EA3A037454C7B4a3be2Eb32D54cB1DDbdE9F75e
? Select which function * initialize(_value: uint256)
? _value (uint256): 50000
✓ Transaction successful. Transaction hash: 0x00e08a490c76342aa565fff18edc1a5048682fd4011e11bbec6cd13405c7c75a
@abcoathup
Copy link
Contributor Author

Adding "constantinopleFixBlock" to genesis.json of the private geth network resolved the issue.

See the forum for details:
https://forum.openzeppelin.com/t/openzeppelin-create-on-private-geth-check-your-gas-limit-error/1357/22

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant