• Pricing
  • Enterprise
  • Customers
  • Blog

Picking an enterprise blockchain protocol to develop on: Corda, Kotlin & Java

As a Kotlin developer;
As a Java developer.

In brief

This post is a part of the multipart series aimed at developers looking to try their hand out at and get a taste of the enterprise blockchain world.

This post focuses on running a “Hello, Block!” smart contract on Corda for developers primarily comfortable with Java and Kotlin.

Architecture

On Corda, a smart contract is called a CorDapp. Each CorDapp consists of a contract and a flow. The contract establishes the transaction validity, and the flow automates the logic of the exchange between the involved nodes.

A CorDapp must be installed on each of the nodes involved in an exchange. Unlike in public blockchain protocols, the smart contracts are not propagated to all nodes in the network.

Each exchange is notarized by a separate node called the notary.

Ecosystem

Corda is mainly driven by R3 developers—R3 is the company behind Corda.

Prerequisites

  1. A Chainstack account.
  2. Two Corda nodes. See Deploy a consortium network and Add a node to a network.

Corda “Hello, Block!” in Kotlin

Smart contract

State

Flow

Source on GitHub.

You can clone the “Hello, Block!” repository to see the full code and experiment with it.

Corda “Hello, Block!” in Java

Smart Contract

State

Flow

Flow

Flow responder

Source on GitHub.

You can clone the “Hello, Block!” repository to see the full code and experiment with it.

Build the smart contract and the flow

To build the contract and the flow, run ./gradlew build in the root of the cloned repository.

This will build the contract and the flow JAR files:

/contract/build/libs/contracts-0.1.jar
/workflows/build/libs/workflows-0.1.jar

Install the smart contract and the flow

Install both the contract and the flow on each of the two nodes you deployed. See Installing a CorDapp.

Connect to one of the nodes

To be able to interact with the CorDapps, you must have the contract and the flow JAR files both locally on your machine and on the node you are connecting to.

Copy the previously built contract and flow JAR files to a directory on your machine.

Connect to one of your nodes while providing the directory with the JAR files on your local machine. For detailed instructions, see Corda interaction tools.

Interact with “Hello, Block!”

In the shell, run:

start helloBlockFlow target: "LEGAL_NAME"

where

  • LEGAL_NAME — the legal name of your second Corda to which you are sending a “Hello, Block!” transaction. To get the node’s legal name, see View node access and credentials.

Example:

start helloBlockFlow target: "OU=RG-254-409-ND-141-587-071, O=RG-254-409, L=Portland, C=US, ST=Oregon"

Output:

 ✓ Starting 
          Requesting signature by notary service 
              Requesting signature by Notary service 
              Validating response from Notary service 
     ✓ Broadcasting transaction to participants 
▶︎ Done 
Flow completed with result: SignedTransaction(id=F2B267806C09BDEEB0E1E815AC1502EFFCD8C4F19F5701CFE9BECC46871AE47C)

Congratulations! What you have just done is: a) deployed a two-node private Corda network; b) built a smart contract in the programming language you are comfortable with; c) interacted with it on your Corda network.

And it wasn’t even complicated.

For more sophisticated and real-world scenarios, explore Chainstack tutorials.

Join our community of innovators

SHARE THIS ARTICLE

Chainstack announces support for Solana blockchain

Chainstack launches Solana blockchain on its platform, providing the easiest way for enterprises and developers to build Solana projects and scale Web3 applications with powerful node access and blockchain infrastructure.

Janson Lee
Feb 15