How to do it...

  1. Verify your installation by running the following version command:
$ geth version
  1. Start your node with the following command:
$ geth

This will start an Ethereum node and will connect with the main network. As soon as it finds any peer nodes, it will start downloading the blocks from them.

You can configure the parameters before starting a node. This will help you do things like connect to a different network, expose APIs, and much more. Let's look at a sample initialization and the parameters used in it:

$ geth --networkid 3 --datadir "./ropsten-db" --keystore "./ropsten-keys" --syncmode "fast" --rpc --rpcport "8546" --rpcapi "web3,eth,miner,admin" --rpccorsdomain "*" --port 30301 console

Let's look into each parameter in detail:

  • --networkid <id>: A parameter to identify each network. You can either connect to the main/test network (1=Frontier(default), 2=Morden (disused), 3=Ropsten(PoW), 4=Rinkeby(PoA)) or any private network that you have set up.
  • --datadir <path>: Directory path for storing the blockchain database and keystore. You can change the default keystore directory with the --keystore parameter.
  • --syncmode <mode>: A parameter to specify the type of sync method. You can choose fast, full, or light, based on your needs.
  • --rpc: Enables an RPC server through HTTP. You can also change parameters such as --rpcaddr, --rpcport, and --rpcapi.
  • --rpccorsdomain <list>: Domains from which cross-domain requests are accepted. Use * as a wildcard or specify domains as a comma-separated list.
  • --port <port>: Changes the default network listening port (30303).
  • --console: Starts the web3 JavaScript console.
If you get stuck anywhere, you can always make use of the inbuilt help interface. Just enter geth help and it will return a comprehensive list of all commands with their respective description that you can run using geth.
  1. It might take a few minutes to identify the peers that are already on the network. Run the following command to return the list of peers that are currently connected to your node. Your node will start syncing once it finds at least one peer:
> admin.peers
  1. Check the current syncing status by running the following command. It will return false if not syncing:
> eth.syncing
  1. Run the geth attach command if you would like to connect to this node from a different console. You can also explicitly specify the host and the port. In our case, it is localhost and 8546:
$ geth attach http://localhost:8546
Your firewall may restrict the node from communicating with an external peer. This can cause issues with the synchronization process. Also, ensure that you are not exposing your RPC APIs to the internet, which can result in attacks.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.96.86