...by Daniel Szego
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Sunday, January 8, 2017

Creating permissions on the Ethereum Blockchain with SmartContract

Let we create a simply example for a permissioned Smart Contract on Ethereum Blockchain. Let we assume that we have the following atomic level of access:
- Read: reading information from the state of the Smart Contract.
- Write; Writing information to a Smart Contract.
- Admin: administration the roles.

Let we assume that the Smart Contract has a couple of variables in a struct for storing internal information an enum for storing atomic access information, a mapping for storing the access information for each account and and a constructor that guarantees that the creating account is registered as Admin
Let we create as the next step three modifiers to guarantee that certain functions can be called only by the necessary rights. 
Last but not least, we use the modifiers in the service functions to make sure that only people with the necessary right are able to reach the given service, In our example, we have three services: for reading out data, for writing data and for administrating access.

Certainly, getData functionality does not really cover the expected functionality. As Ethereum is a public Blockchain, the data can be practically read out from the Blockchain even if the getData function can not be explicitly called.