1

I am trying to setup a contract in my private ethereum network. For that, I picked up a sample contract code from the internet:

pragma solidity ^0.4.19;

contract getSchwifty {
  string internal constant seeWhatYouGot = "I want to see what you got!";
  string internal contestResult;

  // Contract constructor that takes a string param
  function getSchwifty(string _contestResult) public {
    contestResult = _contestResult;
  }

  function showMeWhatYouGot() external pure returns (string) {
    return seeWhatYouGot;  
  }

  function enterContest(string _contestEntry) external view returns (string) {
    // completely disregard the _contestEntry ;)
    return contestResult;
  }
} 

I compiled the abi and bytecode for this and am using it to deploy the contract.

var getSchwifty = eth.contract(<ABI generated from solc --abicommand>)
var bytecode = '0x<bytecode generated from solc --bin command>'

and then did

var deploy = {from:eth.coinbase, data:bytecode, gas: 4000}
var getSchwiftyPartialInstance = getSchwifty.new("DISQUALIFIED!", deploy)

basically here I am trying to create a new instance of the contract I wrote above I guess. However, the last step fails with the error:

> var getSchwiftyPartialInstance = getSchwifty.new("TEST", deploy)
Error: intrinsic gas too low
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at web3.js:3021:24
    at <anonymous>:1:34

I tried: eth.getBlock("latest").gasLimit. this gives 5003. I have set gasLimit to the same value in genesis.json as well.

I get the above error for different values of gas in var deploy = {from:eth.coinbase, data:bytecode, gas: 4000}. If I increase the value to something higher than the limit obtained from: eth.getBlock("latest").gasLimit, I get an error: exceeds gas limit.

Any suggestions on what could be wrong and what steps I could take. I did ensure that the peer is talking other peers.

  • 1
    Intrinsic gas is 21000, every transaction must pay at least that much. You will likely need much more for deploying a contract. – Raghav Sood Sep 27 '18 at 6:45
  • where does eth.getBlock("latest").gasLimit get its value from? EVen with gas Limit much higher, this command always gives me around 5003. – techieChamp Sep 27 '18 at 6:50
  • I'm not sure why you're getting 5003, but that command will usually give the maximum possible gas that block could have consumed. It seems odd that it is under the intrinsic gas, though – Raghav Sood Sep 27 '18 at 6:54
  • Thanks for the comment @RaghavSood. Not sure if it matters, this is a private ethereum network(geth). – techieChamp Sep 27 '18 at 6:56
  • And sometimes, I get an error: insufficient funds for gas * price + value if I decrease the value of gas in: var deploy = {from:eth.coinbase, data:bytecode, gas: 4000} – techieChamp Sep 27 '18 at 6:59

Your Answer

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

Browse other questions tagged or ask your own question.