When you’re developing a decentralized ethereum application, you have to interact with Ethereum, and you can’t do that without Web3. The Geth console (REPL) implements all web3 apis and Admin apis, so using Geth well is a required course. Use Geth command to read better.

Writing in the front

Before reading this article, you need to have a preliminary understanding of Ethereum (blockchain). If you don’t know what Ethereum is, read what Ethereum is first. If you are reading this outside of my little column, you may only be able to read an excerpt of this article. To read the full article, please subscribe to the little Column Blockchain Technology

Geth console exploration – start and exit

Installation reference Smart contract development environment setup the simplest startup mode is as follows:

$ geth consoleCopy the code

After the GEth console starts successfully, you see the > prompt. Exit Enter exit

Geth log control

Redirects logs to files

If you start with the Geth Console, logs will appear from time to time under the current interface. You can output logs to a file in the following ways.

$ geth console 2>>geth.logCopy the code

You can open a command line terminal and run the following command to view logs:

$ tail -f geth.logCopy the code

Redirect to another terminal

You can also redirect logs to another terminal by typing:

$ ttyCopy the code

/dev/ttys003 /dev/ttys003

$ geth console 2>> /dev/ttys003Copy the code

Start GEth, which is the log output to another terminal. If you do not want to see the log, you can also redirect to an empty terminal:

$ geth console 2>> /dev/nullCopy the code

Log Level Control

Use – Verbosity to control log levels. If you do not want to see logs, you can also use:

$ geth --verbosity 0 consoleCopy the code

Start a development mode test node

geth --datadir /home/xxx/testNet --dev consoleCopy the code

Tip: If we often use one way to start, we can save the command as a bash script. ~/bin You can put some common scripts and add ~/bin to the environment variable PATH.

Connect the GETH node

Another way to start GETH is to connect to a GETH node:

$geth attach IPC :/some/custom/path $geth attach http://191.168.1.1:8545 $geth attach ws://191.168.1.1:8546Copy the code

To connect to the development mode node just opened, use:

geth attach ipc:testNet/geth.ipcCopy the code

For more on blockchain technology, see the full article. Blockchain in Simple terms – systematic learning of blockchain to create the best blockchain technology blog


WeChat pay

  • By Tiny Bear
  • Links to this article: Learnblockchain. Cn / 2017/12/01 /…
  • Copyright notice: This article is published under a CC BY-NC-SA 3.0 license. Reprint please indicate the source!