ethcli

Useful when working with ganache-cli to quickly force mining of blocks, start/stop mining and check the blockchain height. Requires gnu parallel.

Commands:

  • ethcli start: starts mining.
  • ethcli stop: stops mining.
  • ethcli mine [number]: if the parameter number isn't provided, mines one block. Otherwise, it mines number blocks. Launches up to 200 parallel jobs.
  • ethcli height: returns the blockchain height. TODO: display decimal value instead of hexadecimal.
  • ethcli getblock [number]: returns the last block, or the block with the specified number. Uses eth_getBlockByNumber. Special values are earliest, latest (the default), and pending. For example, to get the last transaction's hash to later debug it with truffle debug
ethcli getblock |jq ".result.transactions[0].hash" -r

The script uses the NODE_ADDR environment variable to connect to an ethereum node. It defaults to http://localhost:8545.

source.