Sometimes in the scripts I run there are errors (for example one variable is undefined), and geth doesn't stop, it tries to run every line of the script, throwing errors everywhere.

I want to abort the script if I detect an error, but I don't how I can do that, the usual javascript functions don't work here. exit() (or exit) gives ReferenceError: 'exit' not defined, which is weird because when I'm in the console exit works fine.

How do I exit the script ? Is it possible ?

  • Most likely you should not scripts in the geth console in the first place. Instead you want to run your JavaScript within Node.js that connects gets. Please see this answer: ethereum.stackexchange.com/a/11203/620 Jan 17, 2017 at 22:17

1 Answer 1


With ethereum-console you can use process.exit().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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