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”
=> I am using  not ganache but private geth,
Details
I made simple Contract called Logic.sol and in truffle folder, and then
- $openzeppelin init .
 
- $openzeppelin compile
 
- $openzeppelin create --network beta Logic --init --args 50000
==> THEN ERROR Appears: “The contract code couldn’t be stored, please check your gas limit.”
(this code used to work on ganache, but failing on private geth…)
is there something I am doing wrong? I am planning to run my own mainnet-geth client in the future, so I am now testing with private-geth. 
 Code to reproduce
“Logic.sol”-----------
    pragma solidity ^0.4.24;
    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;
        }
    }
—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
        },
             
            
              
              
              1 Like
            
            
           
          
            
            
              I don’t know the right answer for your question but I’d like to check the gasLimit in your “private” Geth(maybe check first your genesis.json and then getBlock.gasLimit).
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
Welcome to the community 
I can’t see anything obvious.  The gas used is relatively small.
I suggest deploying a simple contract using Truffle to your private network to check your configuration.
You can also deploy to public testnets (and mainnet) using services such as Infura.  See the documentation for a guide on this:
https://docs.openzeppelin.com/sdk/2.5/public-deploy
             
            
              
              
              
            
            
           
          
            
            
              I succeeded on deploying ropsten,
But I failed on private-geth.  (with almost same config…)
So I am still working-on, Thank you.
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @yong_kim,
I assume there is an issue with your private network or configuration to this network.
You could also try openzeppelin accounts, openzeppelin balance, and openzeppelin transfer on your private network to test connectivity.
             
            
              
              
              
            
            
           
          
            
            
              Good advice.
I tested, but those all work in my private-geth.
So, I think I can exempt the possibility of connectivity issue now.
thank you.
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
I suggest you try deploying a simple contract using truffle and interact with truffle console
    pragma solidity ^0.5.0;
    contract Logic {
        uint maxDeposit;    
        function set(uint _value) public { 
            maxDeposit = _value;
        }
        function getMaxDeposit() public view returns(uint) {
            return maxDeposit;
        }
    }
             
            
              
              
              
            
            
           
          
            
            
              Thank you very much for your rapid suggestion!.
I made Test.sol and deployed with Logic.sol above and it runs well~
I think just *Initialize() is the problem. ^^
const Logic = artifacts.require("./Logic.sol");
const Test = artifacts.require("./Test.sol");
module.exports = function(deployer) {
     deployer.deploy(Logic);
     deployer.deploy(Test);
};
==resut==
truffle migrate --reset --network beta
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name:    'beta'
> Network id:      1990
> Block gas limit: 0x7a1200
1_initial_migration.js
======================
   Replacing 'Migrations'
   ----------------------
   > transaction hash:    0x41c8d0f5085740fa56fae2f8504e066fa3e20ed58c76ef65ddd72d09d340e9c5
   > Blocks: 1            Seconds: 4
   > contract address:    0xfA60c1BE871AbC1953d5C673dF25C50634a574A6
   > block number:        1049
   > block timestamp:     1568705011
   > account:             0x4E28710830e2c910238F60CB03233c91A16f4087
   > balance:             23234465.729235784806170624
   > gas used:            277462
   > gas price:           200 gwei
   > value sent:          0 ETH
   > total cost:          0.0554924 ETH
   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:           0.0554924 ETH
2_deploy_contracts.js
=====================
   Replacing 'Logic'
   -----------------
   > transaction hash:    0xcccc2e76517dbda0068276cfdca7e077cfd6e00b1b224c1a140e31b8af73f6fd
   > Blocks: 0            Seconds: 8
   > contract address:    0x5DfC73bcC2D3bEA42a8CF17572c17222b70fb907
   > block number:        1051
   > block timestamp:     1568705021
   > account:             0x4E28710830e2c910238F60CB03233c91A16f4087
   > balance:             23234475.729235784806170624
   > gas used:            201335
   > gas price:           200 gwei
   > value sent:          0 ETH
   > total cost:          0.040267 ETH
   Deploying 'Test'
   ----------------
   > transaction hash:    0x3fb42bca9e69ab9d2de2e0de4b759092d7ad847c2874e692584e94bdf86157d6
   > Blocks: 0            Seconds: 4
   > contract address:    0x4EBe234bf0B18ceDD28CC2dD96c8E90d361A0dBC
   > block number:        1052
   > block timestamp:     1568705032
   > account:             0x4E28710830e2c910238F60CB03233c91A16f4087
   > balance:             23234485.729235784806170624
   > gas used:            112213
   > gas price:           200 gwei
   > value sent:          0 ETH
   > total cost:          0.0224426 ETH
   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:           0.0627096 ETH
