How to create application-specific blockchain using Cosmos SDK and Ignite CLI

How to create application-specific blockchain using Cosmos SDK and Ignite CLI

calenderAugust 23, 2023 | Editor Choice
clock 2 min read
--:--
--:--
 Zaryab Rafique

Zaryab Rafique

Cosmos software is a layer 0 blockchain that provides interoperability and constitutes a decentralized system comprising distinct parallel blockchains. Each of these blockchains are driven by BFT consensus algorithms, such as the Tendermint consensus. It provides the Cosmos SDK framework and Ignite CLI to build the application-specific blockchain. 

Ignite CLI is built on top of Cosmo SDK. It is a user-friendly command-line tool for establishing and managing self-governing blockchains tailored for specific applications. Ignite CLI and the modules within Cosmos-SDK are crafted using the Go programming language. 

In this article, I will explain how to create an application-specific layer 1 blockchain using Cosmos’s Ignite CLI tool. 

Install Golang & Ignite CLI

Let's start by installing the Golang and Ignite CLI.

Install Golang

The Golang version must be 1.19 or higher. Go to the installation link: https://go.dev/doc/install. Select the OS of your local machine and download the Golang and install it on your machine.

Verify the Go Version

To verify the Go installation version, enter the following command on the terminal.

go version

Install the Ignite CLI

The Ignite CLI has been developed using the Go programming language

To Install Ignite CLI latest version, run the following command in the terminal.

curl https://get.ignite.com/cli! | bash

Verify the Ignite CLI Version

To verify the Go installation version, enter the following command on the terminal.

ignite version

Create a Scaffold Chain

First, create a new “blox” blockchain with Ignite CLI, and run the following command:

ignite scaffold chain blox

Add Custom Query in Chain

Add the custom in your blockchain that responds to the “Hello, &s” where s is the name. To do that, use the Ignite CLI that generates the code and modify the query to return the desired response.

Create a query with Ignite

In Ignite CLI, the query is the request to the blockchain that retrieves the data from a blockchain, such as the current state of the ledger or the details of a specific transaction.

To create a query, enter the following command of the root of the “blox” project directory. 

ignite scaffold query say-hello name --response name

Utilizing the ignite scaffold query command allows for the generation of queries. Executing this command results in modifying your source code, adding the newly generated query, and enabling its accessibility within your API. This command takes as input a query name ("say-hello") and an array of request fields (in our scenario, solely "name"). Optionally, the --response flag can define the query's returned values.

Start the Blockchain

You have added the query to your blockchain; now start your application-specific blockchain using Ignite CLI command. 

Run the following command on the root of the “blox” project.

ignite chain serve

You can use the command line tool to interact with the blockchain to perform the transaction and query the chain state.

Run Query

To build the contract, run the following in the project root directory at the terminal.

bloxd q hello say-hello invo

After executing this command, the "bloxd" binary will dispatch a "say-hello" query to your blockchain, accompanied by the argument "invo.” The blockchain will handle the query's processing and subsequently yield a result. This outcome will be displayed through the "bloxd" binary. In this context, the anticipated development entails a string with "Hello, invo.”

Conclusion

We have installed the Golang, Ignite CLI, and created the scaffold chain with the name  “blox,” then added the query of say-hello. After building & start the “blox” chain and running the query with its daemon “bloxd” that gives the result. You have created a Cosmos DB SDK module named "hello," featuring personalized query capabilities. This allows users to interact with the blockchain and get personalized greetings as responses. It's the most straightforward application-specific blockchain built using the Ignite CLI, plus you can add custom modules and queries to it according to your requirements. 

Want to Create your application-specific blockchain? Contact us at InvoBlox and leverage the power of Cosmos SDK and Ignite CLI to build a tailored blockchain solution that meets your unique requirements.

 

Cosmos software is a layer 0 blockchain that provides interoperability and constitutes a decentralized system comprising distinct parallel blockchains. Each of these blockchains are driven by BFT consensus algorithms, such as the Tendermint consensus. It provides the Cosmos SDK framework and Ignite CLI to build the application-specific blockchain. 

