Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
Hi all,
I have scavenged and brushed up a PoC I did on Business Process Modelling in DAML. It is inspired by BPMN - but isn’t in anyway compatible with or an interpreter of BPMN. It’s very much a work in progress, and was made to demonstrate two things:
- How to implement a simple flexible smart contract language as a state machine inside a DAML contract.
- How to express that smart contract language with a DSL in DAML.
Here’s a scenario demonstrating it:
commercialFinancing = scenario do
sales <- getParty "sales"
risk <- getParty "risk"
admin <- getParty "administration"
credit <- getParty "credit"
cid <- issueProcess do
ack sales "Consolidate and Digitize Data"
ack sales "Analyze Financial Data"
select sales "Qualified Request?" do
ch "Yes" do
ack credit "Verify Credit Record with Credit Offices"
ack risk "Sign-off from Risk"
ack admin "Prepare Detailed Analysis of Financial Data"
ack sales "Prepare Detailed Analysis"
select sales "Qualified Request?" do
ch "Yes" do
ack sales "Elaborate Commercial Financing Reporting"
ch "No" do
ack sales "Prepare and Transmit Refusal Letter"
cancel
ch "No" do
ack sales "Prepare and Transmit Refusal Letter"
cancel
service sales "done!"
Some cid <- sales `submit` exercise cid $ Select0 "ack"
Some cid <- sales `submit` exercise cid $ Select0 "ack"
Some cid <- sales `submit` exercise cid $ Select0 "Yes"
Some cid <- credit `submit` exercise cid $ Select0 "ack"
Some cid <- risk `submit` exercise cid $ Select0 "ack"
Some cid <- admin `submit` exercise cid $ Select0 "ack"
Some cid <- sales `submit` exercise cid $ Select0 "ack"
Some cid <- sales `submit` exercise cid $ Select0 "Yes"
_ <- sales `submit` exercise cid $ Select0 "ack"
It’s defining (at runtime!) a business process involving three parties. At multiple steps a service event is triggered awaiting an acknowledgement from the specified party. At two occasions a specified party needs to make a choice between “Yes” and “No” branching the business process.
Enjoy!