While studying blockchain interoperability (like BTC relay or a Dogecoin relay), it came to my mind that if the Ethereum blockchain can read another blockchain, we could use the same process to make the Ethereum blockchain read itself including private values of contracts.

This would defeat the goal of making some contract variables private.

What would prevent someone from setting a contract (using a Ethereum-Ethereum relay) reading a private value?

If this is effectively possible, shouldn't we simply stop making variables private, as it would be misleading and leading to security issues?

1 Answer 1


In my opinion ...

You raise a good point about a potentially misleading term, but private does more than obfuscate data in reads - it also blocks writes from child contracts, and this has the important effect of blocking child contracts from accidentally overwriting an important piece of information.

"owned" is a common snippet that:

  1. sets a privileged address, the owner, and
  2. lays out a modifier to protect functions from unauthorized use.

One can say

contract App is owned {

and inherit functionality from "owned" including an "owner" state variable. (owned.sol would be a little contract in itself.)

In the case that owner isn't private, the child contract (App) can potentially overwrite the owner address. That is, nothing stops it from altering the variables it inherited. It's allowed to, unless they're set to private in the contracts they're inherited from.

Setting to private is a way of ensuring changes will only go through prescribed channels. Strict control over updates/writes safeguards the integrity of the data.

In terms of "reading" "private" information, the protection is illusory. Everything on the blockchain is on all the hard drives of all participants. A contract can make it inconvenient to read private information but inconvenience is insufficient to safeguard confidential information from a determined adversary. If sensitive information must be stored there, then it should be in a strongly encrypted form.

Hope it helps.

  • Thanks for your answer. The fact that private values are visible to the outside world is clear in the documentation. "Making something private only prevents other contracts from accessing and modifying the information, but it will still be visible to the whole world outside of the blockchain." But it explains that it prevent other contracts from accessing to the information. And this could be overcome by relay methods. Ok, so we still have the use of private for inheritance.
    – clemage
    Feb 3, 2017 at 19:46
  • Hope it helped. I try to frame answers to the question, as asked, and add some interpretation to what the docs say; hopefully without propagating confusion. Shamelessly refers to upvote option :-) Feb 3, 2017 at 20:54
  • somebody tell Parity lol
    – luca590
    Jan 19, 2018 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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