scala
scala

Reputation: 545

Transaction between 3 participants with Corda

Do you have any example how to execute multiple transactions between participants A, B, C. I can do it ease between 2 parties A and B. Have fount the same discussion on the official Corda forum without result Sharing transaction among multiple nodes Is it possible? Do you have any example?

Upvotes: 0

Views: 573

Answers (2)

Raymond Mogg
Raymond Mogg

Reputation: 192

If you are issuing a new state, you can simply alter the participants of this state to ensure all parties receive the new state. Here is an example I have created with KYC data. This is example is updating a state (not issuing a new state), but the same principle applies - simply alter the participants list to control who will see that state. The KYC State is as follows:

@CordaSerializable
data class State(val firstName: String, val lastName: String, val accountNum: String, val owner: AbstractParty,
                 override val linearId: UniqueIdentifier = UniqueIdentifier(), val banksInvolved: List<AbstractParty> = emptyList()) : QueryableState, ContractState, LinearState {

    //Each time a TD is issued with this KYC data, the bank it is issued to is added to this banks involved list, meaning the data is now stored in that banks vault
    override val participants: List<AbstractParty> get() = banksInvolved.plus(owner)

This participants variable is the list of all nodes that will store this state in their vault (i.e will be notified about the states creation, update, etc). This is where you would add new nodes too for them to be able to view the state in their vault.

Then within a flow, to notify a new bank that they have received KYC data, we simply add the state as output with a new bank added to the banksInvolved list. This will make this new bank a participant with this state:

 builder.addOutputState(KYCData.first().state.copy(data = KYCData.first().state.data.copy(
                banksInvolved = KYCData.first().state.data.banksInvolved.plus(issuingInstitue)))) //Same state but with a new bank involved - i.e able to view this KYC data

Upvotes: 2

kety
kety

Reputation: 95

check your state, there you can mention the List of participants for transaction.

Upvotes: 0

Related Questions