Ignite CLI is built on top of Cosmo SDK. It is a user-friendly command-line tool for establishing and managing self-governing blockchains tailored for specific applications. Ignite CLI and the modules within Cosmos-SDK are crafted using the Go programming language. 

In this article, I will explain how to create an application-specific layer 1 blockchain using Cosmos’s Ignite CLI tool. 

Install Golang & Ignite CLI

Let's start by installing the Golang and Ignite CLI.

Install Golang

The Golang version must be 1.19 or higher. Go to the installation link: https://go.dev/doc/install. Select the OS of your local machine and download the Golang and install it on your machine.

Verify the Go Version

To verify the Go installation version, enter the following command on the terminal.

go version

Install the Ignite CLI

The Ignite CLI has been developed using the Go programming language

To Install Ignite CLI latest version, run the following command in the terminal.

curl https://get.ignite.com/cli! | bash

Verify the Ignite CLI Version

To verify the Go installation version, enter the following command on the terminal.

ignite version

Create a Scaffold Chain

First, create a new “blox” blockchain with Ignite CLI, and run the following command:

ignite scaffold chain blox

Add Custom Query in Chain

Add the custom in your blockchain that responds to the “Hello, &s” where s is the name. To do that, use the Ignite CLI that generates the code and modify the query to return the desired response.

Create a query with Ignite

In Ignite CLI, the query is the request to the blockchain that retrieves the data from a blockchain, such as the current state of the ledger or the details of a specific transaction.

To create a query, enter the following command of the root of the “blox” project directory. 

ignite scaffold query say-hello name --response name

Utilizing the ignite scaffold query command allows for the generation of queries. Executing this command results in modifying your source code, adding the newly generated query, and enabling its accessibility within your API. This command takes as input a query name ("say-hello") and an array of request fields (in our scenario, solely "name"). Optionally, the --response flag can define the query's returned values.

Start the Blockchain

You have added the query to your blockchain; now start your application-specific blockchain using Ignite CLI command. 

Run the following command on the root of the “blox” project.

ignite chain serve

You can use the command line tool to interact with the blockchain to perform the transaction and query the chain state.

Run Query

To build the contract, run the following in the project root directory at the terminal.

bloxd q hello say-hello invo

After executing this command, the "bloxd" binary will dispatch a "say-hello" query to your blockchain, accompanied by the argument "invo.” The blockchain will handle the query's processing and subsequently yield a result. This outcome will be displayed through the "bloxd" binary. In this context, the anticipated development entails a string with "Hello, invo.”

Conclusion

We have installed the Golang, Ignite CLI, and created the scaffold chain with the name  “blox,” then added the query of say-hello. After building & start the “blox” chain and running the query with its daemon “bloxd” that gives the result. You have created a Cosmos DB SDK module named "hello," featuring personalized query capabilities. This allows users to interact with the blockchain and get personalized greetings as responses. It's the most straightforward application-specific blockchain built using the Ignite CLI, plus you can add custom modules and queries to it according to your requirements. 

Want to Create your application-specific blockchain? Contact us at InvoBlox and leverage the power of Cosmos SDK and Ignite CLI to build a tailored blockchain solution that meets your unique requirements.

 

FAQS

The Cosmos SDK is an open-source framework by Tendermint. It is used to build public Proof-of-Stake (PoS) blockchains for multi-asset and permission-based Proof-of-Authority (PoA). Cosmos Blockchain SDK is also called an application-specific blockchains.

Ignite CLI is a combined platform to develop and maintain crypto applications on a secured blockchain. It is a development-oriented interface to the Cosmos SDK network, the world's most popular blockchain application framework.

When creating any application specific blockchain developer you can across several challenges, including:

  • Developer cost
  • Technical expertise
  • Hard deployment of blockchain
  • Scalability
  • Upgrade and Maintenance 

 

Ready to make something amazing?

ready to make banner

Ready to make something amazing?

mobile banner

Related Posts