Bitcoin & Blockchain Programming #004 – Basic Commands

By Albert Szmigielski

Last time we saw how to issue a command to bitcoind via the terminal using  bitcoin-cli. Today we will start examining the different commands that bitcoind can accept. Perhaps the most important one to start with will be the help command.

this will print out a list of all the commands that the bitcoind wallet accepts. If you want to save them in a file simply redirect the output to a file.

If you ever need help with a specific command you can get the man page by

for example

Screenshot - 16-01-30 - 03:32:50 PM

So there is our first command getblockcount it returns the number of blocks in our blockchain. Lets execute it.

Screenshot - 16-01-30 - 03:35:50 PM

Currently (jan 30 2016) there are 681,805 blocks in the testchain.

Another command that is interesting is getdifficulty

On the testnet the difficulty is 1, so that is not very informative, but on the mainnet we would find out the current network difficulty. We will work on the mainnet later, for now we are trying to get a feeling for what bitcoind can do for us.

In order to get information about the blockchain we can use getblockchaininfo

This will give us a variety of information including the softforks that took place. To understand what all this information means let’s look at the man page

Screenshot - 16-01-30 - 05:08:05 PM

Another useful command is the getinfo command. We briefly saw it in the last tutorial. getinfo supplies us with a variety of information regarding the wallet and the Bitcoin network that bitcoind represents.

Screenshot - 16-01-30 - 05:31:50 PM

Let’s see what the current information is:

Screenshot - 16-01-30 - 05:46:31 PM

So we know now how to issue a few commands to bitcoind. We looked at the following commands so far

  • help
  • stop
  • getinfo
  • getblockcount
  • getdifficulty
  • getblockchaininfo
  • getinfo

Now it is time to connect to the wallet via RPC and programmatically issue commands and interact with bitcoind. That will be the focus of our next tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *