7

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?

1
  • Glad you answered your own question, I suggest removing it from the question and adding it as an answer, it's fine to answer your own question and will be easier for others to see. Jun 6, 2018 at 9:51

1 Answer 1

6

Via the Developers Portal

When adding a entry...

orders.emplace( payer, [&]( auto& o ) {
  o.id = 1;
  o.expiration = 300;
  o.owner = N(dan);
});

The first parameter payer is the account who pays the bill.

When modifying an entry...

orders.modify( order2, payer, [&]( auto& o ) {
  o.expiration = 400;
});

Payer is the second argument, again who pays. In the event that payer is the same account as the original, it will only pay the difference.

Should payer be a different account, it will take on the bill for storing the whole entry and the original payer will be refunded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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