I am pretty new to quorum/tessera and am trying to set up a small POC with 3 nodes. I followed the 7nodes setup example and similarly deployed 3 nodes on my system using Mysql as the database for tessera. What I want to do is:
Deploy a smart contract(privately) for the 3 nodes and do a private transaction between 2 nodes only (which change a state variable). Now, I understand that quorum maintains a public as well as a private state trie. How can I access the change created by the private transaction between these 2 nodes?
My smart contract is:
pragma solidity >=0.4.22 <0.7.0;
contract SampleContract {
uint256 num1;
uint256 num2;
function store1(uint256 number) public {
num1 = number;
}
function store2(uint256 number) public {
num2 = number;
}
function getVal1() public view returns(uint256){
return num1;
}
function getVal2() public view returns (uint256){
return num2;
}
}
DeploySampleContract.js
var abi = [abi-here];
var bytecode = "bytecode-here";
var simpleContract = web3.eth.contract(abi);
var simple = simpleContract.new({from:web3.eth.accounts[0], data: bytecode, gas: '4700000', privateFor: ["pub-key-of-node2","pub-key-of-node3"]}, function(e, contract) {
if (e) {
console.log("err creating contract", e);
} else {
if (!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
}
});
I use the following command to deploy:
geth --exec 'loadScript("DeploySampleContract.js")' attach http://localhost:22000
My query/send file:
var abi = [abi-here];
var private = eth.contract(abi).at("contract-address-here");
// console.log(private.store1.sendTransaction(27,{from: eth.coinbase}));
// console.log(private.store1.sendTransaction(28,{from: eth.coinbase, privateFor: ["pub-key-node2"]}));
console.log(private.getVal1.call());
I have run the above for both types of sendTransaction (and the transaction is successful, commented them out afterwards) but the value of num1 returned by getVal1()
is still 0. What is the method to access both the transactions' data/state?
Thanks.
private.getVal1.call()
).//
before it, so it's not being executed!