6

The instructions for creating a new account on the Geth console state:

Tip: If you are using Geth then you can just use eth instead of web3.eth command.

Meaning accounts can be referenced by just using eth.accounts rather than having to use web3.eth.accounts.

Are these two commands doing anything different under the covers, or are they the same thing? Why can we leave out the web3 part of the command if we're using Geth?

7

They are exactly the same. My guess is that the web3 umbrella collector is defined in the geth console to allow pasting in web3 based code and have it work instead of requiring you to strip out web3 from all the calls.

  • Maybe the other way around too: the code was moved or made available to eth as a way to save Geth console users from extra typing ;) – eth Feb 13 '16 at 19:26
1

They are two different implementations which do exactly the same but are not streamlined regarding the command line interface calls.

It's worth to have a read of the most recent Ethereum DEV C++ Update, where Christian Reitweissner explains they will eventually drop the eth console with a nodejs applicatoin and allow geth attach to attach to a running eth instance.

The "why" part of your question is hard to answer without being subjective. My best guess would be that the commands are not developed with focus usability and intuitivity but rather the client was developed with focus on stability and functionality.

Future releases will fix that, I'm pretty sure.

0

web3.js is the javascript api to interact with ethereum local or remote node via geth over RPC protocol.

In web3, objeccts are groups based on the functions. one of the object is eth, which deal with ethereum blockchain related apis like web3.eth.getBalance(), web3.eth.getBlock() ...

Under the hood, web3 provides shorthand apis to work on console. This means, you can use shorthand notation to invoke api on console. so instead of writing web3.eth.getBlock(), you can write eth.getBlock() to invoke api on console.

just to remind, shorthand is available only to work on console.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.