Interactive use: the JSRE REPL Console
console subcommand starts the Energi3 node and then opens the console. The
attach subcommand will not start the Energi3 node but instead tries to open the console on a running Core Node instance.
The attach mode accepts an endpoint in case the Core Node is running with a non default ipc endpoint or you would like to connect over the rpc interface.
energi3 attach ipc:/some/custom/path
energi3 attach http://126.96.36.199:39796
energi3 attach ws://188.8.131.52:39795
Note that by default the Energi3 node doesn't start the http and websocket service and not all functionality is provided over these interfaces due to security reasons. These defaults can be overridden when the
--wsapi arguments when the Energi3 node is started, or with
If you need log information, start with:
energi3 --verbosity 5 console 2>> /tmp/energi3.log
Otherwise mute your logs, so that it does not pollute your console:
energi3 console 2>> /dev/null
energi3 --verbosity 0 console
energi3 --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js" console
Non-interactive use: JSRE script mode
energi3 --exec "eth.blockNumber" attach
This prints the current block number of a running Energi3 instance.
Or execute a local script with more complex statements on a remote node over http:
energi3 --exec 'loadScript("/tmp/checkbalances.js")' attach http://184.108.40.206:39796
energi3 --jspath "/tmp" --exec 'loadScript("checkbalances.js")' attach http://220.127.116.11:39796
--jspath <path/to/my/js/root> to set a libdir for your js scripts. Parameters to
loadScript() with no absolute path will be understood relative to this directory.
You can exit the console cleanly by typing exit or simply with Ctrl + C.
The JSRE uses the Otto JS VM which has some limitations:
"use strict" will parse, but does nothing.
The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification. Note that the other known limitation of Otto (namely the lack of timers) is taken care of. The JSRE implements both
setInterval. In addition to this, the console provides
admin.sleep(seconds)as well as a "blocktime sleep" method
web3.js uses the
bignumber.js library (MIT Expat Licence), it is also autoloaded.
In addition to the full functionality of JS (as per ECMA5), the JSRE is augmented with various timers. It implements
clearTimeout you may be used to using in browser windows. It also provides implementation for
admin.sleep(seconds) and a block based timer,
admin.sleepBlocks(n) which sleeps until the number of new blocks added is equal to or greater than n; think "wait for
Beside the official DApp API interface the Energi Core Node has support for additional management API's. These API's are offered using JSON-RPC and follow the same conventions used in the DApp API. The Energi3 package comes with a console client which has support for all additional API's.