Geth console use and web3. js use actual combat text has been updated, please go to the original to read
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 console
Copy 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.log
Copy the code
You can open a command line terminal and run the following command to view logs:
$ tail -f geth.log
Copy the code
Redirect to another terminal
You can also redirect logs to another terminal by typing:
$ tty
Copy the code
/dev/ttys003 /dev/ttys003
$ geth console 2>> /dev/ttys003
Copy 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/null
Copy 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 console
Copy the code
Start a development mode test node
geth --datadir /home/xxx/testNet --dev console
Copy 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.ipc
Copy the code
Dynamic And Simple Blockchain – Learn blockchain systematically and build the best blockchain technology blog.
Dynamic Planet Of My Knowledge answers blockchain technology questions. Welcome to join the discussion.
Aid To The Public account “Deep And Simple Blockchain Technology” To obtain blockchain technology information for the first time.