I'm trying to configure a 1-node private network to mine transactions as they come in.

I found this question which has a script that can be loaded into geth to do exactly this. However, I need to go into the Geth console and run loadScript manually for it to work and be called, and after I close the console session, the script file has to be loaded again to run the function.

The problem I have is invoking loadScript in Go to have it run automatically.

The following I tried with no success: RpcClient.Call(&result, "loadScript", "./scripts/auto_mine.js")

1 Answer 1


You can run the linked script in NodeJS, by including web3 and connecting to your locally-running node.

You shouldn't need to use the javascript repl in geth at all. If you run the script in Node, you can even set it up to poll on particular intervals, or watch for new transactions using filters.

  • For this project, the goal was to have it run entirely on the Go server for simplicity. But this is a better, more general answer that applies to all geth scripts.
    – thanos
    Commented May 30, 2017 at 16:46
  • For what it's worth, you could also try using the js command line option, which loads and executes a specified javascript file when starting or attaching to a geth instance. Commented May 31, 2017 at 2:35

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.