Now, let's test that by deploying a private contract if we make data visible only to those nodes or not that are authorized.
Using the same methodology as before, let's first deploy our private contract:
> ./runscript.sh private-contract.js
Then, follow the same steps to allow each node to understand the contract:
- Get the contract address from the returned transaction hash.
- Set the address to a variable.
- Get the ABI from the .js file and set it to a variable. (Note: This is the same for both private and public contracts, so there's no strict need to update this.)
- Get a reference to the contract using the address and ABI:
> var private_contract = eth.contract(abi).at(address);
We can now show Quorum's privacy in action. On nodes 1 and 7, we are able to read the variable and be returned the expected value:
> public_contract.get()
42
On node 4—or any other node, if we attach to them—we are unable to read the value as shown here:
> public_contract.get()
0
Great! We have demonstrated how Quorum is able to keep data private within a network by using its privateFor option when deploying a contract.