1

Is it feasible to debug a solidity contract using the go-ethereum evm command? And what would be the steps required to do so?

  • Possible duplicate of How to quickly test a Solidity function? – niksmac Jul 31 '17 at 9:34
  • I edited the question, this is not a question of evm as such, but the command line evm in go-ethereum. The original question was ambiguous, sorry. – lash Jul 31 '17 at 10:21
3

Sure. The Remix online IDE is great for this. Paste in your contract code, set up the compilation options and execution environment (JavaScript VM is good to start with).

After deploying your contract or executing one of its methods, a button appears:

enter image description here

If you click this, it takes you to a debugger tab where you can step through, using the buttons provided, the EVM code as it was executed for that transaction. Hover over the buttons to see their description.

enter image description here

All sorts of EVM state data is available as you step through:

enter image description here

You can expand these tabs to see the data. The most useful bits for me are viewing (1) the instructions (EVM bytecode as it is executed), (2) the stack, (3) the memory, (4) the storage. But other info is sometimes useful. It's a great learning environment.

In the left-pane, the browser highlights which bit of the Solidity code are currently being executed. This is not 100% reliable or intuitive, but is a helpful guide for debugging.

enter image description here

  • For the benefit of future generations - this answer was written before the question was edited to be specific to the Geth evm command :-) Enjoy, anyway. – benjaminion Jul 31 '17 at 15:07
0

Well to debug your solidity contract, I strongly advise you to use ethereum IDE (like Remix). Generally It enable you to pass the compilation (otherwise errors showed by the compilator don't tell you anything).

Then if you want to debug your function I advise you to use the truffle framework with enable you to "test" your contract functions. When you deploy your framework on the private blockchain (or the test blockchain) you can test your functions easily.

With truffle what you do is :

  • init your project (truffle init)
  • write your contract in contract/ and write the test function of your contract in test/ and compile it truffle compile
  • then test your contract with truffle test command

I strongly recommand you to deploy and test your contract on the testrpc network or private blockchain first before deploying on the real ethereum blockchain.

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.