mahendran manickam
mahendran manickam

Reputation: 74

R3 Corda sharing transaction with multiple participants

How to share the transaction between multiple participants in the network? say for an example A,B,C and D. where we want to share the transaction to all participants where A and D don't have option to edit the transaction further.

Upvotes: 0

Views: 1253

Answers (1)

Roger Willis
Roger Willis

Reputation: 922

There's two things you can do:

  1. You can write the state object such that A, B, C and D are all listed as participants. However, the contract code for this state object should be written such that it only allows B and C to update the state object. An example might be a bilateral agreement between B and C but A and D are also listed as participants because they are regulators that should be see the whole transaction. If you go down this approach, it is important that the transactions are constructed such that only the public keys for A and D are listed in the commands and you hard code A and D in some other fields in the state so you can perform validation inside the contracts sandbox.

Example:

data class Example(
    val A: AbstractParty,
    val D: AbstractParty,
    override val participants: List<AbstractParty>,
    override val linearId: UniqueIdentifier = UniqueIdentifier()
) : LinearState {
    constructor (
        A: AbstractParty, 
        B: AbstractParty, 
        C: AbstractParty, 
        D: AbstractParty
    ) : this(A, D, listOf(A, B, C ,D))
}
  1. You can use the new observable states feature in Corda V2, which allows an arbitrary number of nodes to observe the output states from a transaction. See an example here: https://github.com/roger3cev/observable-states. In this example, I create a crowd funding campaign, where only the campaign manager is the participant. However, the transaction is broadcast to all other parties on the same business network (so they can see the campaigns).

Option two is probably the better option. Cheers!

Upvotes: 1

Related Questions