1

This question already has an answer here:

I have some contracts written in solidity and I am testing in geth on a private blockchain. I am seeking something like a console statement to display variables.

I have been trying to work this out but nothing seems to work.

I have no UI and this is all just examining the contract itself without any UI.

Is there anyway to display variables as the program runs or is there any debugging process using geth?

I have looked at events but I cannot get them to display.

marked as duplicate by carver, niksmac, Rob Hitchens - B9lab, Dawny33, Richard Horrocks Aug 24 '17 at 15:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I am looking to debug in geth. The link features Remix and various other tools. I cannot see references to geth except one which talks about MIST. I have found these tools to be too slow. I have a private blockchain and I want to use geth and then a means to debug for example using events or something similar in results. My question is more narrow then the one you linked which is about testing in general of solidity code. – Trevor Lee Oakley Aug 23 '17 at 8:55
  • geth is not a development tool, so the short answer is no: there is no way to display the variables as the contract runs. The linked question includes the best alternatives for debugging line by line (especially Remix). If you want help writing the javascript to listen to events, that belongs in a different question. – carver Aug 23 '17 at 16:31
2

From my personal experience, I'd suggest you to try truffle because deploying contract on geth is a hectic job. Truffle gives you CLI to deploy your contract and it's pretty handy too. You can play with your contracts and do the debugging pretty quickly especially when you like the CLI feel.

A sample of debugging steps using truffle-

$ truffle console
truffle(development)> compile
truffle(development)> migrate
truffle(development)> Contract.new().then(function(res) { a = Contract.at(res.address) })
truffle(development)> a.myFunc()

Hope this helps.

  • I am using truffle and I know about the console. Geth is a really good tool with a lot of functions. I would like if possible to use something actually in geth. Geth takes mins to setup and with a private blockchain you can get something running in a short time. But there is limited debugging AFAIK. – Trevor Lee Oakley Aug 23 '17 at 11:40
  • :) I feel the truffle is fast enough too. Anyways, can you post more info about what you are not able to see on geth console? I can probably try and debug. AFAIK we can read event logs on geth too. – Sanchit Aug 23 '17 at 11:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.