The evolving blockchain environment has brought a lot of blockchain development and testing tools. Building and running custom blockchains is now easier than before. Hyperledger Composer Playground is such a tool that provides an environment that quickly models and tests a blockchain network. The composer has a simple Graphical UI to edit and test the business blockchain network. The playground makes the highly complex blockchain network easy for running.
Both online and offline version of Playground is available. While the online playground runs the business network in browser memory, local playground is deployed in Hyperledger Fabric instances.
The Online Playground can be accessed here: https://composer-playground.mybluemix.net
When Playground is used in Browser only mode, all the data including the assets, business networks, transactions, and participants have stored in browser local storage.
Let's check, How to install hyperledger Composer Playground locally,
Basic needs
1. Operating Systems: Ubuntu Linux 16.04 LTS ( 64-bit), or Mac OS 10.12
2. At least 4Gb of memory.
3. Docker Engine 17.03 or greater
4. Docker Compose 1.8 or greater
Docker and Docker compose installation in Ubuntu 16.04 LTS (64-bit)
Follow the comments
- install docker
$ sudo apt install docker.io
- install docker compose
$ sudo apt install docker-compose
- create a user group
$ sudo usermod -a -G docker $USER
You can check the version of docker and docker compose version by
$ docker --version
$ docker-compose --version
If you have used Hyperledger Fabric or Hyperledger Composer Playground locally before, and wish to clear all traces and start fresh, use the following commands. It will delete all downloaded images and any running containers. But be careful if you are using any other docker images on your machine.
docker ps -aq | xargs docker rm -f
docker images -aq | xargs docker rmi -f
Creating the containers and installing playground locally
curl -sSL https://hyperledger.github.io/composer/install-hlfv1.sh | bash
Or
docker run --name composer-playground --publish 8080:8080 hyperledger/composer-playground
This command will download and start a Hyperledger Fabric instance and Hyperledger Composer Playground. Before executing this command, make sure the connectivity of the internet. A stable net connection is needed.
If you already install it then use the following command to restart the playground
-Open terminal
- Type this command and press enter: ./composer.sh
A playground is running now, you can access the playground in a web browser.
Let’s check https://localhost:8080/login
You can see the Blockchain playground welcome screen.

Click on the Button “Let’s Blockchain!” to start playground.
click on the “Deploy a new business network” button.
Give a name for the network.
We can choose a right template from here. There are several templates will be loaded.
In this example, we have just created an empty-business network template.
Click the Deploy button to deploy the blockchain. You can see that an ID card for the admin user is also created.
In the bottom of the id card, there is a “Connect now” button to connect the admin to the new network,
You will be directed to define the tab after connected to the business network mode.
On the top, we can see a “define” tab and test tab.
From the define tab, we can define or write and work with the model in the business network.
Click the Add a file button to add a file
From the wizard, you can add the four necessary files namely
- Model file
- Job script file
- Query file
- Access Control files
Model file
In this file, we define the Assets, Participants, and Transactions in the business model.
Choose this file and click the “Add” button. The new model file opens automatically.
/**
* New model file
*/
namespace org.acme.myfirstmodel
asset Test identified by testId {
o String testId
o String message
}
transaction helloworld {
--> Test test
}
Script File (.js)
/**
* New script file
*/
/**
@param {org.acme.myfirstmodel.helloworld} helloworld
@transaction
*/
function helloworld(helloworld) {
console.log("Hello world" + helloworld.test.message);
}
Update it by clicking the update button. And we are just ready to test the model.
Before we can use the test model, we have to instantiate an Asset and store it in the Asset Register.
Create a new Asset, give a testId and message and save it.
The instance is saved in the Asset registry.
Now we can open the javascript console by clicking F12.
Then click on the “Submit Transaction” button for invoking the ‘helloworld’ transaction.
Then specify the id of the transactions and submit it. We can check the console to see the transaction status.
Nothing fancy here, it simply shows you a model for asset and transaction management.
How to instantiate an asset, store the asset in the asset register, and pass the asset into a transaction.
Obviously, a real application will be more complicated. But I hope it will give you a basic idea to test your model and playground.