DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Pooria Poorsarvi Tehrani
Pooria Poorsarvi Tehrani

Posted on

Use blockchain, like a cloud user, using kaleido

Hyperledger fabric is very great to use. It gives the users the ability to customize their networks and is more performant and private. All great features to have for enterprise applications.

All of this, however, comes out at the cost of simplicity. Bringing up a simple network can be daunting when considering the number of arguments you have to consider and how you have to handle authentication at each step.

This is all good when customizing the network with very complex rules and complex authentication certificates, but this might become a headache when building an MVP.

Here is where Kaleido comes in. This platform can set up your structure with a user-friendly UI and gives you REST APIs that have default options that you can use to quickly set up your network programmatically without handling things like authentications yourself.

In this tutorial, we will go through the basics of using Kaleido.

Kaleido can be divided into three main sections:

Image description

  • Network or consortia: this is the network of organizations that work together or your business network; it might be a little bit confusing with fabric network, which we will see next. But the key takeaway is that this network is your business network and not your fabric network. Image description
    • Here we can define apps. Apps are used for defining chain codes. Notice that at this point, we are only defining apps so that all organizations in our business network can see them, but they have not yet been deployed to fabric networks.

Image description

  • Environments. This is where the actual fabric networks are defined. Image description

Here we can define hyperledger networks. So you can deploy channels and promote your chain codes here (which is other words, for sending in your chain code to fabric networks).
Image description
- Before moving forward with anything, you will need to have an orderer node and a peer node. These will allow you to submit things as an organization and make your API calls, respectively.

  • Once your environment is ready, you can make your channel (there is a default one created for you) and promote chain codes to environments. Image description
    • You can upload chain code by clicking on the "Create new version", then you need to run GOOS=linux GOARCH=amd64 go build -o output.bin and upload the output. Image description Image description
    • You can then promote your uploaded version to an environment that gives you the ability to deploy your chain code to channels.

Image description
Image description
Once all this setup is done, you can access your APIs through the peer node.

Now we will talk about how to run your chain code from the API

Image description

You should use a post request to /identities to create a new user to make your calls your transaction calls with.

Image description

Then you can use the secret information you have gained alongside a post-call to /identities/{username}/enroll to enroll your client.

Image description

Once that is done, you can make your transactions by your chain code using post calls to /transactions. For the signer option, you can use the client's name that you just made. And for arguments, you can pass the string of all the arguments you want to use. Please note that if you want to get the final result of your transaction instead of the link to the receipt, you should set fly-sync to true.

Image description
You can use the same values alongside a post-call to /query for querying.

Now, if you are wondering how to do the following automatically, it is straightforward as long as you follow the following two concepts.

  • For everything we did outside the peer node, you can find their API at https://api.kaleido.io/platform.html. However, for using these APIs, you will need access to your Bearer authentication, which can be found under your user profile under https://console.kaleido.io/profile under API keys. Image description
  • For all the APIs that we used in the peer node, we need to create an application credential that is based on the environment. Please note that once you create the credential, you will be given one-time access to your username and password and links on how to connect to the peer node API while being authenticated. Image description (Please keep your secrets safe and don't share their screenshots XD ... unless you are deleting them afterward)

Using all of this, you should be able to create networks fast, deploy them with ease, and handle most of your logic programmatically.

Limits

Kaleido currently does not support customized policies for validation within the channel. However they are working on that, but for the time being, you should consider that the validation of your transactions is done through the majority vote or more than half of the organizations within your channel.

Going decenterlized

Once you are sure of your network and have tested your logic, you can add more organizations to the Kaleido network, allowing them to add their own node or have self-hosted instances; however, that requires you to at least have a business plan with Kaleido.

Conclusion

Kaleido is a helpful platform for starting out with fabric and testing out new ideas quickly. However, it is a new platform that you need to learn to work with, although there is a good amount of documentation and tutorials for the platform.

I hope this post has been helpful and if you have any more questions checking Kaleido's youtube channel and documents is always very helpful.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.