[Ethereum] ny way to run web3 as cli


On many occasions, I'd like to quickly connect to a local or remote node via web3.js and query for things directly from the console. I imagine something like:

web3-cli set --host http://localhost:8545
web3-cli eth --get-accounts

The first command would switch over to the given host, and when you query for accounts or others things it connects to that HttpProvider in the backend.

Is this possible? I've seen David Knott from OmiseGo created a nice cli for plasma-mvp, so why not upgrade the idea to a general-purpose, handy terminal tool?

Note: I'm already running node in the console, but it's not the same sweet level of flexibility provided by a cli.

Best Answer

I assume you are referring to the web3.js Javascript library for interfacing with the Ethereum blockchain? I agree. It is great.

so why don't upgrade the idea to a general-purpose, handy terminal tool?

Because doing so would be reinventing the wheel. Javascript can be executed in all sorts of different environments nowadays. If you want to use it through your terminal, why not just use nodejs.

web3.js is available as a package through npm

Start a node console, import web3.js and off you go.

Related Topic