Ethereum Read-Eval-Print Loop (REPL) for interacting with Ethereum nodes.
- Interactive JavaScript console for Ethereum
- Supports common Ethereum operations (getBalance, sendTransaction, etc.)
- Configurable RPC endpoint
- Support for HTTP, WebSocket, and IPC connections
- Self-contained bundle, requires only Node.js to run
git clone https://github.com/daoleno/ethrepl.git
cd ethrepl
npm install
npm run build
npm start
By default, ethrepl connects to http://localhost:8545
. You can specify different endpoints using environment variables:
-
HTTP/HTTPS:
ETH_RPC_URL={your_rpc_url} ethrepl
-
WebSocket:
ETH_WS_URL=wss://{your_ws_url} ethrepl
-
IPC:
ETH_IPC_PATH=/path/to/geth.ipc ethrepl
The following modules are available in the REPL:
eth
: Ethereum-related functionsnet
: Network-related functionsadmin
: Node administration functionsweb3
: Utility functionspersonal
: Account management functionstxpool
: Transaction pool informationdebug
: Debugging functionsminer
: Mining control functions
You can access these modules directly in the REPL. Here are some example commands:
// Get the balance of an address
eth.getBalance('0x742d35Cc6634C0532925a3b844Bc454e4438f44e')
// Get the latest block number
eth.getBlockNumber()
// Get network peer count
net.peerCount()
// Create a new account
personal.newAccount('password')
// Get transaction pool status
txpool.status()
Some utility functions are available directly in the context:
// Convert Wei to Ether
web3.fromWei('1000000000000000000', 'ether')
// Convert Ether to Wei
web3.toWei('1', 'ether')
// Check if a string is a valid Ethereum address
web3.isAddress('0x742d35Cc6634C0532925a3b844Bc454e4438f44e')
You can load and execute JavaScript files in the REPL:
loadScript('path/to/your/script.js')
To exit the REPL, you can either:
- Press Ctrl+D
- Type
.exit
and press Enter
We provide an example of how to create a Go program that can launch the ethrepl REPL without requiring any additional installation beyond Node.js. This can be useful for integrating ethrepl into other Go projects or for creating standalone executables.
To build and use the Go launcher:
- Navigate to the
examples/go-launcher
directory. - Run the build script:
./build.sh
- This will create an
ethrepl-launcher
executable in the current directory. - Run the launcher:
./ethrepl-launcher
For more details, see the README in the examples/go-launcher
directory.
This project is licensed under the MIT License. See the LICENSE file for details.