This CorDapp serves as a basic example to create, issue, and move Fungible tokens in Corda utilizing the Token SDK. In this specific fungible token sample, we will not talk about the redeem method of the Token SDK because the redeem process will take the physical asset off the ledger and destroy the token. Thus, this sample will be a simple walk through of the creation, issuance, and transfer of the tokens.
Quick blog about TokenSDK see here
There are a few flows that enable this project. We will create a resource (in this case a house), and then issue tokens for that resource, and then transfer those tokens.
- We create the representation of a house, within
CreateHouseTokenFlow
. - We issue tokens
IssueHouseTokenFlow
- We then move the house token.
MoveHouseTokenFlow
Set up for CorDapp development
Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper)
./gradlew clean build deployNodes
Then type: (to run the nodes)
./build/nodes/runnodes
When started via the command line, each node will display an interactive shell:
Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to shut down the node.
Tue July 09 11:58:13 GMT 2019>>>
You can use this shell to interact with your node.
Create house on the ledger using Seller's interactive node shell, by typing:
flow start CreateHouseTokenFlow symbol: house, valuationOfHouse: 100000
This will create a linear state of type HouseTokenState in Seller's vault
Seller will now issue some tokens to Buyer. run below command via Seller's interactive node shell:
flow start IssueHouseTokenFlow symbol: house, quantity: 50, holder: Buyer
Now at Buyer's terminal, we can check the tokens by running:
flow start GetTokenBalance symbol: house
Since Buyer now has 50 tokens, move tokens to Friend from Buyer's terminal
flow start MoveHouseTokenFlow symbol: house, holder: Friend, quantity: 23
Now lets take look at the balance at both Buyer and their Friend's side
flow start GetTokenBalance symbol: house