I am experimenting with Smart Contracts on the Ethereum Blockchain. Let's say I have a contract, something like SimpleStorage.sol found in the Solidity documentation , that has a storage state accessible by anyone. As the link describes,
anyone could just call set again with a different value and overwrite your number
This would result in problems, and the solution of restricting the accessibility of that function to specific accounts is not appropriate in my use case. In my contract, I want the data each account sets to later be accessible by a different predetermined account (think of a relationship where person A->B so B uses the data exclusively from A, and x->y where y uses the data exclusively from x. No overlap can exist where y can use A's data). From my understanding, there are 2 solutions to the problem:
- Map addresses to each other and keep track of all the data within this single smart contract.
- Have a smart contract "template" that the initial account would access, and generate a separate smart contract for each new account to simply hold data that interacts with the template.
The problem with 1 occurs when the relationship between accounts becomes more complex (map separate structs?) or a large volume of people try to store their information in the contract.
The problem with 2 is redundancy. Do I really need to produce a separate "contract" for every single person trying to access the main template?
If my question is vague, I can explain more but I am mostly looking for a conceptual answer. Most smart contract examples I have found are either extremely simple or unnecessarily complex and don't provide concrete use-case.