No description, website, or topics provided.
Clone or download
Latest commit efb1817 Jun 28, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Initial Setup Jun 28, 2018
cordapp-clearing-house Initial Setup Jun 28, 2018
cordapp-common Initial Setup Jun 28, 2018
cordapp-contracts-states Initial Setup Jun 28, 2018
cordapp-security-buyer Initial Setup Jun 28, 2018
cordapp-security-seller Initial Setup Jun 28, 2018
gradle/wrapper Initial Setup Jun 28, 2018
lib Initial Setup Jun 28, 2018
src Initial Setup Jun 28, 2018
LICENCE Initial Setup Jun 28, 2018
README.md Initial Setup Jun 28, 2018
TRADEMARK Initial Setup Jun 28, 2018
build.gradle Initial Setup Jun 28, 2018
gradle.properties Initial Setup Jun 28, 2018
gradlew Initial Setup Jun 28, 2018
gradlew.bat Initial Setup Jun 28, 2018
settings.gradle Initial Setup Jun 28, 2018

README.md

Three-way flows - DvP atomic transaction - CorDapp

This CorDapp creates Delivery-vs-Payment atomic transaction for on ledger Asset transfer for Cash with three participants.

CorDapp Nodes:

  • Security Seller: This party is owner of Asset state of type OwnableState on ledger. He sells these assets for cash by creating Corda transaction.
  • Security Buyer: This party has some Cash tokens on his ledger. He purchases Asset securities for Cash.
  • Clearing House: coordinates Seller and Buyer parties to process the settlement transaction. It initiate settlement of Asset transfer request and collect the required states (i.e. Asset and Cash) from counterparties (i.e. Seller and Buyer) in-order to complete the transaction.
  • Notary: notary node to check double-spend of input states then verify and sign final transaction.

This CorDapp example business-logic flows as below:

    1. The Seller party creates the Asset state of type OwnableState on ledger.
    1. Create AssetTransfer state and share it with Buyer party who willing to buy the Asset.
    1. The Buyer party review and accept the AssetTransfer transaction and further share this state with ClearingHouse party.
    1. The ClearingHouse party - offline review and validate the Asset data received along with AssetTransfer state. If everything is good, he initiate the AssetSettlementInitiatorFlow flow to create the settlement transaction with three participants. On completion of settlement transaction Buyer party became owner of Asset state and issues Cash tokens equals to the amount of Asset.purchaseCost to Seller party on ledger.

Interacting with the CorDapp via Corda Shell

Use relevant node's Shell console to initiate the flows.

Let's start flows from each Corda node's shell console step-by-step:

1. To create Asset - run below command on SecuritySeller node's console:

flow start com.synechron.cordapp.seller.flows.CreateAssetStateFlow$Initiator cusip: "CUSIP222", assetName: "US Bond", purchaseCost: $10000

To see state created run below command:

run vaultQuery contractStateType: com.synechron.cordapp.state.Asset

Now we have on ledger asset of type OwnableState and ready to sell it to other party on network.

2. To create AssetTransfer - run below command again on SecuritySeller node's console:

flow start com.synechron.cordapp.seller.flows.CreateAssetTransferRequestInitiatorFlow cusip: "CUSIP222", securityBuyer: "O=SecurityBuyer,L=New York,C=US"

To see AssetTransfer state created run below command again:

run vaultQuery contractStateType: com.synechron.cordapp.state.AssetTransfer

You can see the AssetTransfer state data and copy the linearId.id field value of it and save it with you as we required it in next step.

3. The Buyer party confirm AssetTransfer request received by running below command on counterparty SecurityBuyer node's console:

flow start com.synechron.cordapp.buyer.flows.ConfirmAssetTransferRequestInitiatorFlow linearId: "<Replace with AssetTransfer.linearId.id>", clearingHouse: "O=ClearingHouse,L=New York,C=US"

This flow update the AssetTransfer.status value to PENDING from it's initial value PENDING_CONFIRMATION.

4. The Buyer party self-issue the Cash tokens on ledger using:

flow start net.corda.finance.flows.CashIssueFlow amount: $20000, issuerBankPartyRef: 1234, notary: "O=Notary,L=New York,C=US"

To see the issued cash balance run:

run vaultQuery contractStateType: net.corda.finance.contracts.asset.Cash$State

5. Run below command on the ClearingHouse party node's console to create settlement transaction and distribute to three participants:

flow start com.synechron.cordapp.clearinghouse.flows.AssetSettlementInitiatorFlow linearId: "<Replace with AssetTransfer.linearId.id>"

On successful completion of flows the AssetTransfer.status field value became TRANSFERRED. Now you can cross-check the available Asset and Cash states on each counterparty corda node.