Skip to content
CCPEDIAby Unity Nodes
VideosDaml 101: Parties Explained: Missing Authorization from Bob? [2022]

Daml 101: Parties Explained: Missing Authorization from Bob? [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

1,341 words

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

  1. 0:00

    yeah yeah i understand all right thank you alice okay bye-bye so i heard that bob has been giving you a hard time uh with creating a contract like you're missing an authorization from him huh we'll get it taken care of in this video we're going to cover parties in demo and their authority and role in your contract don't go anywhere we'll see how we can take care of the bob situation

  2. 0:39

    hi this is steve ceo from digital asset it's very common to run into the missing authorization from bob era now to understand these sort of errors we need to understand the rows of parties in demo specifically the signatory the controller the observers let's dive right in for parties we are really dealing with authorization and privacy authorization is who can do what and privacy is who can see what

  3. 1:08

    now the first type of party that we want to talk about is the signatory this is a party type obviously it's required and there can be more than one and if there's more than one the party listed are in an end relationship which means both have to agree and they authorize the creation and archival of contracts observers are simple they are party type as well but they are optional and they can see the contract or the

  4. 1:32

    transactions controller is an important party is required there can be more than one for sure and their job is to exercise choices now we are familiar with the use of parties like alice and bob if you have used a one of our templates when you do you're either dealing with the navigator or the script for navigator the parties are set in the demo.yaml file for the script it's set

  5. 1:59

    inside the script code at the bottom if you use one of our templates like this one the skeleton template which we're going to take a closer look at the skeleton template has a story in which uh alice is the issuer and the owner and she is going to create contract number zero if you will out of this template and gives herself the ownership of her own tv then she's going to exercise a choice called give and gives the tv to a new owner named bob

  6. 2:30

    now the tv is in bob's custody and bob will exercise that same choice give and gives it back to alice now notice that i've colored the two arrows green and two blues behind the scenes there are both create commands but they are executed in different contexts notice that the green ones require all the arguments required to create a contract while the blue ones really just require the data that is to be muted along the chain

  7. 3:02

    from one contract to another let's dive deeper into the code to see where the missing authorization from bob arrows can occur so we have our terminal up and i'm going to create a new demo project using the template of skeleton now that will give us a demo file to work with and the script is pre-written for us so it's a good starting point so let's cd into demo at bob bob problem i guess that's a good name and fire up demo studio

  8. 3:42

    vs code fires up let's maximize this and let's look at the main demo that has already pre-written for us in this template okay let's take a look at this we've got the data model oops let me go back back here we got a data model that's fantastic and we have a signatory which is the issuer and a controller which is the owner which means this person can do the following things it can give the item to a new owner

  9. 4:12

    um you will see that in the test script at the bottom here we are creating two parties and the first action that's going to happen yes it starts at line 28 and then line 34 and then 37 now uh what's happening is what we described alice gives itself the tv gives it to bob bob gives it back to her if we see uh we've checked on the archive we see that everything's clean and we have tx0 tx 1 and then tx2 now this is tx

  10. 4:46

    0 right here and that maps to this very first action here which is alice kicks off this chain of custody of the tv if you will now the second part here is maps to tx1 this is when alice gives the tv to bob and the final one is tx2 where bob gives tv back to alice fantastic notice that we are using all the create arguments for tx to create 0 and then subsequent ones are just the new owner now if i have to change that to bob you see there's a problem this is the first

  11. 5:33

    instance of when bob is not authorizing a contract or to to help us proceed here what's going on here so we see that um we have a a committed transaction which means that that got got logged into the ledger that went in so that is actually good there's nothing wrong with that it got committed but after that we do have a partial transaction so tx1 never occurred so it broke right

  12. 6:07

    there so we know that it failed here so let's take a closer look at why it may have failed so let's verify that we have the owner here is bob and then look at this alice is trying to do something but by then the tv is already bob's so alice cannot do anything and that's why bob's authorization was required now we change that to bob in line 36 and have bob submit it have bob take the action things will be okay now in this case bob is giving himself

  13. 6:46

    the tv and if i were to change this to alice and pass the baton to alice pass the ownership to alice we're gonna see the same problem right now we need an authorized issue from alice why because in line 39 of 40 um alice is the only person authorized to act on it because now she has custody of tv so switch that to alice give it back to bob and everybody will be happy i really don't understand why they're giving tvs back and forth

  14. 7:17

    but okay let's move on to another scenario where bob's authorization could be missing and that is when he is designated as a signatory right now we only have issuer if i would add owner which will be whoever the new owner is you see it breaks right again missing authorization from bob now if we look at the script output you will see that zero transaction was committed so it starts off with partial which means

  15. 7:48

    nothing passed everything failed right at the get go so that tells us that the problem exists at the very very first uh command that we are trying to run in the script so in this case you would use the initiate and accept design pattern to fix this so that we can have an authorization from the owner or we can probably just use just one signatory in this example so hope this video gave you a good idea

  16. 8:23

    of why we run into certain authorization errors for bob's case maybe he has no business authorizing the contract in the first place or he should be part of the signatories authorizing it and he's not and there's the last possibility that he is acting on a contract that has already been archived we've got more content see you next episode and if bob gives you more problems let me know i'm gonna call alice and let her know that everything is taken care of

  17. 9:04

    yeah what do you mean bob's missing i didn't do nothing yeah i talked to him if you can find him