Tic-tac-toe on Bitcoin SV

Bitcoin: A Peer-to-Peer Electronic Gaming System

A purely peer-to-peer version of games would allow online players to play with one another without going through a gaming company. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent cheating. We propose a solution to the cheating problem using the Bitcoin network. Specifically, we put a game fully on chain: not only the data, but also the logic. We demonstrate the idea by implementing the first ever p2p version of tic-tac-toe.

Implementation

To initiate a game, Alice and Bob each locks up X amount of bitcoins into a contract UTXO. They take turns to play the game by sending signed transactions interacting with the stateful contract. If one of them wins, the winner claims the 2X bitcoins. If there is a draw, they take back their bitcoins. The core contract code is listed below with self-explanatory comments inline.

Tic-Tac-Toe Contract

Discussion

We only show the most essential part of the game contract, for ease of exposition. They are several ways to polish it into a fully practical game, including:

  • Timeout: add a clause (i.e., function) to handle when a player refuses to make his move (maybe because he finds out he will lose). For example, set nLockTime to 1 hour from now when Alice plays. If Bob does not move in time, Alice wins and can take all bitcoins. Vice versa.
  • Transaction fee: add another UTXO input and change output to cover transaction fee.

We only showed how to implement p2p games using the easiest tic-tac-toe example. The underlying idea can be trivially generalized to arbitrary games (chess, Go, poker, …) to make them fully on chain and thus peer-to-peer. It can also be extended to multiple players. Let us start playing p2p games on Bitcoin!

--

--

--

sCrypt Inc (https://scrypt.io) is a company with a mission to provide integrated on-chain smart contracting solutions using the original BitCoin Protocol on BSV

Love podcasts or audiobooks? Learn on the go with our new app.

Issue 21 — August 13 — August 31 2019

SafeBLAST (BLAST) Trading Competition

Originally published on Instagram

XT Will List PERP

A letter from Phil — Founder, SUS

Nexom Sentai Itbongers — the 1st Pixobos NFT Collection

XT Will Launch “FTM Subscription”

ARE WE NON-FUNGIBLE?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
sCrypt

sCrypt

sCrypt Inc (https://scrypt.io) is a company with a mission to provide integrated on-chain smart contracting solutions using the original BitCoin Protocol on BSV

More from Medium

Proof of Work, Proof of Stake & Pure Proof of Stake: An Evolution in Distributed Consensus

Ledger Nano Guide #3, Activate Liquidity Pool Staking on TBILL.io

CTSI Foundation Reserve Transparency Report — January 2022

A Great Start for TBILL