Reputation: 425
I'm fairly new to DLT technologies and dove a bit in Corda. I'm not sure to understand everything well yet so here is my question that i tried to answer myself (using NotaryChangeFlow). Please correct me.
Problem setup :
I'm node A. I share facts with node B and node C. They don't share any fact. For node B, we have notary B tracking our transactions. For node C, we have notary C tracking our transactions.
Problem :
If B sends me let's say 5€. How can I use those 5€ to send it to C
My solution:
A and B creates a transaction updating both states + updating notary B state. A changes notary B to notary C. A consumes his state shared with B and sends money to the facts he shared with C using notary C as validator. A sends money to C.
That way : B knows A used 5€ and C knows 5€ has been added to A balance and is then transfered to him.
Is this the right way?
Thanks!
Upvotes: 0
Views: 55
Reputation: 1831
Yes, you are correct. Let me just reiterate to make it a little more clear. States in Corda are associated with a particular notary and can only be spent with that specific notary. If there is a need to spend a state at a different notary, a Notary Change Transaction is performed first. In a Notary Change Transaction, the state in question is spent at the current notary and reissued with the new notary.
All of this is done to ensure Notaries are able to do their job of preventing double-spending attempts in the network. Any notary other than the one where a state is being transacted would not have any information regarding the previous transaction of a state and would not be able to able to prevent double-spending attempts without that information.
So now in your case, B wants to send the $5 to A using notary N1 and now A wants to send the same $5 to C using notary N2. This will be a two-step process:
NotaryChangeFlow
.On the statement B know $5 has been used by A
, you need to either add A as a participant/ observer for him to be notified of any updates. Generally, this is not a requirement for cash since once I have to send the money to another party, I am not supposed to know what he does with it. But if that's a requirement for some use case the cordapp needs to be designed accordingly.
Upvotes: 1