Blockchain is a chain of blocks. First, we must create a block.


For more information visit the helpful website at the bottom of this article. I learned the basics from this website. Knowing where and how to find information is very important as a programmer. No reason to reinvent the wheel. Be a smart programmer. Use all the tools.


public class Block
  private String data;
  private String hash;
  private String previousHash; 
  private long timeStamp;

  public Block(String data, String previousHash)
  { = data;
    this.previousHash = previousHash;
    this.timeStamp = new Date().getTime();


This is a class file of a block.


String data = the variable to hold the data that we will retain within the block. This could be any kind of data. Right now we a using a form of data known as a String.


String hash = the variable to hold our digital signature. If you hear the word hash, just think digital signature. Its that simple. It is also a form of data known as a String.


String previousHash = the variable to hold the hash, remember digital signature, of the block prior to the current block. Yes, the previous block. It is also a String.


long timeStamp = this is going to be a number that is used in developing the digital signature, also known as a hash. We are using a number type of long because its gonna be a big number or better worded. A very long number.


The constructor requires two things. The data we want to put into the block and the previous blocks hash. Yes, I will say it again. Hash is the digital signature.


We assign the incoming value of data to our Block's data variable. We assign the incoming previous hash to our Block's previous hash variable. We then create a time stamp using java's built in Date Class. The date class would need to be imported. Example import:


import java.util.Date;


Success - We now have a block that we can chain. This will be the base object of our blockchain. More to come in next tutorial.


Further reading: