If you’ve heard about Hashgraph and wondering how to get started, here is a little guide based off the docs provided in the SDK. Running the demo is easy but preparing your system can take a little bit of time. (Just like cooking!)
A good place to start is https://www.hederahashgraph.com/ where you can read a bit about it but there is a section for developers which points you to https://dev.hashgraph.com/ which is where the good stuff is.
There is a “How do I get started?” section which is where you … start. The instructions are at: https://dev.hashgraph.com/docs/installation/
Pre flight check list
Step 1: JDK 8
You need at least JDK 8 otherwise you’ll get an error like this:
> cloudnthings$ java -jar swirlds.jar > Exception in thread "main" java.lang.UnsupportedClassVersionError: com/swirlds/platform/Browser : Unsupported major.minor version 52.0
If you are on a Mac, you want to run:
> java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
and make sure you get a response like above. Otherwise go to Oracle and download the Java SE Development Kit.
Go through the installation process and you should see a folder called jdk1.8.0_171.jdk at /Library/Java/JavaVirtualMachines/
Run the java -version command again to verify.
Step 2: JCE Unlimited Policy for Java 8
Next download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 from here and paste it to /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/security/policy/unlimited. Otherwise you’ll get this error.
Note: When I tried to do a clean install of Java and repeat the process from scratch I found that I didn’t get this error which is a little strange. I found the 2 files were already at: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/security/policy/unlimited
Step 3: Download the SDK
Go to https://www.swirlds.com/download/ and download the SDK, extract it and then navigate to the sdk folder and run the following command in step 4 in a terminal.
Step 4: Run this command
> java -jar swirlds.jar
This is what you should see:
Congrats! You have your first Hashgraph application up and running. This is called the “Stats Demo” and is the default demo that runs when the > java -jar swirlds.jar command is run or if the swirlds.jar file is double clicked.
It displays basic statistics such as:
- number of corrupted events received per second
- average number of bytes per second transfered during a sync
- number of bytes in the transactions received per second (from unique
- events created by self and others)
- number of bytes in each transactions
- number of events per second created by this node
- number of times a TLS connections was created
- percentage of events received that are already known
This is neat but let’s get the “Hello World” or in this case “Hello Swirlds” app going.
Step 5: Hello Swirlds
Quit the Stats Demo application with command+q or ctrl+c in terminal and open up config.txt
Uncomment by removing the “#” from line 8 “app, HelloSwirldDemo.jar” and re-comment out by typing # in front of line 10 “#app, StatsDemo.jar”. Save the file and then re-run the application and you should get this:
You’ll see I’ve been a bit crafty and changed the name Alice to Seandotau. This was just another simple change in the config.txt file.
If you had Java 8 and the Java Cryptography Extension already, this demo would have taken only about 5 minutes to spin up. It’s a neat way to see something in action for yourself in a few simple steps. Keep experimenting, and remember, learning is doing!