Signed-off-by: Ed Prosser <edward.prosser@r3.com>
2.7 KiB
Running the example CorDapp
At this point we've set up the development environment, and have an example CorDapp in an IntelliJ project. In this section, the CorDapp will be deployed to locally running Corda nodes.
The local Corda network includes one notary, and three nodes, each representing parties in the network. A Corda node is an individual instance of Corda representing one party in a network. For more information on nodes, see the node documentation.
Before continuing, ensure that you've set up your development environment.
Step One: Deploy the CorDapp locally
The first step is to deploy the CorDapp to nodes running locally.
- Navigate to the root directory of the example CorDapp.
- Deploy the CorDapp by running the following command:
./gradlew deployNodes
- To best understand the deployment process, there are several perspectives it is helpful to see. Run the following command:
build/nodes/runnodes
This command opens four terminal windows: the notary, and a node each for PartyA, PartyB, and PartyC. A notary is a validation service that prevents double-spending, enforces timestamping, and may also validate transactions. For more information on notaries, see the notary documentation.
- Go through the tabs to see the perspectives of other network members.
Step Two: Run a CorDapp transaction
Open the terminal window for PartyA. From this window, any flows executed will be from the perspective of PartyA.
To execute the
ExampleFlow.kt
flow, run the following command:flow start ExampleFlow iouValue: 1, otherParty: PartyB
A flow is the mechanism by which a transaction takes place using Corda. This flow creates an instance of the IOU state, which requires an
iouValue
property. Flows are contained in CorDapps, and define the mechanisms by which parties transact. For more information on flows, see the flow documentation.To check whether PartyB has received the transaction, open the terminal window showing PartyB's perspective, and run the following command:
run vaultQuery contractStateType:net.corda.example.IOUState
This command displays all of the IOU states in the node's vault. States are immutable objects that represent shared facts between the parties. States serve as the inputs and outputs of transactions.
Next steps
After deploying the example CorDapp, the next step is to start writing a CorDapp containing your own contract, states, and flows.