SHARE
TWEET

Untitled

a guest Jun 24th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from hashlib import sha256
  2.  
  3. # the seed here is only an example.
  4. # The seed for the lottery (of Nervos CKB Minning Competition between 6/15 and 6/28) will be the block hash of the block of height N.
  5. # Here is the sha256 hash of the sentence that contains the information of N:0x24f7501665d4f59b7f65c0853f8dd2a68fe528d345ffe63721f391eec711c190
  6. seed = "0x08e94db8e9f6bd60152a0d7e54bc4a6f937f3a50af47bc08154787d8fb90292f"
  7.  
  8. # This is the number of the participants in total.
  9. # The number here should be replaced with the actual number after the competition conclude.
  10. participantNumber = 1000
  11.  
  12. # init lottery and result
  13. result = []
  14. hashed = sha256(seed).hexdigest()
  15. lottery = int(int(hashed,16) % participantNumber)
  16. result.append(lottery)
  17.  
  18. # loop to draw lottery
  19. for i in range(64):
  20.     while lottery in result:
  21.         hashed = sha256(hashed).hexdigest()
  22.         lottery = int(int(hashed,16) % participantNumber)
  23.     result.append(lottery)
  24.  
  25. # sort the result
  26. result.sort()
  27.  
  28. # The result printed here will be a list of numbers, which indicates the lottery winners according to their rank upon the competition ending.
  29. # The list that contains all the participants' address will be disclosed after the competition is finished.
  30. print(result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top