Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from hashlib import sha256
- # the seed here is only an example.
- # 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.
- # Here is the sha256 hash of the sentence that contains the information of N:0x24f7501665d4f59b7f65c0853f8dd2a68fe528d345ffe63721f391eec711c190
- seed = "0x08e94db8e9f6bd60152a0d7e54bc4a6f937f3a50af47bc08154787d8fb90292f"
- # This is the number of the participants in total.
- # The number here should be replaced with the actual number after the competition conclude.
- participantNumber = 1000
- # init lottery and result
- result = []
- hashed = sha256(seed).hexdigest()
- lottery = int(int(hashed,16) % participantNumber)
- result.append(lottery)
- # loop to draw lottery
- for i in range(64):
- while lottery in result:
- hashed = sha256(hashed).hexdigest()
- lottery = int(int(hashed,16) % participantNumber)
- result.append(lottery)
- # sort the result
- result.sort()
- # The result printed here will be a list of numbers, which indicates the lottery winners according to their rank upon the competition ending.
- # The list that contains all the participants' address will be disclosed after the competition is finished.
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement