Skip to content

amolpednekar/cordapp-token-ownable

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

CorDapp - Token CorDapp using OwnableState

Overview

This CorDapp models tokens using OwnableState

The TokenState implements OwnableState and has one additional attribute - Amount of type Int

There are three flows

  1. IssueTokenFlow - This flow is triggered by the Issuer node and takes in a single argument, amount.
  2. TransferTokenFlow - This flow is triggered by the Issuer node and takes in two arguments -> Party to which the token must be transferred and the amount of tokens to be transferred.
  3. CombineTokensFlow - This flow can be triggered by any node to aggregate all their TokenStates into a single TokenState

Pre-Requisites

See https://docs.corda.net/getting-set-up.html.

Usage

Run the following command from the project's root folder:

  • Unix/Mac OSX:

Build node directory & compile the CorDapp.

./gradlew deployNodes

Run all nodes

cd build/nodes

./runnodes

Run client

./gradlew runClient

This will run the CorDapp client defined HERE. This client will:

  1. Issuer node issues 200 tokens to receiver node.
Issuer's vault

[StateAndRef(state=TransactionState(data=TokenState(amount=200, owner=O=PartyA, L=London, C=GB, participants=[O=PartyA, L=London, C=GB]), contract=com.template.TokenContract, notary=O=Notary Service, L=Zurich, C=CH, ...]
  1. Issuers transfer token amounts of 100 and 50 to receiver, which creates 2 entries in receiver's node
Issuer's vault

[StateAndRef(state=TransactionState(data=TokenState(amount=50, owner=O=PartyA, L=London, C=GB, participants=[O=PartyA, L=London, C=GB]), contract=com.template.TokenContract, notary=O=Notary Service, L=Zurich, C=CH, ... ]
Receiver's vault 

[StateAndRef(state=TransactionState(data=TokenState(amount=100, owner=O=PartyB, L=New York, C=US, participants=[O=PartyB, L=New York, C=US]), contract=com.template.TokenContract, notary=O=Notary Service, L=Zurich, C=CH .. ), 

StateAndRef(state=TransactionState(data=TokenState(amount=50, owner=O=PartyB, L=New York, C=US, participants=[O=PartyB, L=New York, C=US]), contract=com.template.TokenContract, notary=O=Notary Service, L=Zurich, C=CH ... ]
  1. Receiver combines all Token inputs into a single token
Receiver's vault

[StateAndRef(state=TransactionState(data=TokenState(amount=150, owner=O=PartyB, L=New York, C=US, participants=[O=PartyB, L=New York, C=US]), contract=com.template.TokenContract, notary=O=Notary Service, L=Zurich, C=CH, ...]

Running the nodes

See https://docs.corda.net/tutorial-cordapp.html#running-the-example-cordapp.

TODO

  • Add Flow/State/Tests to 'Spend' tokens
  • Add contract checks for 'Combine' command

About

A CorDapp which shows an example OwnableState to issue, send and combine tokens (Corda v3.3)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages