Sometimes I find myself lost deciding how I will store data for my application. I have a dilemma about: Decentralization vs Accessibility for everybody?
Looking to this table, which manage DAOs:
// @abi table dao i64
struct dao {
uuid id;
account_name owner;
uint16_t min_quorum;
uint16_t debating_period_minutes;
uint16_t majority_margin;
std::vector<account_name> members;
uuid primary_key() const { return id; }
};
I have two options to save a DAO: under owner
storage or under the contract _self
storage:
daos.emplace(*owner|_self*, [&](auto& r) {
r.id = next_id();
r.owner = owner;
r.min_quorum = min_quorum;
r.debating_period_minutes = debating_period_minutes;
r.majority_margin = majority_margin;
r.members = {owner};
});
My question is: should I use the dApp resources/stake and save it on the contract storage or should I save it with the owner of the DAO storage?
I might be wrong, and probably am, but if I save on the contract storage, it means that for anyone wanting to create a DAO would need the contract signature, centralizing the application, because I will always need to provide an application server API to sign the DAO creation action, right? If I'm correct, the only benefit is that the user will have it for free.
Now, in the other hand, if I use the owner storage, they will have to have tokens to stake this storage. Am I correct? The huge benefit is that the dApp is decentralized and everybody will be able to create DAOs directly in the blockchain RPC.
At the end, I don't know even if I'm thinking correctly but I would like more clarification on above and to know the right way to architect these types of contracts!
UPDATE:
Working and playing a little more with contracts I figured out that if I do:
emplace(_self, [&](auto& r){..});
It does not require the contract authorization for the action. Which I think makes sense because it's the contract code trying to store something by itself.
So my dilemma is gone, I do can pay for storage with my dApp contract in a Decentralization fashion for any user, just need STAKE!
I will leave the question open, in case that you could elaborate on my original question: How do you define who pays and what would be a good design/approach for it?