DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. Get Started With MultiChain on Windows PC (Part 1)

Get Started With MultiChain on Windows PC (Part 1)

Part 1 of this blockchain experiment involves getting a private blockchain set up on a Windows machine using two nodes to connect and communicate.

Giannis Karavasilis user avatar by
Giannis Karavasilis
·
May. 21, 18 · Tutorial
Like (5)
Save
Tweet
Share
9.49K Views

Join the DZone community and get the full member experience.

Join For Free
This article is not a guide to teach you blockchain theory. It is a how-to article to get you started with multichain on a single machine.

Ever wanted to get started with blockchain but didn’t know where to start? There are many platforms out there, each having its pros and cons. What will be the steps to follow in order to create your own solution? A good choice to start would be MultiChain – a platform for blockchain based on Bitcoin created by the guys at Coin Sciences Ltd. With MultiChain, you can create your own private blockchain even for enterprise usage, easily configurable and permissioned. It is a platform designed to be easy to get started. They have a great Q&A and, overall, good documentation for their API. 

For Part 1, we will create a private blockchain on our PC and interact with it. Furthermore, I will show you how you can have a second node on the same PC. The two nodes can interact with the blockchain on the same PC, the same way as it would if you had two different PCs on the same network. In a real-world scenario, you would have different computers or VMs or Docker containers, but in this tutorial, we will use one PC without any VM or Docker.

In Part 2, we will create a Java project and interact with the blockchain.

Start by installing MultiChain on your Windows PC.

  • Navigate to https://www.multichain.com/download-install/

  • Under Installing MultiChain on Windows, download the ZIP file and extract its contents into a folder

Along with the extracted .exe files, you will see a README.txt file. Read it, especially the section WINDOWS NOTES, since you are on a Windows PC. 

My extracted folder is: C:\Users\ykarav\Downloads\multichain-windows-1.0.4.

Navigate to yours accordingly. Here, we will create a blockchain with the name tutchain.

Open a cmd on the extracted folder location and run the following command:

multichain-util.exe create tutchain

Image title

You will see a message indicating that the chain was created successfully. Also, you might notice the message about the params.dat file. This file contains parameters that you can change. Parameters regarding permissions, consensus and much more. Please be very careful with these parameters. Read the documentation before you change anything.

Inside this directory, along with the params.dat file, you will also find a multichain.conf file. This file contains your username and password.

Image title

Our private blockchain was just created! Now it is time to connect to it.

Run the following command:

multichaind.exe tutchain -daemon

Image title

Your node will start and you will see the IP and the PORT.

Image title

As you can see, my machine has two available IP/PORTS that other nodes can use to connect to it.

So far, you have a blockchain running on one node, our Windows PC. Since we created the chain, we have the full permissions for it. Let's get some info about the chain and our permissions.

To see the info about our tutchain, open a new cmd at the same location (unfortunately this has to be done since we are on a Windows PC…) and run the following command:

multichain-cli.exe tutchain getinfo

Image title

You will see the following JSON with info about the chain. Also notice the JSON-RPC call highlighted in red. You will need this info later when we run our Java project.

Image title

Try the following command to see your permissions:

multichain-cli.exe tutchain listpermissions

Image title

You will see a full list of your permissions such as: “mine”, “create”, “admin”, “connect”, etc.

So far, you have a blockchain up and running with only one node connected to it – your PC. Let’s create a second node and connect it to our chain.

Remember the first command we used to create the blockchain? The one where it informed us about the params.dat file. See the path to this file. For me, it is the following:

C:\Users\ykarav\AppData\Roaming\MultiChain\tutchain

It means that your chain lies inside: C:\Users\ykarav\AppData\Roaming\MultiChain

Also, take a look at the line where it says: “Other nodes can connect to this node using:” There you can see the IP and PORT that you need to provide to the second node for it to connect to the first one.

We will use a second node on the same PC, so we have to create one. Create a folder with the name MultiChain_Other inside the Roaming folder. You will have something like the following:

C:\Users\ykarav\AppData\Roaming\MultiChain_Other

We will create the new node and start it, but this time, we will use parameters to indicate the path to the second node and also the ports to be used for the connection.

A quick note here. Since our chain already exists every new node will not have full permissions. So node1 have to assign “connect” permission to node2.

Run the following command to create the second node:

multichaind.exe -datadir=C:\Users\ykarav\AppData\Roaming\MultiChain_Other -port=10255 -rpcport=10254 tutchain@172.16.212.153:6753

Image title

As we expected, we cannot yet connect to node1. But as you can see, MultiChain informs us about the connect permissions we need and how to run the command.

Here, 1H5n5Axy2RyVmSWwnUA1qziTrhoqRDexqaLJd8 is the address of the second node. We will provide it with the “connect” permission now from node1.

Run the following command to provide the “connect” permission to node2:

multichain-cli.exe tutchain grant 1H5n5Axy2RyVmSWwnUA1qziTrhoqRDexqaLJd8 connect

Image title

As you can see, we successfully granted connect permissions to node2. Another thing to notice here is that this transaction generated a hash number (30109747….)

Now, node2 can connect to node1. Start node2 again, same as before:

multichaind.exe -datadir=C:\Users\ykarav\AppData\Roaming\MultiChain_Other -port=10255 -rpcport=10254 tutchain@172.16.212.153:6753

Image title

And that’s it! You have a blockchain running on a single machine having two nodes.

Try to run the getinfo command again, but this time, from node2:

multichain-cli.exe -datadir=C:\Users\ykarav\AppData\Roaming\MultiChain_Other -port=10255 -rpcport=10254 tutchain getinfo

Image title

You will see a JSON with info about the blockchain. You can experiment more with API commands from https://www.multichain.com/developers/json-rpc-api/

Let's try the “listaddresses” command. Try the following and see the result on your console:

multichain-cli.exe tutchain listaddresses
multichain-cli.exe tutchain listaddresses * true


We are just scratching the surface here. There is so much more you can do with MultiChain. Worth noticing is the STREAMS feature in MultiChain. You can use it to save and retrieve information.

The MultiChain team has a great section for developers on their site. Start from there!

Blockchain Command (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java Concurrency: LockSupport
  • What Are the Different Types of API Testing?
  • gRPC on the Client Side
  • Cloud Performance Engineering

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: