3

I'm working on a DAO and I need to make some kind of lottery on who get's the earnings for a certain round. To make this as honest of possible I was thinking about making a lottery where the probability is based on the number of DAO tokens the user has.

So lets say 3 users take part in the round. Let's call them Alice, Bob and Charlie. Alice has 100 DAO tokens, Bob has 50 and Charlie has 10;

Would I just pick a random number in the range of 1 to 160(the total amount in the round) and give Alice the round if it is 1-100 Bob if it is 101-150 and charlie if it is 151-160.

How do I get the DAO token balance from my seperate token contract?

And can this method handle large numbers of users without hitting the gas limit?

closed as too broad by niksmac, Paul S, Waqar Lim Apr 11 '16 at 18:10

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • The question is very broad, asking the community to design an entire app. Try coding it up and seeing how it works. You'll learn a lot by doing that. Browse through the questions to see how to unit test and check for gas expense. – Paul S Apr 11 '16 at 16:45
  • I'm not asking the community to design an entire app and I don't understand why you think I do. I'm asking for some help on a part of the problem. I'm not creating a lottery but am looking to divide work and earnings in the DAO by ownership. I'm not asking for anyone to write any code for me only to help me solve the problem of dividing work I might have phrased the question to broad and a bit unclear. – Mick de Graaf Apr 11 '16 at 17:25
  • It's most likely impossible to answer this question until you show some basic framework of your DAO or Token contracts. I see this question has potential, maybe come back here and cast a reopen vote if you have more details for other users to work with? – Waqar Lim Apr 11 '16 at 18:11
  • There are at least two questions here, you should probably ask them separately. One question is (1) How would a randomly assign outcomes to different targets in ratiometric manner using minimum gas? (easy answer, SHA3 hash, pick number ranges in proportion). and (2) How do I get information from a separate contract? (There's existing answers I believe). The third question "without hitting a gas limit" is really something you should try, and if you get stuck, ask a question. You need to learn how to budget gas, and there's resources here to help that, but the best way to learn is to do. – Paul S Apr 12 '16 at 18:57