Skip to content
CCPEDIAby Unity Nodes
VideosDaml 101: Takes Two to Tango: Initiate & Accept Explained [2022]

Daml 101: Takes Two to Tango: Initiate & Accept Explained [2022]

Nothing is loaded from YouTube until you press play, and then without tracking cookies.

About this video

📚Check out Daml Learning Center: bit.ly/LearnDaml 📖Join our forum and get started: bit.ly/tryDaml

This is a multi-episode series intended to take you from the brief context behind blockchain and smart contract to the development of smart contracts using a next-gen smart contract language called Daml. The entire series can be found here: bit.ly/damlone

Daml is a development framework for creating systems of record that securely connect across business processes and data boundaries while retaining privacy, guaranteeing data integrity, and enforcing strict authorization. Allowing such systems to cross boundaries — legal, regulatory, organizational, or other — enables them to form seamless economic networks.

Transcript

2,572 words

Captions as YouTube publishes them, usually machine-generated, so names such as Daml and Canton can be misheard.

  1. 0:00

    it takes two to tango that saying means that sometimes it takes two parties to work together to get something done in the real world contracts are frequently multi-parties in this video we're gonna go through a simple scenario where two parties must work together to get one thing done and to get something meaningful in a contract stay tuned don't go anywhere hi this is steve sean from digital asset in previous videos we looked at very simple scenarios with one signatory in the template

  2. 0:42

    in the real world however typically we are dealing with more than one signatory in this video we're going to look at a pattern called the initiate and accept pattern in which one signatory will initiate a proposal and the other signatory will accept it thereby entering both of them into the contract as signatories let's get started all right here's my problem well it's not my problem but a problem that we can look at

  3. 1:13

    as kids grow up they get smarter well it's not a problem but they do get a little too smart there seem to be three phases for these kids the first phase is when they're too young and they're no chores for them but as they get older they can help around the house and you may pay them um a dollar or two or maybe maybe something else to help around the house then there's the third phase that

  4. 1:38

    some kids go into this is the very strange phase three where they tell you what they want to do and they would demand that they get paid by it and that's what my boy did he told me what he wants to do and how much he wants for it yeah right if you're not a parent allow me to enlighten you this is fortnite fortnite is a computer game you can play on the xbox and other devices and this is roblox

  5. 2:01

    another game that you can play on many devices fortnite has something called a v bucks and roblox have robux in both cases you need hardcore cash to buy these tokens so that you can go buy yourself a new suit or weapon or a new avatar they are very popular kids and they're new ones like among us every time i ask my kids they tell me i'm a sus and they wouldn't tell me how it works but whether i'm a sauce or not i think i can come up with a diplomatic

  6. 2:32

    win-win solution that will make everybody happy how about a smart contract app between me and ethan my boy that can formalize a contract for a paid chore so he can propose something and i can choose to accept it or not that sounds fair to me well before we proceed let's run it through a checklist first we need to ask ourselves if uh if we're tracking something of value yeah we're tracking something of value valuable to me to get a chore done and valuable to uh the child to get the

  7. 3:10

    points and the money is the data change that we are tracking yes as chores get done and measured i guess we can we can track that data change is the history important yes the history of what was done and what was negotiated has to be kept in the ledger and things should always be immutable so that there's no argument about what was agreed upon and the actions that we can take at the end of chore such as releasing the money

  8. 3:44

    let's take a look at the components of this architecture the first step would be the asset in this case the asset would be the v bucks or in our case cash that can be used to buy feedbacks the parties involved the people would be myself and the child that should be straightforward and then there's always the data that we need to worry about and in this case it's really a checklist of things that are completed and finally

  9. 4:12

    we have the business logic if we want to call this a business the logic would be for the work that's done correctly vbucks are awarded that should be straightforward now the architecture should be pretty clean we have the child and then we have the parent the child will have a couple of choices the first is to propose something or to revise something and at this point it's really just a proposal it's not a agreement at this point because the parent will get to reject or

  10. 4:49

    accept and there'll be negotiations in in this flow and if it's accepted it becomes a agreement it becomes a contract with both signatories authorizing it and uh and we'll test it in the navigator and run it in this demo sandbox let's build this let's fire up a terminal and what we are going to do is to create a new demo project using the empty skeleton template there is a skeleton template and an

  11. 5:27

    empty skeleton template we're going to do the empty skeleton and let's make sure we cd into the folder and then run demo studio to fire up vs code here we are in vs code and we're going to create a new demo file let's call it main dot demo oops wrong folder let me move it to the demo folder and in the demo.yaml file we're going to add a line here to make sure that we can use the demo script and that is set now for the parties i'm going to add

  12. 6:08

    my name and my son's name and that's all we need for now let's dive into the demo file so first line it's always module demo and then we're gonna in the second line we're gonna import the demo script and let's break this for a second we have the proposal and we have the contract so the proposal is what's going to be initiated and proposed and then when it's accepted it becomes a contract and so let me just create two types one for the proposal

  13. 6:44

    and one for the contract so remember that the workflow here is that the proposal will be made first will be initiated and then once it's accepted it becomes a contract so let's go ahead and wire up the template we're going to use two parties uh just to keep it simple the child and the parent and then a a chore that is being described or proposed and a note uh field just to pass messages back and forth the senatory at this case

  14. 7:17

    at this level will be the child and the child can do two things one is to make a proposal to the adult and two is to revise the proposal if it's rejected so for the proposed choice it's going to return a chore proposal contract and what's going to happen is we're going to simply create a contract and for re for the revision we're going to do a revised choice and we are just going to take a revision

  15. 7:55

    input and a feedback input as the the notes that you want to pass to the parent and what are we going to do there well we will um we will create the same contract and add it to the to the chain we will add a new description of the chore that we would like to do and then pass a note so that should be good so this is what the child can do and then there will be a section where the uh what the for what the parent can do so let's uh wire up the controller for

  16. 8:36

    that so the parent can do two things reject it send it back or accept it so if they reject it we're going to have a reject choice it it too will return a new contract proposal and with some feedback maybe the reason why it's rejected and when that happens the action it will take is that we'll create a new contract with the feedback now if they do accept it something else is different we are not going to return a proposal we are going to return a

  17. 9:15

    contract because past this point we are saying that we like what we are seeing so we are going to create a chore contract because we are good to go forward and the the parent in contract and the child in contract will be officially added in as the signatory both will authorize it so and we should be good with this uh but let's add in the chore because there may be a revision of the chore name of the description of the chore so let's just say um the chore name

  18. 9:59

    so we will be able to create a chore contract using those three inputs now for the next template we're gonna do a contract so this contract template will be used only when the child and the parent both agree to creating it together so we are going to take in three parameters oops not equal colon and the signatory will be both the parent and the child this is where the two signatories come in and uh that should be good and what we'll do is we'll write some script to

  19. 10:46

    test it we are going to have this script return a contract id not a proposal and we're going to first assign parties to play with so would be the parent and the child and then these are the following scenario that we'll take that ethan proposes to a chore and then steve the dad didn't like the terms so he rejects it and he gives the feedback if that's what we want to call it and he revised the child revises the terms

  20. 11:24

    gets more realistic about what he wants to do and for how much and the dad likes it and accepts it so let's assign a party and then the adult or the parent which is yours truly and ethan is really the name of my son by the way and so the first proposal let's do a submit let's submit this following we'll create a command it will be a proposal and it will take on the following it will have a child's name it will have

  21. 12:06

    a parent's name it will also have the chore that is uh that the child is proposing to do so maybe he wants to take out today's recycles for uh 5 000 v bucks and i think that's like 32 us dollars which is a lot and the the notes that he's adding to it is please i don't want to be default um god forbid he is a default so no default so he wants to have some v bucks to buy uh stuff to make him look good in the game uh so steve is gonna reject the proposal

  22. 12:46

    and he's gonna exercise the on he's gonna exercise on the ethan proposal one the reject choice and the feedback that the dad is gonna give is you're joking right try all month not very nice but we got to be realistic here um and so the child now has a choice to uh revise it and he does so we will have him uh do a proposal 2 as the revised proposal and the the choice that's going to be exercised is called the has to be done on that one that was

  23. 13:33

    rejected uh he's gonna exercise the revised choice on that and by providing a revision of the terms he says that now he's gonna take out the recycles for four times this month and he lowered his price to three thousand v bucks and the feedback he gave is a little sassy but uh he writes fine about this and the dad decides that he has had enough fun with him with the boy so he's gonna go

  24. 14:16

    ahead and accept it but who pays thirty dollars to take up the recycles super expensive all right so the dad is gonna go ahead and accept it and that's all we need to write oops sorry about that let's uh correct that and this automatically changes child events it should be child and everything clean and we are ready for the sandbox and navigator so let's go to the terminal and do a demo start inside of the chorus app folder

  25. 14:56

    it compiles to a dar file and launches the sandbox first let me just double check to the yaml file all looks good here and after the sandbox is up fantastic after the sandbox we should see the navigator perfect and now we have the navigator ui i will log in first as the boy and the boy sees the templates and clicks on the one that creates a proposal notice that the navigator doesn't know who is the parent

  26. 15:30

    who is the child that's why you see all the templates but he's gonna propose to take the recycles up tonight for 5000 v bucks uh exorbitant and added a note that he thinks will convince me and he submits it and the check tells me that it was added into the ledger fantastic double checking perfect so let's see what we see as the as the adult i see a contract waiting for me and i

  27. 16:00

    read the terms and i'm like 5000 reject why reject uh because uh i think he's joking right let's try uh let's counter it with uh let's try all month for three thousand now that goes to him uh if i take a look at my contract you see that i archived his proposal i sent and i sent one back to him fantastic now let's um log in as the boy he goes in and he sees that his archive his is archived and hey here's a counter from dad

  28. 16:42

    and he decides to be to play it smart and revise his terms and they said look i'll take them out three times well i think in the script it was four times for three thousand and he decides to add a note nice and friendly note to me and sends it back and that tells me that it has been logged yup and now the two archived and a active one this is the active one that was his proposal revised proposal and the dad sees it and the dad sees that he there are new terms

  29. 17:23

    being proposed likes it accepts it now if i go to my contract there's only one active contract which is the chora contracts all the proposals have been archived and they're two signatories perfect how about the boy the boy goes into his contract yup same case and the contract is active and the two signatories so this is now an active contract and now we see if he really performs the chores

  30. 17:56

    so i hope that clarified the initiate and accept design pattern now for more than two signatories we recommend using the multi-party agreement but we'll cover that in a future video i got more content lineup for you in the meantime i gotta get the kid to take out the recycles until next time bye you