Implementing Giveaways in Blockchain

0 votes
I'm building a project that does a giveaway everytime the counter reaches 100k.

There are many people that can get the giveaways. It is not that only one person out of all gets the giveaway.

Every person has a Unique ID and I am randomly giving different types of gifts to them.
I dont understand how to implement this.
Aug 17, 2018 in Blockchain by sabby
• 4,370 points

edited Aug 17, 2018 by Omkar 117 views

1 answer to this question.

0 votes

I have found a similar question. The solution mentioned there was:

int(hashlib.sha256(block_header + userID).hexdigest(), 16) / float(2**256)

You conver the hash into an integer, then divide that integer by 2**256. This gives you a decimal from 0 to 1 that can be compared to a random.random() to get the prize.

Source: (https://stackoverflow.com/questions/48656958/assigning-giveaways-based-on-cryptocurrency-block-header)

answered Aug 17, 2018 by digger
• 26,720 points

Related Questions In Blockchain

0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,830 points

edited Mar 26, 2018 by Christine 766 views
0 votes
1 answer

How can i read headers of blockchain in multichain?

You could use a recent feature known ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,100 points
255 views
+1 vote
1 answer

Can Blocks be reorganized in the blockchain?

In practical applications, invalid transactions can not ...READ MORE

answered Jul 18, 2018 in Blockchain by Varun

edited Aug 3, 2018 by Omkar 169 views
+1 vote
1 answer

Can a data be altered in a blockchain without changing its hash?

Yes, it should work. The authentication practice ...READ MORE

answered Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
249 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,830 points
716 views
0 votes
1 answer
+1 vote
1 answer

What problem does pow(proof of work) solves in blockchain?

Proof of Work: When a miner gets a ...READ MORE

answered Aug 6, 2018 in Blockchain by digger
• 26,720 points
296 views
0 votes
1 answer