Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of a post-consuming choice
daml 1.2
module M where
template LeaseOffer
with
realtor : Party
tenant : Party
where
signatory realtor
observer tenant
choice Accept : ContractId Lease with
guarantor : Party
controller tenant
do
create Lease with ..
template Lease
with
realtor : Party
tenant : Party
guarantor : Party
where
signatory realtor, tenant
observer guarantor
nonconsuming choice ReferAFriend : ContractId ReferAFriendOffer
controller realtor
do
create ReferAFriendOffer with leaseCid = self, ..
postconsuming choice Terminate : ContractId ReferAFriendOffer
controller realtor
do
exercise self ReferAFriend
template ReferAFriendOffer
with
realtor : Party
tenant : Party
leaseCid : ContractId Lease
where
signatory realtor
main = scenario do
ken <- getParty "Ken"
alice <- getParty "Alice"
alice'sDad <- getParty "Papa"
leaseOfferCid <- submit ken do
create LeaseOffer with
realtor = ken
tenant = alice
leaseCid <- submit alice do
exercise leaseOfferCid Accept with guarantor = alice'sDad
referAFriendOfferCid <- submit ken do
exercise leaseCid Terminate
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.