Crypto js documentation

Comment

Author: Admin | 2025-04-28

Geth responds to instructions encoded as JSON objects as defined in the JSON-RPC-API. A Geth user can send these instructions directly, for example over HTTP using tools like Curl. The code snippet below shows a request for an account balance sent to a local Geth node with the HTTP port 8545 exposed.curl --data '{"jsonrpc":"2.0","method":"eth_getBalance", "params": ["0x9b1d35635cc34752ca54713bb99d38614f63c955", "latest"], "id":2}' -H "Content-Type: application/json" localhost:8545This returns a result which is also a JSON object, with values expressed as hexadecimal strings, for example:{"id":2,"jsonrpc":"2.0","result":"0x1639e49bba16280000"}This is a low level and rather error-prone way to interact with Geth. Most developers prefer to use convenience libraries that abstract away some of the more tedious and awkward tasks such as converting values from hexadecimal strings into numbers, or converting between denominations of ether (Wei, Gwei, etc). One such library is Web3.js.The purpose of Geth's Javascript console is to provide a built-in environment to use a subset of the Web3.js libraries to interact with a Geth node.NoteThe web3.js version that comes bundled with Geth is not up to date with the official Web3.js documentation. There are several Web3.js libraries that are not available in the Geth Javascript Console. There are also administrative APIs included in the Geth console that are not documented in the Web3.js documentation. The full list of libraries available in the Geth console is available on the JSON-RPC API page.Starting the console There are two ways to start an interactive session using Geth console. The first is to provide the console command when Geth is started up. This starts the node and runs the console in the same terminal. It is therefore convenient to suppress the logs from the node to prevent them from obscuring the console. If the logs are not needed, they can be redirected to the dev/null path, effectively muting them. Alternatively, if the logs are required they can be redirected to a text file. The level of detail provided in the logs can be adjusted by providing a value between 1-6 to the --verbosity flag as in the example below:# to mute logsgeth console 2> /dev/null# to save logs to filegeth console --verbosity

Add Comment