1

I am having two contracts, custodian and trader. I am using custodian as a member of trader contract. contract trader { . . custodian public custodianUser; . . }

I am deploying custodian on separate node. When I try to set custodian by calling a function setCustodian of trader, I am not able to see custodian getting associated for trader. Code works fine in remix and also on my ubuntu instance if I dont use privateFor while deploying contract. Can any one help me to use privateFor wisely. The script used was as follows:

loadScript("trader.js");
var traderbin = output.contracts["trading2.sol:trader"].bin
var traderContract = 
web3.eth.contract(JSON.parse(output.contracts["trading2.sol:trader"].abi));
var trader = traderContract.new(
   {
     from: web3.eth.accounts[0],
     data: '0x' + traderbin,
     gas: '4700000',
     privateFor: [<key1>,<key2>,<key3>]
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' 
transactionHash: ' + contract.transactionHash);
    }
 });

    var custodianBin = output.contracts["trading2.sol:custodian"].bin
    var custodian = web3.eth.contract(JSON.parse(output.contracts["trading2.sol:custodian"].abi));
var custodianContract = custodian.new(
   {
     from: web3.eth.accounts[0],
     data: '0x' + custodianBin,
     gas: '4700000',
     privateFor: [<key4>,<key5>]
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' 
transactionHash: ' + contract.transactionHash);
    }
 });

I am having 3 Different contracts deployed as follows: Trader1 > Custodian1 > CustodianMain > Custodian2 > Trader2

If I make changes in Trader2, changes should pass upwards until Trader1

In order to make it happen, do I need to add privateFor for all nodes? If I add all node public keys in privateFor, then is there any advantage of using quorum in this scenario?

1 Answer 1

1

I think you may need to have all of the participants in both of the contracts when you are just setting up, and then use only the privateFor of actual members when sending txns to it.

Added 8/27/18:

Its a bit unclear in terms of what you need to pass up, but there are 2 suggestions I have for you: 1. Join our slack and ask in the dev channel since we do have others who looked into contracts such as this. 2. Look into 5NodeRTGS here: https://github.com/bacen/quorum-examples/tree/master/examples/5nodesRTGS for inspiration. Its not quiet the same idea, but it may answer some of the questions you are struggling with.

2
  • That means that you need key 4 and key 5 in the trader contract
    – fixanoid
    Commented Aug 23, 2018 at 13:56
  • I have updated question. Please check
    – digya
    Commented Aug 24, 2018 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.