Summary
=======
> Total deployments:   3
> Final cost:          0.118202 ETH
pragma solidity ^0.4.24; contract Test {
    uint maxDeposit;
    function set(uint _value) public {
        maxDeposit = _value;
    }
    function getMaxDeposit() public view returns(uint) {
        return maxDeposit;
    }
}
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
You can try deploying the following contract with Truffle which inherits from Initializable and see if you have any issues. (I updated the pragma solidity to ^0.5.0).
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;
    }
}
             
            
              
              
              
            
            
           
          
            
            
              Thanks @abcoathup,
I upgraded to solidity ^0.5.0; and
migrated with truffle again. and it works well~
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;
    }
} 
===========
   Deploying 'Logic'
   -----------------
   > transaction hash:    0x1f18d7e504bb833c773db6cfc7cb0e8280b8ca71ea8278421a917c334d02b013
   > Blocks: 0            Seconds: 0
   > contract address:    0xcB2C10738725b672E8E608A5A2C025f3D9Cf8EE0
   > block number:        1257
   > block timestamp:     1568705900
   > account:             0x4E28710830e2c910238F60CB03233c91A16f4087
   > balance:             23235505.729235784806170624
   > gas used:            205093
   > gas price:           200 gwei
   > value sent:          0 ETH
   > total cost:          0.0410186 ETH
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
The next thing to try is openzeppelin create with the Logic contract to your private network.
             
            
              
              
              
            
            
           
          
            
            
              Thanks, @abcoathup.
If I create with --init then it fails, but without it it succeeds.
        $ openzeppelin init .
    ? Initial project version 1.0.0
    Project initialized. Write a new contract in the contracts folder and run 'openzeppelin create' to deploy it.
    $ openzeppelin create --network beta  Logic --init --args 50000
    ✓ 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
    ✓ Added contract Logic
    ✓ Contract Logic deployed
    All contracts have been deployed
    ✓ Setting everything up to create contract instances
    ✖ Creating instance for contract at 0x07118daA8212e33DADC538ca61a4787883b6e4aa and calling 'initialize' with:
    - _value (uint256): "50000"
    The contract code couldn't be stored, please check your gas limit.
$ openzeppelin create --network beta  Logic
    ✓ 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
    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 0x2115E44A2A9c07d63931228DdE90984D7763c8F6
    0x2115E44A2A9c07d63931228DdE90984D7763c8F6
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
Can you do openzeppelin create and use the interactive commands to select the contract, the network and to initialize?
$ oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate Logic
? Pick a network development
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
✓ Instance created at 0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B
0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B
             
            
              
              
              
            
            
           
          
            
            
              Thanks @abcoathup,
Yes I tried, but same result.
$ 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.
             
            
              
              
              1 Like
            
            
           
          
            
            
              Hi @Yong_Kim,
One final thing to try is:
openzeppelin create and use the interactive commands but choose No when asked if you want to call a function on the instance after creating it.
Then openzeppelin send-tx and use the interactive commands to call initialize on the contract instance.
$ oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate Logic
? Pick a network development
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 0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
$ oz send-tx
? Pick a network development
? Pick an instance Logic at 0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
? Select which function * initialize(_value: uint256)
? _value (uint256): 42
✓ Transaction successful. Transaction hash: 0x071f283089fb99f9ffcd8f4ba67a6d5e2a0779f206b7ae6b7f5c56ba29414eaf
             
            
              
              
              1 Like
            
            
           
          
            
            
              Thanks, @abcoathup
