[LINUX] Try making your own CorDapp. (Until States creation)

Article summary

I made my own CorDapp according to Corda's official documentation. In this article, I will describe up to the point of creating states.

Official documentation

https://docs.corda.net/_static/corda-developer-site.pdf (Mainly implemented according to Chapter 5 "Getting started developing Cor Dapps" and Chapter 6 "KEY CONCEPTS".)

Overview of states

  1. What are "states"? States are objects in which "facts on the ledger" are recorded. states are updated as the state changes (the amount moves, the ownership changes, etc.). In addition, each node participating in the Corda platform has its own states, It has a vault for storage.

  2. Sequence of "states" update "States" situations are immutable (objects whose state cannot be changed after creation) It cannot be updated directly. Instead, create a new version of states that represents the new states, Mark existing states as history. The history of states is accumulated in the vault of each node.

Implementation of states

Try coding CorDapp according to the official document "5.2.2 Step Two: Creating states". By the way, the programming language is Kotlin.

CarState.kt


package com.template.states
import com.template.contracts.CarContract
import com.template.contracts.TemplateContract
import net.corda.core.contracts.BelongsToContract
import net.corda.core.contracts.ContractState
import net.corda.core.contracts.UniqueIdentifier
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
// *********
// * State *
// *********
@BelongsToContract(CarContract::class)
data class CarState( ※1
val owningBank: Party, ※2
val holdingDealer: Party,
val manufacturer: Party,
val vin: String,
val licensePlateNumber: String,
val make: String,
val model: String,
val dealershipLocation: String,
val linearId: UniqueIdentifier ※3
) : ContractState { ※1
override val participants: List<AbstractParty> = listOf(owningBank, holdingDealer, manufacturer) ※4
}

Below is a note of "*" in the source.

At the end

Next time, I plan to resume from creating contracts.

Recommended Posts

Try making your own CorDapp. (Until States creation)
Try implementing k-NN on your own
Until you self-host your own interpreter
Until you install your own Python library
Try to make your own AWS-SDK with bash
Linux C / C ++ Build your own library creation environment
Try to improve your own intro quiz in Python
Try to put LED in your own PC (slightly)