In the development of Ethereum to central application, inevitably and ethereum interaction, it is inseparable from WEB3.
The Geth console (REPL) implements all WEB3 APIs and the Admin API,
The use of good geth is compulsory. Combined with geth command usage read better.
Write in front
Before reading this article, you need to have a preliminary understanding of Ethereum (blockchain), and if you don't know what Ethereum is, first read what Ethereum is.
If you read this article outside of my little column, you may only read the excerpt from this article, read the full text, subscribe to the small column blockchain technology
Geth console-Start, exit
Install Reference Smart Contract development environment construction
The simplest way to start is as follows:
$ geth console
After the Geth console starts successfully, you can see the > prompt.
Exit input Exit
Geth Log Control redirect log to file
Starting with Geth console is a log that appears from time to time under the current interactive interface.
You can use the following methods to output the log to a file.
$ geth console 2>>geth.log
You can open a new command line terminal and enter the following command to view the log:
$ tail -f geth.log
REDIRECT another endpoint
You can also redirect the log to another terminal, first in the terminal you want to see the log input:
$ tty
You can get the terminal number, for example:/dev/ttys003
Then another terminal uses:
$ geth console 2>> /dev/ttys003
Start Geth, which is the log output to another terminal.
If you do not want to see the log, you can redirect to an empty terminal:
$ geth console 2>> /dev/null
Log level Control
You can use --verbosity to control the log level, and you can use it if you do not want to see the log:
$ geth --verbosity 0 console
Start a development Mode test node
geth --datadir /home/xxx/testNet --dev console
Tip: If we often use a 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.
Connecting Geth nodes
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:8546
If you are connecting to a development mode node that you just opened, use:
geth attach ipc:testNet/geth.ipc
For more information, go to the Blockchain Tech column for full-text links.
Blockchain-Learn blockchain to build the best Blockchain technology blog
Geth console use and Web3.js use combat