diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index f8a4da490..75e5c8610 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -78,3 +78,73 @@ + [uninstallFilter](./json-rpc/methods/shh/uninstallFilter.md) + [getFilterChanges](./json-rpc/methods/shh/getFilterChanges.md) + [getMessages](./json-rpc/methods/shh/getMessages.md) + +## Javascript Console (JSRE) +- [About](./jsre.md) +- [Interactive Use](./jsre/interactive-use.md) +- [Non-interactive Use](./jsre/non-interactive-use.md) +- [Caveats](./jsre/caveats.md) +- [Timers](./jsre/timers.md) +- [Management Apis](./jsre/management-apis.md) +- [How To](./jsre/how-to.md) +- [Integration](./jsre/integration.md) +- Methods + + [admin](./jsre/methods/admin/admin.md) + + [nodeInfo](./jsre/methods/admin/nodeInfo.md) + + [addPeer](./jsre/methods/admin/addPeer.md) + + [peers](./jsre/methods/admin/peers.md) + + [importChain](./jsre/methods/admin/importChain.md) + + [exportChain](./jsre/methods/admin/exportChain.md) + + [startRPC](./jsre/methods/admin/startRPC.md) + + [stopRPC](./jsre/methods/admin/stopRPC.md) + + [startWS](./jsre/methods/admin/startWS.md) + + [stopWS](./jsre/methods/admin/stopWS.md) + + [sleep](./jsre/methods/admin/sleep.md) + + [sleepBlocks](./jsre/methods/admin/sleepBlocks.md) + + [datadir](./jsre/methods/admin/datadir.md) + + [setSolc](./jsre/methods/admin/setSolc.md) + + [startNatSpec](./jsre/methods/admin/startNatSpec.md) + + [stopNatSpec](./jsre/methods/admin/stopNatSpec.md) + + [getContractInfo](./jsre/methods/admin/getContractInfo.md) + + [saveInfo](./jsre/methods/admin/saveInfo.md) + + [register](./jsre/methods/admin/register.md) + + [registerUrl](./jsre/methods/admin/registerUrl.md) + - [personal](./jsre/methods/personal/personal.md) + + [listAccounts](./jsre/methods/personal/listAccounts.md) + + [newAccount](./jsre/methods/personal/newAccount.md) + + [unlockAccount](./jsre/methods/personal/unlockAccount.md) + - [geth](./jsre/methods/geth/geth.md) + + [getAddressTransactions](./jsre/methods/geth/getAddressTransactions.md) + - [txpool](./jsre/methods/txpool/txpool.md) + + [status](./jsre/methods/txpool/status.md) + - [miner](./jsre/methods/miner/miner.md) + + [start](./jsre/methods/miner/start.md) + + [stop](./jsre/methods/miner/stop.md) + + [startAutoDAG](./jsre/methods/miner/startAutoDAG.md) + + [stopAutoDAG](./jsre/methods/miner/stopAutoDAG.md) + + [makeDAG](./jsre/methods/miner/makeDAG.md) + + [setExtra](./jsre/methods/miner/setExtra.md) + + [setGasPrice](./jsre/methods/miner/setGasPrice.md) + + [setEtherbase](./jsre/methods/miner/setEtherbase.md) + - [debug](./jsre/methods/debug/debug.md) + + [setHead](./jsre/methods/debug/setHead.md) + + [seedHash](./jsre/methods/debug/seedHash.md) + + [getBlockRlp](./jsre/methods/debug/getBlockRlp.md) + + [printBlock](./jsre/methods/debug/printBlock.md) + + [dumpBlock](./jsre/methods/debug/dumpBlock.md) + + [metrics](./jsre/methods/debug/metrics.md) + + [accountExist](./jsre/methods/debug/accountExist.md) + - [eth](./jsre/methods/eth/eth.md) + + [pendingTransactions](./jsre/methods/eth/pendingTransactions.md) + + [sign](./jsre/methods/eth/sign.md) + + [resend](./jsre/methods/eth/resend.md) + - [additional interfaces](./jsre/methods/interfaces/additional-interfaces.md) + + [loadScript](./jsre/methods/interfaces/loadScript.md) + + [web3](./jsre/methods/interfaces/web3.md) + + [net](./jsre/methods/interfaces/net.md) + + [shh](./jsre/methods/interfaces/shh.md) + + [inspect](./jsre/methods/interfaces/inspect.md) + + + + diff --git a/docs/jsre/caveats.md b/docs/jsre/caveats.md new file mode 100644 index 000000000..d4d9b0fb1 --- /dev/null +++ b/docs/jsre/caveats.md @@ -0,0 +1,10 @@ +## Caveat + +The go-ethereum JSRE uses the [Otto JS VM](https://github.com/robertkrimen/otto) 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. Ethereum JSRE implements both `setTimeout` and `setInterval`. In addition to this, the console provides `admin.sleep(seconds)` as well as a "blocktime sleep" method `admin.sleepBlocks(number)`. + +Since `web3.js` uses the [`bignumber.js`](https://github.com/MikeMcl/bignumber.js) library (MIT Expat Licence), it is also autoloded. diff --git a/docs/jsre/how-to.md b/docs/jsre/how-to.md new file mode 100644 index 000000000..d29336b8e --- /dev/null +++ b/docs/jsre/how-to.md @@ -0,0 +1,34 @@ +# How to +It is possible to specify the set of API's which are offered over an interface with the `--${interface}api` command line argument for the go ethereum daemon. Where `${interface}` can be `rpc` for the `http` interface or `ipc` for an unix socket on unix or named pipe on Windows. + +For example, `geth --ipcapi "admin,eth,miner" --rpcapi "eth,web3"` will +* enable the admin, official DApp and miner API over the IPC interface +* enable the eth and web3 API over the RPC interface + +Please note that offering an API over the `rpc` interface will give everyone access to the API who can access this interface (e.g. DApp's). So be careful which API's you enable. By default geth enables all API's over the `ipc` interface and only the eth,net and web3 API's over the `rpc` and `ws` interface. + +To determine which API's an interface provides the `modules` transaction can be used, e.g. over an `ipc` interface on unix systems: + +``` +echo '{"jsonrpc":"2.0","method":"rpc_modules","params":[],"id":1}' | socat -,ignoreeof UNIX-CONNECT:$HOME/.ethereum/geth.ipc +``` +will give all enabled modules including the version number: +``` +{ + "id": 1, + "jsonrpc": "2.0", + "result": { + "admin": "1.0", + "debug": "1.0", + "eth": "1.0", + "miner": "1.0", + "net": "1.0", + "personal": "1.0", + "rpc": "1.0", + "txpool": "1.0", + "web3": "1.0", + "geth": "1.0" + } +} + +``` \ No newline at end of file diff --git a/docs/jsre/integration.md b/docs/jsre/integration.md new file mode 100644 index 000000000..698eb3a25 --- /dev/null +++ b/docs/jsre/integration.md @@ -0,0 +1,20 @@ +## Integration +These additional API's follow the same conventions as the official DApp API. Web3 can be [extended](https://github.com/ethereumproject/web3.js/pull/229) and used to consume these additional API's. + +The different functions are split into multiple smaller logically grouped API's. Examples are given for the [Javascript console](./JavaScript-Console) but can easily be converted to a rpc request. + +**2 examples:** + +* Console: `miner.start()` + +* IPC: `echo '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":1}' | socat -,ignoreeof UNIX-CONNECT:$HOME/.ethereum/geth.ipc` + +* RPC: `curl -X POST --data '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":74}' localhost:8545` + +With the number of THREADS as an arguments: + +* Console: `miner.start(4)` + +* IPC: `echo '{"jsonrpc":"2.0","method":"miner_start","params":["0x04"],"id":1}' | socat -,ignoreeof UNIX-CONNECT:$HOME/.ethereum/geth.ipc` + +* RPC: `curl -X POST --data '{"jsonrpc":"2.0","method":"miner_start","params":["0x04"],"id":74}' localhost:8545` \ No newline at end of file diff --git a/docs/jsre/interactive-use.md b/docs/jsre/interactive-use.md new file mode 100644 index 000000000..f20ac5dc4 --- /dev/null +++ b/docs/jsre/interactive-use.md @@ -0,0 +1,38 @@ +## Interactive use: the JSRE REPL Console + +The `ethereum CLI` executable `geth` has a JavaScript console (a **Read, Evaluate & Print Loop** = REPL exposing the JSRE), which can be started with the `console` or `attach` subcommand. The `console` subcommands starts the geth node and then opens the console. The `attach` subcommand will not start the geth node but instead tries to open the console on a running geth instance. + +```shell +$ geth 2>>out.log console # redirect logs to a file and begin interactive console session +``` + +```shell +$ geth # terminal 1 +$ geth attach # terminal 2 +``` + +The attach node accepts an endpoint in case the geth node is running with a non default ipc endpoint or you would like to connect over the rpc interface. + + $ geth attach ipc:/some/custom/path + $ geth attach http://191.168.1.1:8545 + $ geth attach ws://191.168.1.1:8546 + +Note that by default the geth node doesn't start the http and weboscket service and not all functionality is provided over these interfaces due to security reasons. These defaults can be overridden when the `--rpcapi` and `--wsapi` arguments when the geth node is started, or with [admin.startRPC](admin_startRPC) and [admin.startWS](admin_startWS). + +If you need log information, start with: + + $ geth --verbosity 5 console 2>> /tmp/eth.log + +Otherwise mute your logs, so that it does not pollute your console: + + $ geth console 2>> /dev/null + +or + + $ geth --verbosity 0 console + +Geth has support to load custom JavaScript files into the console through the `--preload` argument. This can be used to load often used functions, setup web3 contract objects, or ... +``` +geth --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js" console +``` + diff --git a/docs/jsre/management-apis.md b/docs/jsre/management-apis.md new file mode 100644 index 000000000..e0a275d50 --- /dev/null +++ b/docs/jsre/management-apis.md @@ -0,0 +1,3 @@ +# Management APIs + +Beside the official [DApp API](https://github.com/ethereumproject/wiki/wiki/JSON-RPC) interface the go ethereum node has support for additional management API's. These API's are offered using [JSON-RPC](http://www.jsonrpc.org/specification) and follow the same conventions as used in the DApp API. The go ethereum package comes with a console client which has support for all additional API's. \ No newline at end of file diff --git a/docs/jsre/methods/admin/addPeer.md b/docs/jsre/methods/admin/addPeer.md new file mode 100644 index 000000000..ce2e02e9b --- /dev/null +++ b/docs/jsre/methods/admin/addPeer.md @@ -0,0 +1,23 @@ + +#### admin.addPeer + +admin.addPeer(nodeURL) + +Pass a `nodeURL` to connect a to a peer on the network. The `nodeURL` needs to be in [enode URL format](https://github.com/ethereumproject/wiki/wiki/enode-url-format). geth will maintain the connection until it +shuts down and attempt to reconnect if the connection drops intermittently. + +You can find out your own node URL by using [nodeInfo](#adminnodeinfo) or looking at the logs when the node boots up e.g.: + +``` +[P2P Discovery] Listening, enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@54.169.166.226:30303 +``` + +##### Returns + +`true` on success. + +##### Example + +```javascript +> admin.addPeer('enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@54.169.166.226:30303') +``` diff --git a/docs/jsre/methods/admin/admin.md b/docs/jsre/methods/admin/admin.md new file mode 100644 index 000000000..24baa94b4 --- /dev/null +++ b/docs/jsre/methods/admin/admin.md @@ -0,0 +1,3 @@ +### Admin + +The `admin` exposes the methods to manage, control or monitor your node. It allows for limited file system access. diff --git a/docs/jsre/methods/admin/datadir.md b/docs/jsre/methods/admin/datadir.md new file mode 100644 index 000000000..299cb3790 --- /dev/null +++ b/docs/jsre/methods/admin/datadir.md @@ -0,0 +1,17 @@ + +#### admin.datadir + +admin.datadir + +the directory this nodes stores its data + +##### Returns + +directory on success + +##### Example + +```javascript +admin.datadir +'/Users/username/Library/Ethereum' +``` diff --git a/docs/jsre/methods/admin/exportChain.md b/docs/jsre/methods/admin/exportChain.md new file mode 100644 index 000000000..68f185c6d --- /dev/null +++ b/docs/jsre/methods/admin/exportChain.md @@ -0,0 +1,16 @@ + +#### admin.exportChain + +admin.exportChain(file) + +Exports the blockchain to the given file in binary format. + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.exportChain('path/to/file') +``` diff --git a/docs/jsre/methods/admin/getContractInfo.md b/docs/jsre/methods/admin/getContractInfo.md new file mode 100644 index 000000000..f8e09cfb4 --- /dev/null +++ b/docs/jsre/methods/admin/getContractInfo.md @@ -0,0 +1,18 @@ + +#### admin.getContractInfo + +admin.getContractInfo(address) + +this will retrieve the [contract info json](./Contracts-and-Transactions#contract-info-metadata) for a contract on the address + +##### Returns + +returns the contract info object + +##### Examples + +```js +> info = admin.getContractInfo(contractaddress) +> source = info.source +> abi = info.abiDefinition +``` diff --git a/docs/jsre/methods/admin/importChain.md b/docs/jsre/methods/admin/importChain.md new file mode 100644 index 000000000..5bb721d0c --- /dev/null +++ b/docs/jsre/methods/admin/importChain.md @@ -0,0 +1,19 @@ + +#### admin.importChain + +admin.importChain(file) + +Imports the blockchain from a marshalled binary format. +**Note** that the blockchain is reset (to genesis) before the imported blocks are inserted to the chain. + + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.importChain('path/to/file') +// true +``` diff --git a/docs/jsre/methods/admin/nodeInfo.md b/docs/jsre/methods/admin/nodeInfo.md new file mode 100644 index 000000000..2dae7a22b --- /dev/null +++ b/docs/jsre/methods/admin/nodeInfo.md @@ -0,0 +1,26 @@ + +#### admin.nodeInfo + +admin.nodeInfo + +##### Returns + +information on the node. + +##### Example + +``` +> admin.nodeInfo +{ +Name: 'Ethereum(G)/v0.9.36/darwin/go1.4.1', +NodeUrl: 'enode://c32e13952965e5f7ebc85b02a2eb54b09d55f553161c6729695ea34482af933d0a4b035efb5600fc5c3ea9306724a8cbd83845bb8caaabe0b599fc444e36db7e@89.42.0.12:30303', +NodeID: '0xc32e13952965e5f7ebc85b02a2eb54b09d55f553161c6729695ea34482af933d0a4b035efb5600fc5c3ea9306724a8cbd83845bb8caaabe0b599fc444e36db7e', +IP: '89.42.0.12', +DiscPort: 30303, +TCPPort: 30303, +Td: '0', +ListenAddr: '[::]:30303' +} +``` + +To connect to a node, use the [enode-format](https://github.com/ethereumproject/wiki/wiki/enode-url-format) nodeUrl as an argument to [addPeer](#adminaddpeer) or with CLI param `bootnodes`. diff --git a/docs/jsre/methods/admin/peers.md b/docs/jsre/methods/admin/peers.md new file mode 100644 index 000000000..9e5d53989 --- /dev/null +++ b/docs/jsre/methods/admin/peers.md @@ -0,0 +1,15 @@ + +#### admin.peers + +admin.peers + +##### Returns + +an array of objects with information about connected peers. + +##### Example + +``` +> admin.peers +[ { ID: '0x6cdd090303f394a1cac34ecc9f7cda18127eafa2a3a06de39f6d920b0e583e062a7362097c7c65ee490a758b442acd5c80c6fce4b148c6a391e946b45131365b', Name: 'Ethereum(G)/v0.9.0/linux/go1.4.1', Caps: 'eth/56, shh/2', RemoteAddress: '54.169.166.226:30303', LocalAddress: '10.1.4.216:58888' } { ID: '0x4f06e802d994aaea9b9623308729cf7e4da61090ffb3615bc7124c5abbf46694c4334e304be4314392fafcee46779e506c6e00f2d31371498db35d28adf85f35', Name: 'Mist/v0.9.0/linux/go1.4.2', Caps: 'eth/58, shh/2', RemoteAddress: '37.142.103.9:30303', LocalAddress: '10.1.4.216:62393' } ] +``` diff --git a/docs/jsre/methods/admin/register.md b/docs/jsre/methods/admin/register.md new file mode 100644 index 000000000..0747b00b8 --- /dev/null +++ b/docs/jsre/methods/admin/register.md @@ -0,0 +1,27 @@ +#### admin.register + +admin.register(address, contractaddress, contenthash); + +will register content hash to the codehash (hash of the code of the contract on contractaddress). The register transaction is sent from the address in the first parameter. The transaction needs to be processed and confirmed on the canonical chain for the registration to take effect. + +##### Returns + +`true` on success, otherwise `false`. + +##### Examples + +```js +source = "contract test {\n" + +" /// @notice will multiply `a` by 7.\n" + +" function multiply(uint a) returns(uint d) {\n" + +" return a * 7;\n" + +" }\n" + +"} "; +contract = eth.compile.solidity(source).test; +txhash = eth.sendTransaction({from: primary, data: contract.code }); +// after it is uncluded +contractaddress = eth.getTransactionReceipt(txhash); +filename = "/tmp/info.json"; +contenthash = admin.saveInfo(contract.info, filename); +admin.register(primary, contractaddress, contenthash); +``` diff --git a/docs/jsre/methods/admin/registerUrl.md b/docs/jsre/methods/admin/registerUrl.md new file mode 100644 index 000000000..ebf16133f --- /dev/null +++ b/docs/jsre/methods/admin/registerUrl.md @@ -0,0 +1,30 @@ + +#### admin.registerUrl + +admin.registerUrl(address, codehash, contenthash); + +this will register a contant hash to the contract' codehash. This will be used to locate [contract info json](./Contracts-and-Transactions#contract-info-metadata) +files. Address in the first parameter will be used to send the transaction. + +##### Returns + +`true` on success, otherwise `false`. + +##### Examples + +```js +source = "contract test {\n" + +" /// @notice will multiply `a` by 7.\n" + +" function multiply(uint a) returns(uint d) {\n" + +" return a * 7;\n" + +" }\n" + +"} "; +contract = eth.compile.solidity(source).test; +txhash = eth.sendTransaction({from: primary, data: contract.code }); +// after it is uncluded +contractaddress = eth.getTransactionReceipt(txhash); +filename = "/tmp/info.json"; +contenthash = admin.saveInfo(contract.info, filename); +admin.register(primary, contractaddress, contenthash); +admin.registerUrl(primary, contenthash, "file://"+filename); +``` diff --git a/docs/jsre/methods/admin/saveInfo.md b/docs/jsre/methods/admin/saveInfo.md new file mode 100644 index 000000000..34d780ccd --- /dev/null +++ b/docs/jsre/methods/admin/saveInfo.md @@ -0,0 +1,26 @@ +#### admin.saveInfo + +admin.saveInfo(contract.info, filename); + +will write [contract info json](./Contracts-and-Transactions#contract-info-metadata) into the target file, calculates its content hash. This content hash then can used to associate a public url with where the contract info is publicly available and verifiable. If you register the codehash (hash of the code of the contract on contractaddress). + +##### Returns + +`contenthash` on success, otherwise `undefined`. + +##### Examples + +```js +source = "contract test {\n" + +" /// @notice will multiply `a` by 7.\n" + +" function multiply(uint a) returns(uint d) {\n" + +" return a * 7;\n" + +" }\n" + +"} "; +contract = eth.compile.solidity(source).test; +txhash = eth.sendTransaction({from: primary, data: contract.code }); +// after it is uncluded +contractaddress = eth.getTransactionReceipt(txhash); +filename = "/tmp/info.json"; +contenthash = admin.saveInfo(contract.info, filename); +``` diff --git a/docs/jsre/methods/admin/setSolc.md b/docs/jsre/methods/admin/setSolc.md new file mode 100644 index 000000000..a17044b9a --- /dev/null +++ b/docs/jsre/methods/admin/setSolc.md @@ -0,0 +1,19 @@ + +#### admin.setSolc + +admin.setSolc(path2solc) + +Set the solidity compiler + +##### Returns + +a string describing the compiler version when path was valid, otherwise an error + +##### Example + +```javascript +admin.setSolc('/some/path/solc') +'solc v0.9.29 +Solidity Compiler: /some/path/solc +' +``` diff --git a/docs/jsre/methods/admin/sleep.md b/docs/jsre/methods/admin/sleep.md new file mode 100644 index 000000000..0f6a7d0c3 --- /dev/null +++ b/docs/jsre/methods/admin/sleep.md @@ -0,0 +1,6 @@ + +#### admin.sleep + +admin.sleep(s) + +Sleeps for s seconds. diff --git a/docs/jsre/methods/admin/sleepBlocks.md b/docs/jsre/methods/admin/sleepBlocks.md new file mode 100644 index 000000000..aec1da06e --- /dev/null +++ b/docs/jsre/methods/admin/sleepBlocks.md @@ -0,0 +1,6 @@ + +#### admin.sleepBlocks + +admin.sleepBlocks(n) + +Sleeps for n blocks. diff --git a/docs/jsre/methods/admin/startNatSpec.md b/docs/jsre/methods/admin/startNatSpec.md new file mode 100644 index 000000000..4523b2562 --- /dev/null +++ b/docs/jsre/methods/admin/startNatSpec.md @@ -0,0 +1,7 @@ + +#### admin.startNatSpec + +admin.startNatSpec() + +activate NatSpec: when sending a transaction to a contract, +Registry lookup and url fetching is used to retrieve authentic contract Info for it. It allows for prompting a user with authentic contract-specific confirmation messages. diff --git a/docs/jsre/methods/admin/startRPC.md b/docs/jsre/methods/admin/startRPC.md new file mode 100644 index 000000000..e83ec5c83 --- /dev/null +++ b/docs/jsre/methods/admin/startRPC.md @@ -0,0 +1,17 @@ + +#### admin.startRPC + +admin.startRPC(host, portNumber, corsheader, modules) + +Starts the HTTP server for the [JSON-RPC](https://github.com/ethereumproject/wiki/wiki/JSON-RPC). + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.startRPC("127.0.0.1", 8545, "*", "web3,net,eth") +// true +``` diff --git a/docs/jsre/methods/admin/startWS.md b/docs/jsre/methods/admin/startWS.md new file mode 100644 index 000000000..4e48b2f76 --- /dev/null +++ b/docs/jsre/methods/admin/startWS.md @@ -0,0 +1,17 @@ + +#### admin.startWS + +admin.startWS(host, portNumber, allowedOrigins, modules) + +Starts the websocket server for the [JSON-RPC](https://github.com/ethereumproject/wiki/wiki/JSON-RPC). + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.startWS("127.0.0.1", 8546, "*", "web3,net,eth") +// true +``` diff --git a/docs/jsre/methods/admin/stopNatSpec.md b/docs/jsre/methods/admin/stopNatSpec.md new file mode 100644 index 000000000..04baaa537 --- /dev/null +++ b/docs/jsre/methods/admin/stopNatSpec.md @@ -0,0 +1,6 @@ + +#### admin.stopNatSpec + +admin.stopNatSpec() + +deactivate NatSpec: when sending a transaction, the user will be prompted with a generic confirmation message, no contract info is fetched diff --git a/docs/jsre/methods/admin/stopRPC.md b/docs/jsre/methods/admin/stopRPC.md new file mode 100644 index 000000000..96dcf2332 --- /dev/null +++ b/docs/jsre/methods/admin/stopRPC.md @@ -0,0 +1,17 @@ + +#### admin.stopRPC + +admin.stopRPC() + +Stops the HTTP server for the [JSON-RPC](https://github.com/ethereumproject/wiki/wiki/JSON-RPC). + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.stopRPC() +// true +``` diff --git a/docs/jsre/methods/admin/stopWS.md b/docs/jsre/methods/admin/stopWS.md new file mode 100644 index 000000000..f03db98cc --- /dev/null +++ b/docs/jsre/methods/admin/stopWS.md @@ -0,0 +1,17 @@ + +#### admin.stopWS + +admin.stopWS() + +Stops the websocket server for the [JSON-RPC](https://github.com/ethereumproject/wiki/wiki/JSON-RPC). + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +admin.stopWS() +// true +``` diff --git a/docs/jsre/methods/debug/accountExist.md b/docs/jsre/methods/debug/accountExist.md new file mode 100644 index 000000000..50200c668 --- /dev/null +++ b/docs/jsre/methods/debug/accountExist.md @@ -0,0 +1,18 @@ + +#### debug.accountExist + +``` +debug.accountExist(address, blockNumber) +``` + +##### Returns + +Returns `BOOL` if a given account exists at a given block. Whether an account +exists affects the gas cost of a transaction. + + +##### Example +```js +debug.accountExist("0x102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c", 1000) +> true +``` diff --git a/docs/jsre/methods/debug/debug.md b/docs/jsre/methods/debug/debug.md new file mode 100644 index 000000000..0e5fd4f3a --- /dev/null +++ b/docs/jsre/methods/debug/debug.md @@ -0,0 +1 @@ +### Debug diff --git a/docs/jsre/methods/debug/dumpBlock.md b/docs/jsre/methods/debug/dumpBlock.md new file mode 100644 index 000000000..8c9499326 --- /dev/null +++ b/docs/jsre/methods/debug/dumpBlock.md @@ -0,0 +1,17 @@ + + +#### debug.dumpBlock + +debug.dumpBlock(blockNumber) + +##### Returns + +the raw dump of a block referred to by block number or block hash or undefined if the block is not found. +see [web3.eth.getBlock](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3ethgetblock) for more details on block fields and lookup by number or hash. + +##### Example + + +```js +> debug.dumpBlock(eth.blockNumber) +``` diff --git a/docs/jsre/methods/debug/getBlockRlp.md b/docs/jsre/methods/debug/getBlockRlp.md new file mode 100644 index 000000000..ee97b1873 --- /dev/null +++ b/docs/jsre/methods/debug/getBlockRlp.md @@ -0,0 +1,17 @@ + +#### debug.getBlockRlp + +debug.getBlockRlp(blockNumber) + +Returns the hexadecimal representation of the RLP encoding of the block. +See [web3.eth.getBlock](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3ethgetblock) for more details on block fields and lookup by number or hash. + +##### Returns + +The hex representation of the RLP encoding of the block. + +##### Example + +``` +> debug.getBlockRlp(131805) 'f90210f9020ba0ea4dcb53fe575e23742aa30266722a15429b7ba3d33ba8c87012881d7a77e81ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794a4d8e9cae4d04b093aac82e6cd355b6b963fb7ffa01f892bfd6f8fb2ec69f30c8799e371c24ebc5a9d55558640de1fb7ca8787d26da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083bb9266830202dd832fefd880845534406d91ce9e5448ce9ed0af535048ce9ed0afce9ea04cf6d2c4022dfab72af44e9a58d7ac9f7238ffce31d4da72ed6ec9eda60e1850883f9e9ce6a261381cc0c0' +``` diff --git a/docs/jsre/methods/debug/metrics.md b/docs/jsre/methods/debug/metrics.md new file mode 100644 index 000000000..0978f1bdf --- /dev/null +++ b/docs/jsre/methods/debug/metrics.md @@ -0,0 +1,15 @@ + +#### debug.metrics + +debug.metrics(raw) + +##### Returns + +Collection of metrics, see for more information [this](./Metrics-and-Monitoring) wiki page. + +##### Example + + +```js +> metrics(true) +``` diff --git a/docs/jsre/methods/debug/printBlock.md b/docs/jsre/methods/debug/printBlock.md new file mode 100644 index 000000000..597cd61dd --- /dev/null +++ b/docs/jsre/methods/debug/printBlock.md @@ -0,0 +1,46 @@ + +#### debug.printBlock + +debug.printBlock(blockNumber) + +Prints information about the block such as size, total difficulty, as well as header fields properly formatted. + +See [web3.eth.getBlock](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3ethgetblock) for more details on block fields and lookup by number or hash. + +##### Returns + +formatted string representation of the block + +##### Example + +``` +> debug.printBlock(131805) +BLOCK(be465b020fdbedc4063756f0912b5a89bbb4735bd1d1df84363e05ade0195cb1): Size: 531.00 B TD: 643485290485 { +NoNonce: ee48752c3a0bfe3d85339451a5f3f411c21c8170353e450985e1faab0a9ac4cc +Header: +[ + +ParentHash: ea4dcb53fe575e23742aa30266722a15429b7ba3d33ba8c87012881d7a77e81e +UncleHash: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 +Coinbase: a4d8e9cae4d04b093aac82e6cd355b6b963fb7ff +Root: 1f892bfd6f8fb2ec69f30c8799e371c24ebc5a9d55558640de1fb7ca8787d26d +TxSha 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 +ReceiptSha: 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 +Bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +Difficulty: 12292710 +Number: 131805 +GasLimit: 3141592 +GasUsed: 0 +Time: 1429487725 +Extra: ΞTHΞЯSPHΞЯΞ +MixDigest: 4cf6d2c4022dfab72af44e9a58d7ac9f7238ffce31d4da72ed6ec9eda60e1850 +Nonce: 3f9e9ce6a261381c +] +Transactions: +[] +Uncles: +[] +} + + +``` diff --git a/docs/jsre/methods/debug/seedHash.md b/docs/jsre/methods/debug/seedHash.md new file mode 100644 index 000000000..a1ebfd76f --- /dev/null +++ b/docs/jsre/methods/debug/seedHash.md @@ -0,0 +1,15 @@ + +#### debug.seedHash + +debug.seedHash(blockNumber) + +Returns the hash for the epoch the given block is in. + +##### Returns + +hash in hex format + +##### Example + +> debug.seedHash(eth.blockNumber) +'0xf2e59013a0a379837166b59f871b20a8a0d101d1c355ea85d35329360e69c000' diff --git a/docs/jsre/methods/debug/setHead.md b/docs/jsre/methods/debug/setHead.md new file mode 100644 index 000000000..880c87bf4 --- /dev/null +++ b/docs/jsre/methods/debug/setHead.md @@ -0,0 +1,15 @@ + +#### debug.setHead + +debug.setHead(blockNumber) + +**Sets** the current head of the blockchain to the block referred to by _blockNumber_. +See [web3.eth.getBlock](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3ethgetblock) for more details on block fields and lookup by number or hash. + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +debug.setHead(eth.blockNumber-1000) diff --git a/docs/jsre/methods/eth/eth.md b/docs/jsre/methods/eth/eth.md new file mode 100644 index 000000000..a6ccf4415 --- /dev/null +++ b/docs/jsre/methods/eth/eth.md @@ -0,0 +1,3 @@ + +#### eth +The `eth` is a shortcut for [web3.eth](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3eth). In addition to the `web3` and `eth` interfaces exposed by [web3.js](https://github.com/ethereumproject/web3.js) a few additional calls are exposed. diff --git a/docs/jsre/methods/eth/pendingTransactions.md b/docs/jsre/methods/eth/pendingTransactions.md new file mode 100644 index 000000000..d7f5c7498 --- /dev/null +++ b/docs/jsre/methods/eth/pendingTransactions.md @@ -0,0 +1,5 @@ +#### eth.pendingTransactions + +eth.pendingTransactions + +Returns pending transactions that belong to one of the users `eth.accounts`. diff --git a/docs/jsre/methods/eth/resend.md b/docs/jsre/methods/eth/resend.md new file mode 100644 index 000000000..7a1c78242 --- /dev/null +++ b/docs/jsre/methods/eth/resend.md @@ -0,0 +1,14 @@ + +#### eth.resend + +eth.resend(tx, , ) + +Resends the given transaction returned by `pendingTransactions()` and allows you to overwrite the gas price and gas limit of the transaction. + +##### Example + +```javascript +eth.sendTransaction({from: eth.accounts[0], to: "...", gasPrice: "1000"}) +var tx = eth.pendingTransactions[0] +eth.resend(tx, web3.toWei(10, "szabo")) +``` diff --git a/docs/jsre/methods/eth/sign.md b/docs/jsre/methods/eth/sign.md new file mode 100644 index 000000000..007aec01f --- /dev/null +++ b/docs/jsre/methods/eth/sign.md @@ -0,0 +1,5 @@ + +#### eth.sign + +eth.sign(signer, data) + diff --git a/docs/jsre/methods/geth/getAddressTransactions.md b/docs/jsre/methods/geth/getAddressTransactions.md new file mode 100644 index 000000000..282c9e4c0 --- /dev/null +++ b/docs/jsre/methods/geth/getAddressTransactions.md @@ -0,0 +1,41 @@ + +#### geth.getAddressTransactions + +Returns transactions for an address. + +Usage requires address-transaction indexes using `geth --atxi` to enable and create indexes during chain sync/import, optionally using `geth atxi-build` to index pre-existing chain data. + + +##### Parameters +1. `DATA`, 20 Bytes - address to check for transactions +2. `QUANTITY` - integer block number to filter transactions floor +3. `QUANTITY` - integer block number to filter transactions ceiling +4. `STRING` - `[t|f|tf|]`, use `t` for transactions _to_ the address, `f` for _from_, or `tf`/`''` for both +5. `STRING` - `[s|c|sc|]`, use `s` for _standard_ transactions, `c` for _contracts_, or `sc`/``''` for both +6. `QUANTITY` - integer of index to begin pagination. Using `-1` equivalent to `0`. +7. `QUANTITY` - integer of index to end pagination. Using `-1` equivalent to last transaction _n_. +8. `BOOL` - whether to return transactions in order of oldest first. By default `false` returns transaction hashes ordered by newest transactions first. + +``` +params: [ +'0x407d73d8a49eeb85d32cf465507dd71d507100c1', +123, // earliest block +456, // latest block, use 0 for "undefined", ie. eth.blockNumber +'t', // only transactions to this address +'', // both standard and contract transactions +-1, // do not trim transactions for pagination (start) +-1, // do not trim transactions for pagination (end) +false // do not reverse order ('true' will reverse order to be oldest first) +] +``` + +##### Returns + +`Array` - Array of transaction hashes, or an empty array if no transactions found + +##### Example +```js +> geth.getAddressTransactions("0xf4e6FeA8C10C05fe9E2C2FA7545e4c9dd3993a26", 0, 0, "tf", "sc", -1, -1, true) + +["0x148809a063efc39e66e35a27a72a82747905071bc2c3b7fc12370dd979eac650", "0x5649e7346ed868bde9ef3a532f8140aeb4171392d278da8e030b26540e248f8a", "0x11bc379dd4f42db7bce759e89dbfda8420fa489e785b1989374f719dac1923dd", "0xdc983ced410b96a95d9a27c9ed88c20ddf735c45797237a34c8f103bbad30caa", "0x58532fa1492a77df622fac57e5e4853f417dcbc3c92940c9df0a2bde72b303f9", "0x223c8589024914b293b92b1fbda08636dd1d3a121fc75532aaa046d579ff641d", "0xd5332daa2e8cb8621912ada4ce09bb1ed8d5831844f8260c4bd07e39677f1201", "0x15bced756880910783272beafc644b9d755291e9fa643ae7c305c6cae961fa26", "0x099e6323f5f9a09197fa5032a546f0f0706b3b8e31404e297e80fcea89210ccd", "0xb5c8b065561e1ee144c2999786accdb5626c10b31c691e01b3c94f22380c0143", "0x743156d73d92595d6005124b6130e4ed85e52312af08aa1303e7ea53741c8cff", "0x38d4128c12c1c4b7a0aab8ab028f95860e2a5a5deb4cd9c992d6cea5f3c45c2b", "0xf87d4e67aa21fda8e749fbedf2e6a6f9bb499d9e4f94e2faae65b473718d6905", "0x4aa8bb43108488e247d52e57ae50ba115b5e95452b89aa4cee92458cb2c9e148", "0x13dc8baa1f4bc0076095e7d73a9aa22e049a30e064e7ea13b34d1498f108730c", "0x351f388bd8271feef0b3b81dcbc500b1f8a0b16064722fca76612a6d04e37378", "0x02ecebe4cc15179991c202b249f358bbc81c26613c66d16bdcc201a550557a7b", "0xd5a50c70909b9f494495449df6cd3e3f5621de41ff5ab4174b066b61468ddbcc"] +``` diff --git a/docs/jsre/methods/geth/geth.md b/docs/jsre/methods/geth/geth.md new file mode 100644 index 000000000..cc9d7c8fe --- /dev/null +++ b/docs/jsre/methods/geth/geth.md @@ -0,0 +1,4 @@ +### Geth + +The geth API module provides client specific services. + diff --git a/docs/jsre/methods/interfaces/additional-interfaces.md b/docs/jsre/methods/interfaces/additional-interfaces.md new file mode 100644 index 000000000..663291398 --- /dev/null +++ b/docs/jsre/methods/interfaces/additional-interfaces.md @@ -0,0 +1 @@ +### Additional interfaces diff --git a/docs/jsre/methods/interfaces/inspect.md b/docs/jsre/methods/interfaces/inspect.md new file mode 100644 index 000000000..bf6656117 --- /dev/null +++ b/docs/jsre/methods/interfaces/inspect.md @@ -0,0 +1,4 @@ + + +#### inspect +The `inspect` method pretty prints the given value (supports colours) diff --git a/docs/jsre/methods/interfaces/loadScript.md b/docs/jsre/methods/interfaces/loadScript.md new file mode 100644 index 000000000..37fe96479 --- /dev/null +++ b/docs/jsre/methods/interfaces/loadScript.md @@ -0,0 +1,14 @@ + +#### loadScript + +loadScript('/path/to/myfile.js'); + +Loads a JavaScript file and executes it. Relative paths are interpreted as relative to `jspath` which is specified as a command line flag, see [Command Line Options](./Command-Line-Options). + +#### setInterval + +setInterval(s, func() {}) + +#### clearInterval +#### setTimeout +#### clearTimeout diff --git a/docs/jsre/methods/interfaces/net.md b/docs/jsre/methods/interfaces/net.md new file mode 100644 index 000000000..43277d711 --- /dev/null +++ b/docs/jsre/methods/interfaces/net.md @@ -0,0 +1,3 @@ + +#### net +The `net` is a shortcut for [web3.net](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3net). diff --git a/docs/jsre/methods/interfaces/shh.md b/docs/jsre/methods/interfaces/shh.md new file mode 100644 index 000000000..9c51eaf91 --- /dev/null +++ b/docs/jsre/methods/interfaces/shh.md @@ -0,0 +1,4 @@ + + +#### shh +The `shh` is a shortcut for [web3.shh](https://github.com/ethereumproject/wiki/wiki/JavaScript-API#web3shh). diff --git a/docs/jsre/methods/interfaces/web3.md b/docs/jsre/methods/interfaces/web3.md new file mode 100644 index 000000000..e3ee3cdd1 --- /dev/null +++ b/docs/jsre/methods/interfaces/web3.md @@ -0,0 +1,3 @@ + +#### web3 +The `web3` exposes all methods of the [JavaScript API](https://github.com/ethereumproject/wiki/wiki/JavaScript-API). diff --git a/docs/jsre/methods/miner/makeDAG.md b/docs/jsre/methods/miner/makeDAG.md new file mode 100644 index 000000000..4103e5421 --- /dev/null +++ b/docs/jsre/methods/miner/makeDAG.md @@ -0,0 +1,11 @@ + +#### miner.makeDAG + +miner.makeDAG(blockNumber, dir) + +Generates the DAG for epoch `blockNumber/epochLength`. dir specifies a target directory, +If `dir` is the empty string, then ethash will use the default directories `~/.ethash` on Linux and MacOS, and `~\AppData\Ethash` on Windows. The DAG file's name is `full-R-` + +##### Returns + +`true` on success, otherwise `false`. diff --git a/docs/jsre/methods/miner/miner.md b/docs/jsre/methods/miner/miner.md new file mode 100644 index 000000000..8fb399284 --- /dev/null +++ b/docs/jsre/methods/miner/miner.md @@ -0,0 +1 @@ +### Miner diff --git a/docs/jsre/methods/miner/setEtherbase.md b/docs/jsre/methods/miner/setEtherbase.md new file mode 100644 index 000000000..b77937a8a --- /dev/null +++ b/docs/jsre/methods/miner/setEtherbase.md @@ -0,0 +1,6 @@ + +#### miner.setEtherbase + +miner.setEtherbase(account) + +**Sets** the the ether base, the address that will receive mining rewards. diff --git a/docs/jsre/methods/miner/setExtra.md b/docs/jsre/methods/miner/setExtra.md new file mode 100644 index 000000000..7a273c5b4 --- /dev/null +++ b/docs/jsre/methods/miner/setExtra.md @@ -0,0 +1,6 @@ + +#### miner.setExtra + +miner.setExtra("extra data") + +**Sets** the extra data for the block when finding a block. Limited to 32 bytes. diff --git a/docs/jsre/methods/miner/setGasPrice.md b/docs/jsre/methods/miner/setGasPrice.md new file mode 100644 index 000000000..abee276a8 --- /dev/null +++ b/docs/jsre/methods/miner/setGasPrice.md @@ -0,0 +1,6 @@ + +#### miner.setGasPrice + +miner.setGasPrice(gasPrice) + +**Sets** the the gasprice for the miner diff --git a/docs/jsre/methods/miner/start.md b/docs/jsre/methods/miner/start.md new file mode 100644 index 000000000..a1a883b6f --- /dev/null +++ b/docs/jsre/methods/miner/start.md @@ -0,0 +1,17 @@ + +#### miner.start + +miner.start(threadCount) + +Starts [mining](see ./Mining) on with the given `threadNumber` of parallel threads. This is an optional argument. + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +miner.start() +// true +``` diff --git a/docs/jsre/methods/miner/startAutoDAG.md b/docs/jsre/methods/miner/startAutoDAG.md new file mode 100644 index 000000000..386575f50 --- /dev/null +++ b/docs/jsre/methods/miner/startAutoDAG.md @@ -0,0 +1,10 @@ + +#### miner.startAutoDAG + +miner.startAutoDAG() + +Starts automatic pregeneration of the [ethash DAG](https://github.com/ethereumproject/wiki/wiki/Ethash-DAG). This process make sure that the DAG for the subsequent epoch is available allowing mining right after the new epoch starts. If this is used by most network nodes, then blocktimes are expected to be normal at epoch transition. Auto DAG is switched on automatically when mining is started and switched off when the miner stops. + +##### Returns + +`true` on success, otherwise `false`. diff --git a/docs/jsre/methods/miner/stop.md b/docs/jsre/methods/miner/stop.md new file mode 100644 index 000000000..cdd082287 --- /dev/null +++ b/docs/jsre/methods/miner/stop.md @@ -0,0 +1,15 @@ + +#### miner.stop + +miner.stop() + +##### Returns + +`true` on success, otherwise `false`. + +##### Example + +```javascript +miner.stop() +// true +``` diff --git a/docs/jsre/methods/miner/stopAutoDAG.md b/docs/jsre/methods/miner/stopAutoDAG.md new file mode 100644 index 000000000..16dddca96 --- /dev/null +++ b/docs/jsre/methods/miner/stopAutoDAG.md @@ -0,0 +1,10 @@ + +#### miner.stopAutoDAG + +miner.stopAutoDAG() + +Stops automatic pregeneration of the [ethash DAG](https://github.com/ethereumproject/wiki/wiki/Ethash-DAG). Auto DAG is switched off automatically when mining is stops. + +##### Returns + +`true` on success, otherwise `false`. diff --git a/docs/jsre/methods/personal/listAccounts.md b/docs/jsre/methods/personal/listAccounts.md new file mode 100644 index 000000000..478ce1db5 --- /dev/null +++ b/docs/jsre/methods/personal/listAccounts.md @@ -0,0 +1,10 @@ +#### personal.listAccounts +personal.listAccounts + +List all accounts + +#### Return +collection with accounts + +#### Example +` personal.listAccounts` diff --git a/docs/jsre/methods/personal/newAccount.md b/docs/jsre/methods/personal/newAccount.md new file mode 100644 index 000000000..7077953f9 --- /dev/null +++ b/docs/jsre/methods/personal/newAccount.md @@ -0,0 +1,14 @@ + +#### personal.newAccount + +personal.newAccount(passwd) + +Create a new password protected account + +#### Return +`string` address of the new account + +#### Example +` personal.newAccount("mypasswd")` + +` personal.newAccount() # will prompt for the password` diff --git a/docs/jsre/methods/personal/personal.md b/docs/jsre/methods/personal/personal.md new file mode 100644 index 000000000..5eb18dafa --- /dev/null +++ b/docs/jsre/methods/personal/personal.md @@ -0,0 +1,2 @@ +### Personal +The `personal` api exposes method for personal the methods to manage, control or monitor your node. It allows for limited file system access. \ No newline at end of file diff --git a/docs/jsre/methods/personal/unlockAccount.md b/docs/jsre/methods/personal/unlockAccount.md new file mode 100644 index 000000000..a89acef87 --- /dev/null +++ b/docs/jsre/methods/personal/unlockAccount.md @@ -0,0 +1,12 @@ + + +#### personal.unlockAccount +personal.unlockAccount(addr, passwd, duration) + +Unlock the account with the given address, password and an optional duration (in seconds). If password is not given you will be prompted for it. + +#### Return +`boolean` indication if the account was unlocked + +#### Example +` personal.unlockAccount(eth.coinbase, "mypasswd", 300)` diff --git a/docs/jsre/methods/txpool/status.md b/docs/jsre/methods/txpool/status.md new file mode 100644 index 000000000..97bbdb1dd --- /dev/null +++ b/docs/jsre/methods/txpool/status.md @@ -0,0 +1,13 @@ + +#### txpool.status +txpool.status + +Number of pending/queued transactions + +#### Return +`pending` all processable transactions + +`queued` all non-processable transactions + +#### Example +` txpool.status` diff --git a/docs/jsre/methods/txpool/txpool.md b/docs/jsre/methods/txpool/txpool.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/jsre/non-interactive-use.md b/docs/jsre/non-interactive-use.md new file mode 100644 index 000000000..72eb51e5b --- /dev/null +++ b/docs/jsre/non-interactive-use.md @@ -0,0 +1,18 @@ +## Non-interactive use: JSRE script mode + +It's also possible to execute files to the JavaScript interpreter. The `console` and `attach` subcommand accept the `--exec` argument which is a javascript statement. + + $ geth --exec "eth.blockNumber" attach + +This prints the current block number of a running geth instance. + +Or execute a local script with more complex statements on a remote node over http: + + $ geth --exec 'loadScript("/tmp/checkbalances.js")' attach http://123.123.123.123:8545 + $ geth --jspath "/tmp" --exec 'loadScript("checkbalances.js")' attach http://123.123.123.123:8545 + +Find an example script [here](./Contracts-and-Transactions#example-script) + +Use the `--jspath ` 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`. \ No newline at end of file diff --git a/docs/jsre/timers.md b/docs/jsre/timers.md new file mode 100644 index 000000000..530bdc2e2 --- /dev/null +++ b/docs/jsre/timers.md @@ -0,0 +1,4 @@ + +## Timers + +In addition to the full functionality of JS (as per ECMA5), the ethereum JSRE is augmented with various timers. It implements `setInterval`, `clearInterval`, `setTimeout`, `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 till the number of new blocks added is equal to or greater than `n`, think "wait for n confirmations". \ No newline at end of file