Project Lottoshi

in LeoFinance •  last month 


lotto 2.png

Another project I'm working on concurrently with Pentaskill is Lottoshi. Often times when I make progress on Pentaskill I realize that the code I've written will also work toward completing this lottery.

The best example of this was my work with SHA-256 hashing (Bitcoin's hashing algorithm). I thought it might be difficult to get this up and running, which made me shy away from working on the project more. However, it turns out I also needed a way to obfuscate the skills chosen in Pentaskill so players couldn't cheat, so I used SHA-256 for both projects. Turns out, getting it up and running was as easy as copy/pasting a file someone else had written and importing it into the project.

<script src="SHA256.js"> </script>

Easy

All that's left to do now is to find Bitcoin node APIs I can connect to in order to retrieve the hash information of certain blocks. I thought this would be trivially easy, and honestly it should be, but I keep running into problems.

Currently I'm trying to access https://www.blockchain.com/api/

fetch('https://blockchain.info/latestblock', {
})
.then(function(response) {
  // Do something with response
  console.log(response)
});

No Dice

t1.png

Apparently there are security issues with what I'm trying to do. I have very little experience connecting with servers and trying to get information from them, so I'm pretty clueless in this department. Now I'm in a rabbit hole of looking up how things like CORS works and the standard procedure of fetch() and the JavaScript API in general.

It's pretty annoying because all I want is the stupid hash of the given Bitcoin block number. Shouldn't be this difficult, but here we are.

lotto.jpg

Why Bitcoin?

Bitcoin is the first and most secure crypto on the planet. As such, Bitcoin block hashes are the perfect solution for a second-layer lottery stacked on top of it. The process of Bitcoin mining is already a lottery. SHA-256 hashes are totally random, and the only way to post a Bitcoin block to the network and get the 12.5 BTC block reward is to generate a hash with a massive amount of leading zeros.

t1.png

Imagine how hard it would be to generate a totally random number with all those leading zeros.

JK, you don't have to imagine it, because it's all math. These are hex digits (base-16), so the chance of getting one zero is 1/16. The chance of getting 19 leading zeros is 1/16^19 aka 1/‭75,557,863,725,914,323,419,136‬.

So yeah, it's not easy.

The entire world is competing to hash these winning lottery tickets and get the block reward of 12.5 Bitcoin. The difficulty of the lottery changes every 2 weeks in order to try and center the average time per block to around 10 minutes, making Bitcoin the most secure blockchain of all time. The amount of energy and hardware one would need to attack the network is so massive that by the time you acquired all those resources you wouldn't want to attack the network anymore because playing by the rules is far more profitable.

lotto ticket hash.png

In any case.

The leading zeros of a Bitcoin block hash are obviously not random, but all the other numbers are. Therefore, my plan is to use those unhackable random numbers as a seed for another lottery: Lottoshi. Essentially, whoever's lottery ticket is closest to the given Bitcoin block hash wins the lottery. Honestly, I can't believe this doesn't exist already.

This is yet another example of developers being greedy and overly concerned about capturing value for themselves. The beauty of crypto is that these applications don't need to capture value. The programmers simply need stake in the network that the apps are on. By having stake in the network value is captured automatically by the cryptocurrency itself. The magic of crypto is that EVERYONE benefits from the work being done. The potential synergy is incredible.

Can you imagine what would happen if Steem/Bitcoin were the first networks to create a peer-to-peer lottery that was impossible to regulate and no centralized authority was scraping massive profits off the top of the winnings? Zero-rake gambling is the future of gambling. The Race To The Bottom is real.

Conclusion

And it all hinges on me grinding through learning JavaScript and connecting to other servers and all that. I'm pretty annoyed at the moment. The problems I run into while learning this stuff could be fixed in minutes if I actually had a tutor telling me what to do, but instead I go down these rabbit holes where I learn 100 different things and I still haven't found the solution for what I'm looking for. Pretty fun, especially when you just forgot the 100 things you just learned because it was too much information all at once that you didn't use.

Here's to daydreaming about that tipping point.

Posted via Steemleo

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

I'm home for this weekend, have stationary pain therapy for another 3 weeks. no wifi.
now.. I'm home and reading this little gem.

I love these news and can't wait to gamble :D

but first I need to get rid off my pain and work for some crypto to gamble ;)

wish you much fun in rabbit holing buddy^^

This is pretty cool and exciting. Good Luck and may your tank of perseverance’s never run dry.

the fact is bitcoin of course is actually the most secure crypto...so picking bitcoin as your choice is a good decision by you @edicted

Posted via Steemleo

i am always excited when great people like @edicted do awesome projects like this,i am so positive that this will bring alot of wonderful developments to the steem blockchain....

Posted via Steemleo

the name "lottoshi"itself sounds awesome and will grab the attention of so many people...and creating a token for the project would be amazing too...

Posted via Steemleo