{"id":"kpOXUJ_LJyU","title":"Lesson 6: Atomic Swap","description":"For a better learning experience, sign up and enroll in this free course at: https://daml.talentlms.com/plus/catalog/courses/151","channel_name":"Digital Asset Training","published_at":"2025-02-20T00:00:00.000Z","thumbnail_url":"https://i.ytimg.com/vi/kpOXUJ_LJyU/hqdefault.jpg","transcript_text":"building upon the previous lesson on utxo and transaction workflows this lesson delves into a powerful concept Atomic swapping in the utxo lesson you learned how to implement transaction workflows without divulging sensitive information of a party however one challenge remains ensuring that you don't end up in the situation where one party's asset like stock is transferred to the other but the other party's asset like cash isn't or vice versa Atomic swapping addresses this challenge head-on the term Atomic signifies that the exchange is indivisible it either happens entirely or not at all eliminating the risk of one party fulfilling their part while the other doesn't the concept of atomic swap is not specific to crypto blockchain or digital assets it is a highly desirable feature in any system that facilitates any kind of business transactions where assets are exchanged between parties let's revisit the business transaction between a buyer and a seller where the seller is selling 100 shares of Acne Ink to the buyer at a price of $120 per share again there are four parties involved the seller the buyer the depository and the bank the ownership of the stocks need needs to be transferred from the seller to the buyer through the Securities depository as $112,000 is transferred from the buyer to the seller via the bank in the system that facilitates this business transaction the state where the cash has been transferred and the stock ownership hasn't or vice versa should not be allowed therefore the exchange of cash and of the stock ownership change need to happen atomically in other words the transaction should always either succeed or fail in its entirety within this Atomic business transaction each party should be privy to only those details of the transaction that are essential for the party to know to be able to facilitate the transaction for the seller this means knowing that they have sold 100 shares of Acme Inc for $112,000 the buyer likewise should be aware of their purchase of 100 shares of Acme Inc for $112,000 both parties should not have access to any other personal or unrelated information about each other the bank's involvement should be limited to the transfer of cash the bank should only have access to information regarding the $122,000 transfer from the buyer to the seller any other details of the transaction should remain invisible to the bank similarly the depositor's role is to oversee the transfer of ownership of the 100 shares of Acme Incorporated the depository should only be privy to information related to this ownership transfer and nothing more this example demonstrates why in certain business workflows notably in delivery versus payment or DVP workflow it is essential that privacy is implemented at a subtransaction level without subtransaction privacy it's not possible to simultaneously satisfy both the requirement for Atomic settlement and the requirement for need to know visibility of the transaction details in DVP workflow let's see what this means in terms of authorization and privacy if Alice were to propose swapping her Euro for Bob's USD the transaction begins with Alice with her asset contract in Euro and Bob with his asset contract in USD before the swap the stakeholders of Alice's asset contract would be the signatories Alice and the EU Bank where Alice is the owner and EU bank is the issuer the stakeholders of Bob's USD would be the signatories Bob and the US Bank where Bob is the owner and the US Bank is the issuer at this point the stakeholders of each of the asset contracts cannot view one another's asset when Alice decides to swap her Euro for Bob's us Alice initiates swapping process by creating a swap proposal contract with Bob as the recipient the swap proposal contract includes all the necessary information regarding Alice's asset for Bob to decide whether to accept or reject the proposal the swap proposal is visible to the signatory of the contract Alice and the Observer Bob but it is not visible to either the EU bank or the US bank once Bob decides to accept the proposal he can exercise the swap proposal except choice on the proposal contract to offer his USD in exchange for Alice's Euro exercising the accept choice would result in the creation of two new asset contracts an asset contract in Euro with Bob as the owner and EU Bank as the issuer and and an asset contract in USD with Alice as the owner and US Bank as the issuer US Bank only gains visibility into the newly created asset contract in USD and EU Bank can only view the newly created asset in Euro since the two new asset contracts are created as a result of Bob exercising the except Choice Alice as the signatory of The Proposal contract Witnesses the creation of Bob's new asset and Bob as the required authorizer of the exercise action Witnesses the creation of Alice's new asset the transaction workflow that has been constructed so far does not Implement Atomic swapping this means there could be a scenario where Alice sends her Euro to Bob in exchange for his USD only to find that Bob refuses to reciprocate after receiving Alice's Euro or vice versa now let's proceed to incorporate Atomic swapping into the workflow first in the asset template The Observers field is added the Observer field will be a list of parties that will be assigned to be the Observer of the asset contract this field is necessary because if Alice were to propose swapping her €380 EO for some of Bob's USD atomically Bob should be able to view the asset contract that is currently owned by Alice to be able to decide whether to accept or reject the proposal the importance of the observer's field will become more clear later when the test script is run in case an asset contract has been created without an observer there's a newly added consuming Choice called asset set observers this Choice allows the owner to recreate an asset contract to have observers after it's been created without any observers in initially using this Choice owner can either add or remove observers on an asset contract in the asset transfer Choice the asset transfer proposal contract is still created with the asset payload but with its observer's field reset to be an empty list it is important to clear all the sensitive information such as the observer's field before the receiver acts on it this way when the receiver exercises either the accept or reject choice on the proposal they won't see what other parties were in The Observer list in case there were parties other than the receiver themselves finally swap proposal template is added swap proposal has four Fields initiator recipient offer CID and requested asset for instance Alice as an initiator can create a swap proposal contract with Bob as the recipient by providing all the relevant information such as offer C ID which is the contract ID of the asset that Alice would like to swap in and the requested asset which is an asset record that contains all the information regarding the asset that Alice would like to receive an exchange for the asset that she offers once Bob agrees to swap his USD with Alice's Euro he can exercise the swap proposal except choice on the proposal contract by passing in asset CID which is the contract ID of the asset that Bob would like to swap out in the body of the choice first the payload of the asset which Bob agrees to swap out is fetched by using its contract ID asset CID then the fetched asset is compared with the requested asset to confirm that the asset that Bob offers indeed matches with the asset that Alice has requested the three assert message Expressions confirm that the issuer amount and owner information of the two asset records match and will throw an error if any information does not match it is important to check if the owner of the requested asset matches with Bob's offered asset let's say that the last assert message expression is missing and Bob happens to know that Alice has an asset contract with matching issuer and amount information Bob can pass Alice's asset contract ID as asset CID pretending to offer his own asset contract this way Bob will be able to receive Alice's asset without offering any of his own asset to Alice in return the third assert message expression is added to prevent such a situation from happening if no errors are thrown with the authority of the sender Alice the asset transfer choice is exercised IED on Alice's offered asset to create an asset transfer proposal contract with Bob as the recipient this line of the code will throw an error if Bob has not yet been set as an observer of the asset that Alice swaps in that is because in daml the submitter of the transaction must have visibility of all contracts used in the transaction when Bob exercises the swap proposal accept Choice as the submitter of the transaction he must have visibility of all contracts used in the choice including Alice's asset therefore Bob needs to have been added to Alice's asset as an observer prior to the creation of this swap proposal contract as well as the exercise of this accept Choice then with the authority of the required authorizer Bob asset transfer choice is exercised on Bob's asset in USD with Alice the initiator as the recipient unlike Bob Alice does not need to have been set as an observer of Bob's asset ahead of time because she is not the submitter of the transaction since she is not the required authorizer of exercising the accept Choice therefore Alice does not need to see all contracts used in the transaction once asset transfer proposal contracts are created by both parties the accept choice is exercised on both proposals to settle the trade this test script extends the one from the previous lesson where Bob ends up with two asset contracts in USD $600 from US Bank and $400 from Alice with that being said the EU Bank represented as EB issues and creates an asset contract with €380 and no Observers EB offers the €380 to Alice by exercising the asset transfer choice on the asset contract Alice accepts the €380 from EB becoming the new owner of the asset then Alice exercises asset set Observer choice on the asset in Euro to recreate the contract with Bob as an observer on it finally Alice creates a swap proposal contract with Bob as the recipient Alice passes in the contract ID of her asset in Euro on which Bob is added as an observer for the requested asset field a new asset record is created with all the information of the asset that Alice requests of Bob Alice would like to receive an asset which is issued by the US Bank and 400 for the amount in other words Alice would like to swap her three 80 for Bob's 400 USD Bob accepts the proposal by exercising the swap proposal except choice and passing in his asset contract in 400 USD which he has previously received from the US Bank the table view shows that Bob is now in fact the owner of €380 and Alice is the owner of 400 USD confirming that the two Pary assets have been atomically swapped Alice and Bob are marked W on one another's asset contract because they witnessed the exercise action which resulted in the creation of those two asset contracts it is important to note that Bob became an observer of Alice's €380 Euro before Alice created the swap proposal let's see what happens if Bob didn't gain visibility into Alice's contract prior to accep her St proposal the new observers field for the asset set Observer choice is now empty which means Alice recreated her asset contract without adding any party as an observer prior to proposing to trade her asset with Bob the error says attempt to fetch or exercise a contract not visible to the reading parties it's pointing at the contract created at the action number 131 listing Bob as the acting party while there's no reading party It also says that the contract is only disclosed to Alice and EU Bank since the error message is pointing at number 131 let's take a look at the corresponding action in the transaction view in fact number 131 refers to the create action of Alice's asset in 380 but with an empty observers field under the failed exercise it says that exercising the swap proposal except Choice has failed this explains why the error message says that Bob's attempt to exercise the accept Choice failed because Bob was not able to view Alice's asset contract on which the asset transfer choice is exercised within the body of the swap proposal accept Choice due to this part of the action failing the entire transaction of Bob exercising the except Choice has failed neither Alice's nor Bob's asset is transferred to the other party confirming that the transaction has atomically failed without any partial commit of the exercise action in the atomic swap implementation because the settlement of the trade is submitted as a single transaction it is guaranteed to fully succeed or fully fail in the walkthr of the atomic swap implementation you learned about the imity of the transaction you also explored the Privacy aspect of the workflow finally let's discuss the authorization mechanics whose authority is needed for what action and how is this Authority obtained in the swap proposal accept Choice the required authorizer is the recipient and since it is a root action it is indeed authorized by the submitting party recipient the required authorizer of the fet F action is any stakeholder of the contract being fetched this means authorization of either the owner who is the initiator on this contract or the issuer of the asset is required since the fetch action is a consequence of the exercise action it is indeed authorized by The initiator Who is the signatory of The Proposal contract and the recipient who is the controller of the choice the required authoriz ier of exercising the asset transfer choice on the initiator's asset is the owner of the asset since again it is a consequence of the exercise action it is authorized by the initiator the owner of the asset since the party is the signatory of The Proposal contract and the recipient the controller of the choice by the same logic the required authorizer of exercising the asset transfer choice on the recipient asset is the recipient and it is authorized by the recipient and the initiator the required authorizer of exercising the accept choice on the offer transfer proposal contract is the recipient and the required authorizer for exercising the accept choice on the requested transfer proposal is the initiator again they are both consequences of exercising swap proposal except choice and they are both author ized by the initiator the signatory of The Proposal contract and the recipient the controller of the choice this lesson focused on the concept of atomic swapping the term Atomic signifies that the asset exchange between parties is indivisible eliminating potential settlement risks in delivery versus payment workflows it ensures that the exchange either happens entirely or not at all minimizing the risk of one party not fulfilling their part of the exchange in an atomic swap both parties Place their assets into a system that guarantees a fair and secure exchange the proposed accept pattern can be implemented where the initiator proposes swapping of assets upon the recipient accepting the swap proposal assets are transferred to the parties atomically so that if one of the assets fails to be transferred the entirety of the transaction fails it is important to note that in daml privacy is implemented at a subtransaction level without subtransaction privacy it's not possible to simultaneously satisfy both the requirement for Atomic settlement and the requirement for need to know visibility of the transaction details in the DVP workflow","transcript_synced_at":"2026-10-26T03:59:52.752Z","segments":[{"start_seconds":0,"text":"building upon the previous lesson on utxo and transaction workflows this lesson delves into a powerful concept","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=0s"},{"start_seconds":8,"text":"Atomic swapping in the utxo lesson you learned how to implement transaction workflows without divulging sensitive","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=8s"},{"start_seconds":16,"text":"information of a party however one challenge remains ensuring that you don't end up in the situation where one","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=16s"},{"start_seconds":24,"text":"party's asset like stock is transferred to the other but the other party's asset like cash isn't or vice versa Atomic","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=24s"},{"start_seconds":33,"text":"swapping addresses this challenge head-on the term Atomic signifies that the exchange is indivisible it either","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=33s"},{"start_seconds":42,"text":"happens entirely or not at all eliminating the risk of one party fulfilling their part while the other","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=42s"},{"start_seconds":49,"text":"doesn't the concept of atomic swap is not specific to crypto blockchain or digital","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=49s"},{"start_seconds":56,"text":"assets it is a highly desirable feature in any system that facilitates any kind of business transactions where assets","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=56s"},{"start_seconds":65,"text":"are exchanged between parties let's revisit the business transaction between a buyer and a seller","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=65s"},{"start_seconds":72,"text":"where the seller is selling 100 shares of Acne Ink to the buyer at a price of $120 per share again there are four","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=72s"},{"start_seconds":82,"text":"parties involved the seller the buyer the depository and the bank the ownership of the stocks need","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=82s"},{"start_seconds":89,"text":"needs to be transferred from the seller to the buyer through the Securities depository as $112,000 is transferred","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=89s"},{"start_seconds":98,"text":"from the buyer to the seller via the bank in the system that facilitates this business transaction the state where the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=98s"},{"start_seconds":106,"text":"cash has been transferred and the stock ownership hasn't or vice versa should not be allowed therefore the exchange of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=106s"},{"start_seconds":115,"text":"cash and of the stock ownership change need to happen atomically in other words the transaction should always either","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=115s"},{"start_seconds":123,"text":"succeed or fail in its entirety within this Atomic business transaction each party should be privy","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=123s"},{"start_seconds":131,"text":"to only those details of the transaction that are essential for the party to know to be able to facilitate the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=131s"},{"start_seconds":138,"text":"transaction for the seller this means knowing that they have sold 100 shares of Acme Inc for","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=138s"},{"start_seconds":146,"text":"$112,000 the buyer likewise should be aware of their purchase of 100 shares of Acme Inc for","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=146s"},{"start_seconds":154,"text":"$112,000 both parties should not have access to any other personal or unrelated information about each","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=154s"},{"start_seconds":162,"text":"other the bank's involvement should be limited to the transfer of cash the bank should only have access to information","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=162s"},{"start_seconds":170,"text":"regarding the $122,000 transfer from the buyer to the seller any other details of the transaction should remain invisible","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=170s"},{"start_seconds":178,"text":"to the bank similarly the depositor's role is to oversee the transfer of ownership of the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=178s"},{"start_seconds":186,"text":"100 shares of Acme Incorporated the depository should only be privy to information related to this","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=186s"},{"start_seconds":193,"text":"ownership transfer and nothing more this example demonstrates why in certain business workflows notably in","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=193s"},{"start_seconds":201,"text":"delivery versus payment or DVP workflow it is essential that privacy is implemented at a subtransaction level","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=201s"},{"start_seconds":211,"text":"without subtransaction privacy it's not possible to simultaneously satisfy both the requirement for Atomic settlement","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=211s"},{"start_seconds":218,"text":"and the requirement for need to know visibility of the transaction details in DVP workflow let's see what this means in","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=218s"},{"start_seconds":227,"text":"terms of authorization and privacy if Alice were to propose swapping her Euro for Bob's","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=227s"},{"start_seconds":234,"text":"USD the transaction begins with Alice with her asset contract in Euro and Bob with his asset contract in USD before","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=234s"},{"start_seconds":243,"text":"the swap the stakeholders of Alice's asset contract would be the signatories Alice and the EU Bank where Alice is the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=243s"},{"start_seconds":251,"text":"owner and EU bank is the issuer the stakeholders of Bob's USD would be the signatories Bob and the US Bank where","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=251s"},{"start_seconds":260,"text":"Bob is the owner and the US Bank is the issuer at this point the stakeholders of each of the asset contracts cannot view","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=260s"},{"start_seconds":268,"text":"one another's asset when Alice decides to swap her Euro for Bob's us Alice initiates","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=268s"},{"start_seconds":276,"text":"swapping process by creating a swap proposal contract with Bob as the recipient the swap proposal contract","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=276s"},{"start_seconds":285,"text":"includes all the necessary information regarding Alice's asset for Bob to decide whether to accept or reject the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=285s"},{"start_seconds":292,"text":"proposal the swap proposal is visible to the signatory of the contract Alice and the Observer Bob but it is not visible","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=292s"},{"start_seconds":301,"text":"to either the EU bank or the US bank once Bob decides to accept the proposal he can exercise the swap","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=301s"},{"start_seconds":309,"text":"proposal except choice on the proposal contract to offer his USD in exchange for Alice's","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=309s"},{"start_seconds":316,"text":"Euro exercising the accept choice would result in the creation of two new asset contracts an asset contract in Euro with","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=316s"},{"start_seconds":325,"text":"Bob as the owner and EU Bank as the issuer and and an asset contract in USD with Alice as the owner and US Bank as","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=325s"},{"start_seconds":334,"text":"the issuer US Bank only gains visibility into the newly created asset contract in","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=334s"},{"start_seconds":340,"text":"USD and EU Bank can only view the newly created asset in Euro since the two new","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=340s"},{"start_seconds":348,"text":"asset contracts are created as a result of Bob exercising the except Choice Alice as the signatory of The Proposal","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=348s"},{"start_seconds":355,"text":"contract Witnesses the creation of Bob's new asset and Bob as the required authorizer of the exercise action","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=355s"},{"start_seconds":364,"text":"Witnesses the creation of Alice's new asset the transaction workflow that has been constructed so far does not","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=364s"},{"start_seconds":372,"text":"Implement Atomic swapping this means there could be a scenario where Alice sends her Euro to Bob in exchange for","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=372s"},{"start_seconds":380,"text":"his USD only to find that Bob refuses to reciprocate after receiving Alice's Euro or vice versa now let's proceed to","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=380s"},{"start_seconds":389,"text":"incorporate Atomic swapping into the workflow first in the asset template The Observers field is added the Observer","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=389s"},{"start_seconds":399,"text":"field will be a list of parties that will be assigned to be the Observer of the asset contract this field is necessary because","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=399s"},{"start_seconds":408,"text":"if Alice were to propose swapping her €380 EO for some of Bob's USD atomically Bob should be able to view the asset","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=408s"},{"start_seconds":417,"text":"contract that is currently owned by Alice to be able to decide whether to accept or reject the proposal the importance of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=417s"},{"start_seconds":425,"text":"the observer's field will become more clear later when the test script is run in case an asset contract has been","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=425s"},{"start_seconds":433,"text":"created without an observer there's a newly added consuming Choice called asset set observers this Choice allows the owner","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=433s"},{"start_seconds":442,"text":"to recreate an asset contract to have observers after it's been created without any observers in initially using","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=442s"},{"start_seconds":451,"text":"this Choice owner can either add or remove observers on an asset contract in the asset transfer Choice","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=451s"},{"start_seconds":459,"text":"the asset transfer proposal contract is still created with the asset payload but with its observer's field reset to be an","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=459s"},{"start_seconds":466,"text":"empty list it is important to clear all the sensitive information such as the observer's field before the receiver","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=466s"},{"start_seconds":474,"text":"acts on it this way when the receiver exercises either the accept or reject choice on","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=474s"},{"start_seconds":481,"text":"the proposal they won't see what other parties were in The Observer list in case there were parties other than the receiver","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=481s"},{"start_seconds":489,"text":"themselves finally swap proposal template is added swap proposal has four Fields","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=489s"},{"start_seconds":497,"text":"initiator recipient offer CID and requested asset for instance Alice as an initiator can create a swap proposal","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=497s"},{"start_seconds":506,"text":"contract with Bob as the recipient by providing all the relevant information such as offer C ID which is the contract","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=506s"},{"start_seconds":515,"text":"ID of the asset that Alice would like to swap in and the requested asset which is an asset record that contains all the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=515s"},{"start_seconds":522,"text":"information regarding the asset that Alice would like to receive an exchange for the asset that she","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=522s"},{"start_seconds":529,"text":"offers once Bob agrees to swap his USD with Alice's Euro he can exercise the swap proposal except choice on the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=529s"},{"start_seconds":537,"text":"proposal contract by passing in asset CID which is the contract ID of the asset that Bob would like to swap","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=537s"},{"start_seconds":546,"text":"out in the body of the choice first the payload of the asset which Bob agrees to swap out is fetched by using its","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=546s"},{"start_seconds":554,"text":"contract ID asset CID then the fetched asset is compared with the requested asset to confirm that","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=554s"},{"start_seconds":562,"text":"the asset that Bob offers indeed matches with the asset that Alice has requested the three assert message Expressions","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=562s"},{"start_seconds":570,"text":"confirm that the issuer amount and owner information of the two asset records match and will throw an error if any","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=570s"},{"start_seconds":578,"text":"information does not match it is important to check if the owner of the requested asset matches","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=578s"},{"start_seconds":585,"text":"with Bob's offered asset let's say that the last assert message expression is missing and Bob happens to know that","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=585s"},{"start_seconds":593,"text":"Alice has an asset contract with matching issuer and amount information Bob can pass Alice's asset","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=593s"},{"start_seconds":601,"text":"contract ID as asset CID pretending to offer his own asset contract this way","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=601s"},{"start_seconds":608,"text":"Bob will be able to receive Alice's asset without offering any of his own asset to Alice in return the third","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=608s"},{"start_seconds":616,"text":"assert message expression is added to prevent such a situation from happening if no errors are thrown with","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=616s"},{"start_seconds":624,"text":"the authority of the sender Alice the asset transfer choice is exercised IED on Alice's offered asset to create an","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=624s"},{"start_seconds":632,"text":"asset transfer proposal contract with Bob as the recipient this line of the code will throw an error if Bob has not yet been","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=632s"},{"start_seconds":641,"text":"set as an observer of the asset that Alice swaps in that is because in daml the submitter","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=641s"},{"start_seconds":648,"text":"of the transaction must have visibility of all contracts used in the transaction when Bob exercises the swap","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=648s"},{"start_seconds":656,"text":"proposal accept Choice as the submitter of the transaction he must have visibility of all contracts used in the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=656s"},{"start_seconds":664,"text":"choice including Alice's asset therefore Bob needs to have been added to Alice's asset as an observer","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=664s"},{"start_seconds":672,"text":"prior to the creation of this swap proposal contract as well as the exercise of this accept","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=672s"},{"start_seconds":679,"text":"Choice then with the authority of the required authorizer Bob asset transfer choice is exercised on Bob's asset in","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=679s"},{"start_seconds":688,"text":"USD with Alice the initiator as the recipient unlike Bob Alice does not need","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=688s"},{"start_seconds":695,"text":"to have been set as an observer of Bob's asset ahead of time because she is not the submitter of the transaction since","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=695s"},{"start_seconds":703,"text":"she is not the required authorizer of exercising the accept Choice therefore Alice does not need to see all contracts","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=703s"},{"start_seconds":711,"text":"used in the transaction once asset transfer proposal contracts are created by both parties","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=711s"},{"start_seconds":719,"text":"the accept choice is exercised on both proposals to settle the trade this test script extends the one","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=719s"},{"start_seconds":727,"text":"from the previous lesson where Bob ends up with two asset contracts in USD $600","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=727s"},{"start_seconds":733,"text":"from US Bank and $400 from Alice with that being said the EU Bank","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=733s"},{"start_seconds":740,"text":"represented as EB issues and creates an asset contract with €380 and no Observers","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=740s"},{"start_seconds":749,"text":"EB offers the €380 to Alice by exercising the asset transfer choice on the asset","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=749s"},{"start_seconds":757,"text":"contract Alice accepts the €380 from EB becoming the new owner of the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=757s"},{"start_seconds":765,"text":"asset then Alice exercises asset set Observer choice on the asset in Euro to recreate the contract with Bob as an","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=765s"},{"start_seconds":773,"text":"observer on it finally Alice creates a swap proposal contract with Bob as the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=773s"},{"start_seconds":781,"text":"recipient Alice passes in the contract ID of her asset in Euro on which Bob is added as an","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=781s"},{"start_seconds":789,"text":"observer for the requested asset field a new asset record is created with all the information of the asset that Alice","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=789s"},{"start_seconds":797,"text":"requests of Bob Alice would like to receive an asset which is issued by the US Bank and 400 for the amount in other","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=797s"},{"start_seconds":806,"text":"words Alice would like to swap her three 80 for Bob's 400 USD Bob accepts the proposal by","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=806s"},{"start_seconds":815,"text":"exercising the swap proposal except choice and passing in his asset contract in 400 USD which he has previously","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=815s"},{"start_seconds":823,"text":"received from the US Bank the table view shows that Bob is now in fact the owner of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=823s"},{"start_seconds":831,"text":"€380 and Alice is the owner of 400 USD confirming that the two Pary assets have been atomically","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=831s"},{"start_seconds":840,"text":"swapped Alice and Bob are marked W on one another's asset contract because they witnessed the exercise action which","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=840s"},{"start_seconds":849,"text":"resulted in the creation of those two asset contracts it is important to note that","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=849s"},{"start_seconds":855,"text":"Bob became an observer of Alice's €380 Euro before Alice created the swap","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=855s"},{"start_seconds":862,"text":"proposal let's see what happens if Bob didn't gain visibility into Alice's contract prior to accep her St","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=862s"},{"start_seconds":870,"text":"proposal the new observers field for the asset set Observer choice is now empty which means Alice recreated her asset","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=870s"},{"start_seconds":878,"text":"contract without adding any party as an observer prior to proposing to trade her asset with","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=878s"},{"start_seconds":885,"text":"Bob the error says attempt to fetch or exercise a contract not visible to the reading parties it's pointing at the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=885s"},{"start_seconds":893,"text":"contract created at the action number 131 listing Bob as the acting party while there's no reading party It also","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=893s"},{"start_seconds":902,"text":"says that the contract is only disclosed to Alice and EU Bank since the error message is pointing","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=902s"},{"start_seconds":909,"text":"at number 131 let's take a look at the corresponding action in the transaction view in fact number 131 refers to the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=909s"},{"start_seconds":919,"text":"create action of Alice's asset in 380 but with an empty observers","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=919s"},{"start_seconds":926,"text":"field under the failed exercise it says that exercising the swap proposal except Choice has","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=926s"},{"start_seconds":934,"text":"failed this explains why the error message says that Bob's attempt to exercise the accept Choice failed","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=934s"},{"start_seconds":941,"text":"because Bob was not able to view Alice's asset contract on which the asset transfer choice is exercised within the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=941s"},{"start_seconds":948,"text":"body of the swap proposal accept Choice due to this part of the action failing the entire transaction of Bob","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=948s"},{"start_seconds":957,"text":"exercising the except Choice has failed neither Alice's nor Bob's asset is transferred to the other party","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=957s"},{"start_seconds":965,"text":"confirming that the transaction has atomically failed without any partial commit of the exercise action in the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=965s"},{"start_seconds":972,"text":"atomic swap implementation because the settlement of the trade is submitted as a single transaction it is guaranteed to","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=972s"},{"start_seconds":980,"text":"fully succeed or fully fail in the walkthr of the atomic swap implementation you learned about the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=980s"},{"start_seconds":988,"text":"imity of the transaction you also explored the Privacy aspect of the workflow finally let's discuss the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=988s"},{"start_seconds":996,"text":"authorization mechanics whose authority is needed for what action and how is this Authority","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=996s"},{"start_seconds":1003,"text":"obtained in the swap proposal accept Choice the required authorizer is the recipient and since it is a root action","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1003s"},{"start_seconds":1011,"text":"it is indeed authorized by the submitting party recipient the required authorizer of the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1011s"},{"start_seconds":1018,"text":"fet F action is any stakeholder of the contract being fetched this means authorization of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1018s"},{"start_seconds":1025,"text":"either the owner who is the initiator on this contract or the issuer of the asset is required since the fetch action is a","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1025s"},{"start_seconds":1034,"text":"consequence of the exercise action it is indeed authorized by The initiator Who is the signatory of The Proposal","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1034s"},{"start_seconds":1041,"text":"contract and the recipient who is the controller of the choice the required authoriz ier of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1041s"},{"start_seconds":1049,"text":"exercising the asset transfer choice on the initiator's asset is the owner of the asset since again it is a consequence of","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1049s"},{"start_seconds":1058,"text":"the exercise action it is authorized by the initiator the owner of the asset since the party is the signatory of The","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1058s"},{"start_seconds":1066,"text":"Proposal contract and the recipient the controller of the choice by the same logic the required","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1066s"},{"start_seconds":1074,"text":"authorizer of exercising the asset transfer choice on the recipient asset is the recipient and it is authorized by","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1074s"},{"start_seconds":1081,"text":"the recipient and the initiator the required authorizer of exercising the accept choice on the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1081s"},{"start_seconds":1089,"text":"offer transfer proposal contract is the recipient and the required authorizer for exercising the accept choice on the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1089s"},{"start_seconds":1098,"text":"requested transfer proposal is the initiator again they are both consequences of exercising swap proposal","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1098s"},{"start_seconds":1106,"text":"except choice and they are both author ized by the initiator the signatory of The Proposal contract and the recipient","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1106s"},{"start_seconds":1113,"text":"the controller of the choice this lesson focused on the concept of atomic swapping the term","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1113s"},{"start_seconds":1121,"text":"Atomic signifies that the asset exchange between parties is indivisible eliminating potential settlement risks","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1121s"},{"start_seconds":1128,"text":"in delivery versus payment workflows it ensures that the exchange either happens entirely or not at all minimizing the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1128s"},{"start_seconds":1137,"text":"risk of one party not fulfilling their part of the exchange in an atomic swap both parties","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1137s"},{"start_seconds":1144,"text":"Place their assets into a system that guarantees a fair and secure exchange the proposed accept pattern can be","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1144s"},{"start_seconds":1152,"text":"implemented where the initiator proposes swapping of assets upon the recipient accepting the swap proposal assets are","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1152s"},{"start_seconds":1159,"text":"transferred to the parties atomically so that if one of the assets fails to be transferred the entirety of the","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1159s"},{"start_seconds":1167,"text":"transaction fails it is important to note that in daml privacy is implemented at a subtransaction","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1167s"},{"start_seconds":1175,"text":"level without subtransaction privacy it's not possible to simultaneously satisfy both the requirement for Atomic","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1175s"},{"start_seconds":1183,"text":"settlement and the requirement for need to know visibility of the transaction details in the DVP","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1183s"},{"start_seconds":1197,"text":"workflow","url":"https://www.youtube.com/watch?v=kpOXUJ_LJyU&t=1197s"}],"youtube_url":"https://youtube.com/watch?v=kpOXUJ_LJyU","url":"https://ccpedia.xyz/videos/kpOXUJ_LJyU"}