3

I have my private Ethereum Network.

Inside Solidity Browser:

  1. From Web3 Provider I have connected to my local ethereum node.
  2. I have pressed create button and successfully deployed my contract.
  3. Now I could call any function inside my contract and all deployed without having any problem.

enter image description here

As an example: I have deployed insertfront(string val) transaction inside Solidity Browser (To get mined takes around a minute). Gas costs is 203893.

enter image description here

Inside Geth:

  1. Connect into private ethereum network.
  2. Obtain address and abi (located inside the interface box) from the Solidity Browser that will point the deployed contract.

    enter image description here

  3. var mycontract = eth.contract(abi).at(address)

mycontract { ... insertfront: function(), allEvents: function(), construct: function(), delete_: function(), delete_items: function(), deleteback: function(), deletefront: function(), get: function(), get_: function(), get_map: function(), ... }

  1. mycontract.deletefront( {from: eth.accounts[0]} ) //This works inside geth and function does what it has to do. Transaction mines and deploys. deletefront() function's gas usage is 41920.
  2. But when I call insertfront(string val) function inside geth (please not that transaction has costed 203893 gas inside Solidity Browser), it never deploys or mines in my blockchain (I have waited hours but no help).

    > mycontract.insertfront("some_string", {from: eth.accounts[0]} ) "0x7048278dcdb02c02894082af541c73ad6a8e0e37cf1ab90ac914c58cc2d2f983"

//But it has no affect and did not done the what function has to do.

[Q] Why function that is deploy inside Solidity browser does not deployed inside geth? Could it be because usage of high gas amount for a function?

Thank you for your valuable time and help.

1

I wouldn't know right off, but I'd suspect it's indeed a gas problem. geth, by default, provides only 90k gas, which wouldn't be enough. You can set the gas inside the transaction like this: {from: eth.accounts[0], gas: 300000}. Note that you'll want to set the gas, not the gasPrice. Don't worry about getting it exact, since any unused gas is refunded.

Here's an additional tip to help debug: use web3.getTransaction() and web3.getTransactionReceipt(). The hex string geth is giving you after a transaction (i.e. "0x7048278dcdb02c02894082af541c73ad6a8e0e37cf1ab90ac914c58cc2d2f983") is the hash of that transaction. By using getTransactionReceipt(hash), you'll see what happened. If getTransactionReceipt() says the transaction used as much gas as getTransaction() said it had in the first place, the transaction most likely went out of gas.

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.