Composer Playground

As Composer Playground has already been installed, we can start the corresponding container using:

sudo docker run --name composer-playground --publish 8080:8080 --detach hyperledger/composer-playground

Once the container has started, open a browser and navigate to localhost:8080, where you should see the following welcome page:

You can shut down playground at any time, using:

sudo docker rm --force composer-playground

If everything is ready, let’s start to play!

First, let's create a new business network by clicking on Deploy a new business network. Afterwards you'll need to provide some details about your new business network, for example a name—fsn-business-network. Then select empty-business-network, and click Deploy.

Once created, you have to connect to the fsn-business-network by clicking Connect now:

You'll get a few files, and among them will be a model file. Hyperledger Composer provides an object-oriented-like modeling language, which allows us to define the domain model for a business network definition in a .cto file. You can learn more about this modeling language and this file's structure from the official documentation at: https://hyperledger.github.io/composer/v0.19/reference/cto_language. For the sake of our example, let's adopt the following sample:

After that, we need to define your transaction processor script file by adding a JavaScript file with the following content:

Then, we need to define the access control policy. We use the default network administrator to give full access to the business network and system-level operations:

Once you have finished, click Deploy changes in the bottom left to upgrade the business network, and click Test to get a test started.

We should add a participant to our business network. To do that, create a participant by selecting the left menu's Consumer tab, and clicking Create new participant in the upper right. Modify the value with your details, then click Create new to create the new participant.

Now, we need to create an asset. This can be done by selecting the left menu Food tab under assets, and clicking Create new asset in the upper right. Enter or modify the value you need to test. Then click Create new to create the new asset.

You should see the newly created asset in the Food tab:

At this level, you can submit a transaction by entering the corresponding orderId and consumerId defined in previous steps:

Once submitted, you can view the log of your transactions by clicking All transactions on the left. Click View record to inspect the transaction details. You can see the transaction ID and when this transaction was processed:

By checking the food asset value, we can see that the consumer data is updated:

Now, you have an idea how Composer works and how easy it is to work with such a tool, instead of using the native Fabric infrastructure directly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset