Vigyata.AI
Is this your channel?

Day 7 of Blockchain | Adding Timeouts and Requiring Participation to Enforce Payout

715 views· 27 likes· 11:51· Jan 7, 2022

🛍️ Products Mentioned (7)

So it turns out - blockchain is actually pretty cool. I’m super excited to be partnering with Reach and Algorand to create a YouTube series that tackles how to create decentralized applications with blockchain technology. In 10 Days of Blockchain, you’ll learn what a blockchain is, build a decentralized application, and deploy it to the Algorand blockchain. With Day 7 specifically, we'll add timeouts to our Rock, Paper, Scissors decentralized application and require all participation from all players. Thank you for watching! ✅ NOTE: Reach documentation at the time of your viewing may be slightly different than when I recorded. When in doubt, follow the documentation, and if you have questions, connect with the Reach community in Discord. In this particular video, we initially feed in the deadline for the timeout directly. This no longer works and later in the video, we wrap the deadline with a relativeTime function. ⛓ Discord Community! Reach HQ: https://discord.gg/reachsh Got a question? Ask it here: https://discord.com/channels/628402598663290882/912484855789518848 ⛓ More about Reach! Website: http://reach.sh Links: https://reach.crd.co/ Documentation: https://docs.reach.sh Questions & Support: help@reach.sh ⛓ More about Algorand! Website: https://www.algorand.com/ My courses on LinkedIn Learning! https://www.linkedin.com/learning/instructors/kathryn-hodge Support me on Patreon! https://www.patreon.com/blondiebytes

About This Video

In Day 7 of my 10 Days of Blockchain series, I focus on a super real problem in decentralized apps: non-participation. In a normal client/server world, if someone stops responding you throw an error and move on. But in a smart contract, if one player disappears at the wrong time, funds can get locked in the contract forever. So I walk through what happens in our Rock, Paper, Scissors dApp if Alice pays a wager and Bob never accepts—or if Bob pays and Alice never reveals her hand. To fix it, I add Reach timeouts and wire them all the way through the participant interfaces so the front end can react when a timeout occurs. Alice publishes a shared “deadline” value, and then I add timeout handlers that close the contract and transfer funds to the appropriate party (plus call an `informTimeout` callback for both players). I also explain why we don’t “refund both sides” in certain cases—because it would let someone strategically time out to avoid a loss once information is revealed. Finally, I manually test by making Bob randomly “take his sweet time,” hit a deprecation warning about bare time values, and fix it by wrapping the deadline with `relativeTime`.

Frequently Asked Questions

🎬 More from blondiebytes