Git Product home page Git Product logo

accounts-demo-supplychain's Introduction

This sample has officially moved to the Account section in the samples-kotlin.

Accounts_SupplyChain

For More information regarding the Accounts Library, please read at: https://github.com/corda/accounts/blob/master/docs.md

This sample describes a mock/simple supply chain business flow.

Corda

From the above chart, you can see the flow is going back and forth between different parties' accounts. Please follow the instruction below to experience the Accounts library.

Setting up

Go into the project directory and build the project

./gradlew clean deployNodes

Run the project

./build/nodes/runnodes

Now, you should have four Corda terminals opened automatically.

Shell Instructions (Part 1) - Creating & Sharing Accounts

Go to the Buyer's node terminal and paste in the following code: (You can select all 7 lines and copy to the terminal all at once)

flow start CreateNewAccount acctName: BuyerProcurement
flow start CreateNewAccount acctName: BuyerFinance
flow start CreateNewAccount acctName: BuyerWarehouse

flow start ShareAccountTo acctNameShared: BuyerProcurement, shareTo: Seller
flow start ShareAccountTo acctNameShared: BuyerFinance, shareTo: Seller
flow start ShareAccountTo acctNameShared: BuyerWarehouse, shareTo: ShippingCo
flow start ShareAccountTo acctNameShared: BuyerWarehouse, shareTo: Seller

This is creating 3 accounts under Buyer's node and sharing with their specific conterpartie's node or account.

Go to the Seller's node terminal and paste in the following code:

flow start CreateNewAccount acctName: SellerSales
flow start CreateNewAccount acctName: SellerFinance
flow start CreateNewAccount acctName: SellerInventory

flow start ShareAccountTo acctNameShared: SellerSales, shareTo: Buyer
flow start ShareAccountTo acctNameShared: SellerFinance, shareTo: Buyer
flow start ShareAccountTo acctNameShared: SellerInventory, shareTo: ShippingCo

This is creating 3 accounts under Seller's node and sharing with their specific conterpartie's node or account.

[Optional]: You can run a vaultQuery to see the accoutnInfo that been stored at each node by using:

run vaultQuery contractStateType: com.r3.corda.lib.accounts.contracts.states.AccountInfo

Shell Instructions (Part 2) - Executing Business Flows

Step 1: Seller's sales team send inovice of $500 to Buyer's procurement team

navigate to Seller's node terminal and run

flow start SendInvoice whoAmI: SellerSales, whereTo: BuyerProcurement, amount: 500 

[Optional]: If you would like to verify the message had been successfully pass into Buyer's procurement team, you can navigate to Buyer's node terminal and type in:

flow start ViewInboxByAccount acctname: BuyerProcurement

You see that the invoice state amount 500 is returned. You can also replace the BuyerProcurement with BuyerWarehouse to see that the non-relevant accounts has no visiblity about the invoice state.

Step 2: Buyer's procurement team will send an internal message to Buyer's Buyer's finance team

Navigate to Buyer's node terminal and type in:

flow start InternalMessage fromWho: BuyerProcurement, whereTo: BuyerFinance, message: Send 500 to SellerFinance

[Optional verification]: run flow start ViewInboxByAccount acctname: BuyerFinance at Buyer' node terminal

Step 3: Buyer's finance team send a payment to Seller's finance team

Navigatie to Buyer's node terminal and type in:

flow start SendPayment whoAmI: BuyerFinance, whereTo: SellerFinance, amount: 500

[Optional verification]: run flow start ViewInboxByAccount acctname: SellerFinance at Seller's node terminal

Step 4: Seller's finance team send an internal message to Seller's inventory team to instruct them to send the cargo

Navigate to Seller's node terminal and type in

flow start InternalMessage fromWho: SellerFinance, whereTo: SellerInventory, message: send Cargo to Buyer

[Optional verification]: run flow start ViewInboxByAccount acctname: SellerInventory at Seller's node terminal

step 5: Seller's inventory team send a shipping work order for shipping company

Navigate to Seller's node terminal and type in

flow start SendShippingRequest whoAmI: SellerInventory, whereTo: BuyerWarehouse, shipper: ShippingCo, Cargo: 10 boxes of Books

[Optional verification]: run run vaultQuery contractStateType: com.accounts_SupplyChain.states.ShippingRequestState at ShippingCo's node terminal

Step 6: Shipping company sends the cargo to Buyer's warehouse

Navigate to ShippingCo's node terminal and type in

flow start SendCargo pickupFrom: SellerInventory, shipTo: BuyerWarehouse, cargo: Books

[Optional verification]: run flow start ViewInboxByAccount acctname: BuyerWarehouse at Buyer's node terminal

Now, the entire business chain is completed.

accounts-demo-supplychain's People

Contributors

peterli-r3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.