Skip to content
CCPEDIAby Unity Nodes
VideosLesson 1: Authorization

Lesson 1: Authorization

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

About this video

For a better learning experience, sign up and enroll in this free course at: daml.talentlms.com/plus/catalog/courses/151

Transcript

1,593 words

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

  1. 0:00

    this lesson focuses on the authorization rules to help reason through your contract models by understanding Dam's authorization rules you will be able to construct your contracts in a way that avoids authorization errors during runtime and more importantly prevents the execution of malicious transactions you learned that a transaction is a list of Ledger actions and an exercise action exercises a

  2. 0:31

    choice on a contract resulting in a list of subactions called the consequences each action has a set of required authorizers the parties that must authorize that action the required authorizers of an exercise action are the controllers on the corresponding Choice remember that the built-in archive is just a Shand for exercising the implicit archive Choice with the signatories as controllers the required authorizers of a create action are the

  3. 1:03

    signatories of the contract the required authorizers of a fetch action which also includes the fetch by key statement are any one of the stakeholders of the contract being fetched the required authorizers of lookup I key are all the key maintainers for the key you are attempting to look up and each action has a set of authorizers the parties that did authorize the action the root action or actions are authorized by all of the

  4. 1:33

    submitting parties every transaction starts with a command or a list of commands sent to The Ledger from a client application these commands are authorized by the submitting party whose credentials are included with the submit the consequences of an exercise action which are the actions listed in a body of a choice do not automatically inherit the authorization of the submitter the con consequences of an exercise action are authorized by the controllers of the

  5. 2:04

    choice plus the signatories of the contract on which the action was taken now let's see what that means in a transaction tree here is a transaction tree with its list of Ledger actions the transaction tree was generated when the party Bob exercised a send iio you choice on a payment Channel contract this Ledger action has two consequen quences Fetch and exercise among those two the exercise action has a consequence of creating a

  6. 2:37

    new IOU contract let's take a look at the number 42 as an example the required authorizers of exercising Mutual transfer are the controllers of the choice Bob and Charlie with this in mind let's check out the code that generated this transaction tree there are two templates I OU and payment Channel Once an IOU contract is created by an issuer and a sending party a receiving party can create a payment

  7. 3:09

    Channel contract to allow the sender to send the IOU to the receiving party the sender can exercise a send IOU Choice by passing a contract ID of an IOU contract as an input within the body of the send IOU Choice the mutual transfer choice is is exercised on the input reassigning the receiving party to be the new owner the mutual transfer Choice creates a new IOU contract with the new owner as the

  8. 3:43

    owner send IU choice is a non-consuming choice allowing the sending party to send IUS to a receiver multiple times let's take a look at the test script parties Alice Bob and Charlie are allocated Alice creates a new IOU contract setting herself as both issuer and owner Bob creates a payment Channel contract to allow Alice to send him IUS Charlie also creates a payment Channel contract to allow Bob to send him IUS finally Alice sends her IOU to Bob

  9. 4:27

    and Bob sends it to Charlie now let's analyze the last submit expression where Bob sends the IOU to Charlie in terms of the authorization rule let's revisit the transaction tree from the script where Bob sends an IOU to Charlie using a send IOU contract Bob submits the transaction so he is the authorizer on the root action which is to exercise and I owe you on a payment Channel contract with Bob as sender and Charlie as receiver

  10. 5:01

    since the controller of that choice is the sender Bob is the required authorizer at number 41 and number 42 the consequences of the send I OU action are authorized by its controller Bob as well as signatories of the payment Channel contract on which the send IO you Choice was exercised that's Charlie in this case so the two consequences are authorized by both Bob and Charlie ignore the fetch action for now and

  11. 5:34

    focus on number 42 which shows the exercise action Bob and Charlie exercise Mutual transfer with Charlie as new owner on the IOU contract which has Alice as the issuer and Bob as the current owner the required authorizers of exercising Mutual transfer are the owner Bob and the new owner Charlie finally number 43 shows that the consequences of exercising Mutual transfer are authorized by the

  12. 6:07

    controllers Bob and Charlie as well as the signatories of the IOU contract Alice and Bob there's a single action on the consequences which is the create action the creation of an IOU with issuer Alice and owner Charlie has the required authorizers Alice and Charlie finally let's delve into the topic of how a party's Authority is not transferred transitively which will enhance your understanding of the

  13. 6:40

    missing authorization error here is a simple template non-transitive which takes Sig and obes the signatory is Sig and the Observer is OBS Sig can exercise swap Sig and's Choice which is a consuming choice that creates a new non-transitive contract by switching Sig and OBS OBS can exercise exercise swap another which takes another non-transitive contract as an argument to exercise swaps aand dubs on it let's try exercising swapan

  14. 7:16

    dobs the parties Alice and Bob are allocated and Alice creates a non-transitive contract with Alice as Sig and Bob as OBS Alice exercises swaps of on the contract and runs into a missing authorization error which says that Bob's authorization is missing let's walk through the transaction tree to analyze why this happened under the committed transactions the root action number 00

  15. 7:46

    for creating a new non-transitive contract is authorized by the submitting party Alice the failed exercise indicates that exercising the swaps ub's choice on the contract created from the root action number 00 failed under the subtransaction at number zero Alice the controller is the required authorizer of exercising the swap a gindo's choice on the non-transitive contract since it is the root action it is authorized by the

  16. 8:20

    submitter Alice and the consequence of exercising swaps ovs is the create action at number one based B on the authorization rule the consequence is authorized by the controller of the choice and the signatory of the contract that the choice is exercised on in this case the controller of the swapan do's choice is Alice and the signatory of the non-transitive contract that swapan Do's choice is exercised on is also

  17. 8:52

    Alice however number one indicates that Bob is the required authorizer of the create action Bob should have been one of the parties that authorized the consequences of exercising swaps aand dos but they were only authorized by Alice this explains the error message on the top where it says number one create of non-transitive failed due to a missing authorization from Bob let's try exercising exercise swap another have

  18. 9:24

    Alice create another non-transitive contract nt2 again Alice is Sig and Bob is OBS just like N1 at the end of the test script have Bob exercise exercise swap another choice on N1 by passing in N2 as the argument of the choice under the committed transactions the create actions number 00 0 and number one0 are both authorized by the submitting party Alice the action number 00 repres

  19. 9:59

    represents the creation of N1 and number one Z represents the creation of nt2 the failed exercise indicates that exercising swaps ub's choice on the nt2 contract created from the root action number one Z failed under the subtransaction at number0 Bob is the required authorizer of exercising exercise swap another since it is the root action it is authorized by the submitting party Bob the consequences of exercising exercise swap another are authorized by the

  20. 10:39

    controller of the choice Bob and the signatory of the contract that exercise swap another is exercised on which is Alice at number one in fact the required authorizer of exercising swaps aobs is Alice and the consequence of this action is author authorized by the controller of the the choice swaps a gands which is Alice and the signatory of the contract that the choice is exercised on which again is

  21. 11:10

    Alice however number two indicates that the required authorizer of the create action is Bob this explains the error message on the top where it says to create of non-transitive failed due to a missing authorization from Bob this example illust rates that authorization in daml does not propagate down the transaction tree in the last submit expression even though the root action of exercising exercise swap another is authorized by Bob Bob's authorization is

  22. 11:43

    missing for the last create action a transaction is a list of Ledger actions and an exercise action may result in a list of subactions called the consequences each action has a set of requir ired authorizers the parties that must authorize that action and a set of authorizers the parties that did authorize the action remember that A party's Authority is not transferred down the transaction tree to avoid missing authorization

  23. 12:27

    errors