2

I am trying to create a smart contract or a combination of contracts thereof whereby one could set permissions to view variables that can be set in a contract on a private network.

Consider an account that has deployed a contract with 2 variables:

name
address

In addition lets say there are 2 functions:

getDetails
setDetails

These can be set by the caller of the contract calling the setDetails function which can set these variables to values passed in during the invocation of the function. They can be fetched by getDetails which provides the values of these variables.

At this point, lets say an address has set the variables to

name = John
address = 1 Smith St.

How do I make sure other users/addresses calling the get function or reading the variables that have been set can retrieve the variable values only if they have the correct permissions?

I was following the Eris Industries based tutorials and noticed that permissions can be set for token transfer based on the fund manager example. Can this be extended to read variables that have been set by a previous interaction with the contract?

3

If somebody has a node on the network, they can read all the data on the blockchain. There's nothing you can do about this, except stop storing the data unencrypted on the blockchain. You may want to either encrypt each piece of data with the keys of the people who should be able to read it or set up a system to share the data with the appropriate people outside the blockchain.

However, if your end users will access the node indirectly through an application, and you trust the person who does run the node not to share the secrets, you can build information about who should be able to see the data into your smart contracts, and the enforce hiding of the data in the application.

  • "Except storing data unencrypted..." I think you mean encrypted – Tjaden Hess Sep 29 '16 at 13:53
  • Unencrypted, because that's what they have to stop doing. – Edmund Edgar Sep 30 '16 at 0:31
  • Oops, sorry. I somehow missed the word "stop" – Tjaden Hess Sep 30 '16 at 0:35
  • No worries, the way I phrased that was kind-of confusing. – Edmund Edgar Sep 30 '16 at 0:38

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.