Final sugesstion succeeded!!
Great help to me, I can move on to next step owing to you!
Really thank~~
$ 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
             
            
              
              
              1 Like
            
            
           
          
          
            
            
              Thanks, @abcoathup
And I am posting error of next step here....
On same environment of PrivateGeth, After oz create, and oz send-tx
Truffle console test fails with
Error: Returned values aren't valid, did it run Out of Gas?
(it used to work on ganache)
$ truffle console --network beta
truffle(beta)> let abi = require("./build/contracts/Logic.json").abi
undefined
truffle(beta)> let contract = new web3.eth.Contract(abi, "0x5EA3A037454C7B4a3be2Eb32D54cB1DDbdE9F75e")
undefined
truffle(beta)> contract.methods.getMaxDeposit().call();
Error: Returned values aren't valid, did it run Out of Gas?
    at t._setReadyState [as _onHttpResponseEnd] (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)
    at t.dispatchEvent [as _setReadyState] (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
    at t.call [as dispatchEvent] (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at t.callback [as onreadystatechange] (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/web3/node_modules/web3-providers-http/src/index.js:96:1)
    at end (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/web3-provider-engine/subproviders/provider.js:19:1)
    at eachSeries (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/web3-provider-engine/index.js:134:1)
    at fn (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/async/internal/doLimit.js:9:1)
    at t.default (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/async/eachLimit.js:43:1)
    at replenish (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/async/internal/eachOfLimit.js:71:1)
    at callback (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/async/internal/eachOfLimit.js:61:1)
    at apply (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/async/internal/once.js:12:1)
    at finished (/Users/kimyong/workspace/blocery-mvp/truffle5/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/web3-provider-engine/index.js:159:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:147:1
    at sendTxCallback (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-core-method/src/index.js:473:1)
    at Method.formatOutput (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-core-method/src/index.js:163:1)
    at Method.outputFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:818:1)
    at Contract._decodeMethodReturn (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:465:1)
    at ABICoder.decodeParameters (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/src/index.js:226:1)
             
            
              
              
              1 Like
            
            
           
          
            
            
              FYI, I tested your contract in my local Geth(v1.9.2). I can’t reproduce your error.
Logic.sol is same and networks.js is
const HDWalletProvider = require('truffle-hdwallet-provider');
module.exports = {
  networks: {
    development: {
      protocol: 'http',
      host: 'localhost',
      port: 7545,
      gas: 5000000,
      gasPrice: 5e9,
      networkId: '*',
    },
    local_geth: {
      provider: ()=> new HDWalletProvider(["cae19a0a3...9b74cfa"], "http://127.0.0.1:8545/"),
      gas:6000000,
      networkId: 44
    }
  },
};
root@0a23bee8b631:~/sandbox/ozdapp# oz create --network local_geth
Nothing to compile, all contracts are up to date.
? 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? Yes
? Select which function * initialize(_value: uint256)
? _value (uint256): 5000
✓ Instance created at 0x82163D38B04d5F8B35D9bF63f14602509420f309
If I set gas to 9000000(more than 8000000 in my genesis config)  an error occured with different error message from yours.
root@0a23bee8b631:~/sandbox/ozdapp# oz create --network local_geth
Nothing to compile, all contracts are up to date.
? 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? Yes
? Select which function * initialize(_value: uint256)
? _value (uint256): 5000
✖ Creating instance for contract at 0x5aA5142103cb6c6f01df5CcD5C3fD0Cc545F78fe and calling 'initialize' with:
- _value (uint256): "5000"
exceeds block gas limit
I don’t remember right but there is some option of gasLimit when starting Geth. I hope this is helpful.
             
            
              
              
              1 Like
            
            
           
          
            
            
              Thanks, @swkim109
In case of me, when I upgrade my local-Geth to v1.9.3, it still reproduce errors.
Can you post your Genesis.json for me?
             
            
              
              
              1 Like