How to Use Ethereum Optional Flags with New Chains

Note

For a comprehensive coverage of blockchain development in Ethereum or mastering Solidity programming, taking our below self paced courses is highly recommended:

 

Recap

In our previous article (How to Create an Account on a Local Private Ethereum Blockchain), we discussed how to create an account on a local private Ethereum network.

In this article, we learn what Ethereum Optional Flags are and how to use them.

 

Using optional flags with new chains

While we were building a local private blockchain, we used a few command-line options such as –datadir, –identity, –verbosity, and so on. These options are also known as optional flags. They are Ethereum options and are useful for setting up a local blockchain and accessing testnets. Developer chain options support switching to developer mode.

Other options are available for Ethash, transaction pools, performance tuning, account, API and consoles, networking, miner, gas price oracles, virtual machines, logging and debugging, metrics, stats, and options, and so on. Let’s have a look at the following command:

$ geth help or $ geth h

The preceding command will give you a full host of Ethash options. Let’s have a look at the format of the following command:

$ geth [options] command  [command options] [arguments]

 

One-to-One Live Blockchain Classes

Coding Bootcamps school offers One-to-One Live Blockchain Classes for Beginners.

 

You can implement all the options in the commands using the preceding format.

 

Commands

Geth comes with a list of commands and command-line options. Earlier, you saw a few in action, including console, account, attach, and so on. The following is a list of commands that are supported by Geth:

  • account
  • attach
  • bug
  •  console
  • copydb
  • dump
  • dumpconfig
  • export
  • export-preimages
  • import
  • import-preimages
  • init
  • js license
  • makecache
  • makedag
  • monitor
  • removedb
  • version wallet
  • help,h

 

We used geth account new to create new accounts in the previous section. Furthermore, geth account helps you manage accounts:

  $ geth account  list - gives you a summary of existing accounts
  $ geth account update  - updates the existing accounts
  $ geth account import  - imports private  keys for new accounts

Some additional geth commands are as follows:

 

  • geth import: This imports the files of a blockchain
  • geth export: This exports a blockchain to the appropriate files
  • geth copydb: This creates a local blockchain from a source chain data directory path
  • geth removdb: This discards a local blockchain and its databases
  • geth init: This initializes a genesis block from the target genesis JSON file
  • geth js: This executes the target JavaScript files
  • geth attach: This connects to nodes in the network
  • geth console: This opens an interactive JavaScript environment session
  • geth wallet: This manages presale Ethereum wallets
  • geth bug: This automatically brings up the page on GitHub, where you can report the bug

For example, a presale Ethereum wallet can be imported with the following import command:

$ geth wallet  import <path to wallet>presale.wallet

There are other commands that are useful for monitoring your local chain and testing, including dump, dumpconfig, export-preimages, import-preimages, license, makecache, makedag, monitor, and version.

 

Next Article

In our next article (Review of Ethereum Options for Development and Testing), we discuss what Ethereum Options are for application development and testing.

This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.

 

Resources

coming soon