I made my own CorDapp according to Corda's official documentation. In this article, I will describe up to the point of creating states.
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".)
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.
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.
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.
Next time, I plan to resume from creating contracts.
Recommended Posts