Exploring Web3 with Geth
To expose the required APIs via geth, the following command can be used:
$ geth --datadir ~/etherprivate --networkid 786 --http --http.api "web3,net,eth,debug" --http.port 8001 --http.corsdomain http://localhost:7777
The -
–httpflag in the preceding command allows theweb3,eth,net, anddebugmethods. There are other APIs such aspersonal,miner, andadminthat can be exposed by adding their names to this list.
Web3 is a powerful API and can be explored by attaching a geth instance. Later in this section, you will be introduced to the concepts and techniques of making use of Web3 via JavaScript/HTML frontends.
Note that I have used Geth version v1.10.14-stable and all commands work correctly for this version and may not work with previous versions. Try to use latest version of geth when running examples in this chapter, or at least v1.10.14-stable.
The geth instance can be attached using the following command:
$ geth attach ~/etherprivate...