E-Sports - Web3 PvP Winner Takes Crypto

This revision is from 2026/11/01 21:07. You can Restore it.

Version 2 of the article

Peer-to-Peer (PvP) E-Sports Gaming Platform

Introduction

The concept is to create a decentralised, peer-to-peer (PvP) competitive gaming platform where two people can challenge each other to a game of skill, put cryptocurrency at stake, play the game, and have the winner automatically receive the prize pool through a smart contract.

Rather than betting against a bookmaker or the platform itself, the two players compete directly against one another. Both players contribute an equal amount of cryptocurrency, and the smart contract holds the money in escrow until the outcome has been established.

For example:

  • Player A wants to play a game of football against another online player.
  • Player B accepts the challenge.
  • Both players agree to stake $10 worth of cryptocurrency.
  • Player A deposits $10 into the smart contract.
  • Player B deposits $10 into the same match contract.
  • The game begins once both deposits have been confirmed.
  • They play the match.
  • The game server determines the winner.
  • The result is verified and submitted to the smart contract.
  • The smart contract awards the entire $20 prize pool to the winner.

The platform does not need to develop every game itself. Instead, it provides the environment in which players meet, challenge one another, arrange matches, deposit their stakes, play and collect their winnings.

The same system could accommodate fighting games, football games, racing games, chess, trivia, strategy games, card games and other competitive games where a winner can be objectively established.

The underlying principle is simple: Two players. One game. Two stakes. One winner. One smart contract settlement.

1. Platform Overview

The platform consists of five primary components:

  1. The kiosk (gaming lobby and matchmaking).
  2. Player registration and cryptocurrency wallet integration.
  3. Match creation and smart contract escrow.
  4. The actual multiplayer game.
  5. Game-result verification and prize distribution.

These components communicate with each other but should remain separate modules. This is important because additional games should be introduced without rebuilding the entire wagering and matchmaking infrastructure.

2. The Gaming Kiosk

The kiosk is the central meeting point for players.

When someone visits the website, they enter a gaming lobby showing other registered players who are currently online and available to play.

Each player has a profile containing:

  • Username and avatar.
  • Cryptocurrency wallet address.
  • Online/offline status.
  • Games available to play.
  • Competitive ranking or experience.
  • Match history.
  • Wins and losses.
  • Preferred stake amounts.
  • Current match status.

Players browse the available opponents and select someone to challenge.

PlayerGameStatusRecord
Player AFightingAvailable12–4
Player BFootballAvailable8–3
Player CChessIn a match20–6
Player DFightingAvailable4–2

A player clicks an opponent and selects the game and stake amount.

The opponent receives a challenge notification containing:

  • Challenger's username.
  • Selected game.
  • Proposed stake.
  • Cryptocurrency/token being used.
  • Total potential prize pool.
  • Match rules.
  • Time allowed to accept.

The invited player can accept or decline. A player cannot participate in multiple active matches simultaneously, and an accepted challenge should reserve both players while deposits are being confirmed.

3. Player Registration and Cryptocurrency Wallets

Players register an account and connect a Web3 wallet.

The wallet is used to establish player ownership, authorise match participation and pay the cryptocurrency stake.

The platform should support:

  • MetaMask.
  • WalletConnect-compatible wallets.
  • Other compatible EVM wallets.
  • Smart contract wallets where supported.

The website must never request or store a player's private keys or seed phrase.

Wallet ownership can be established through a signed login message containing a one-time nonce. This prevents someone from registering a profile using another person's wallet address.

For the initial implementation, it would be preferable to support one blockchain and one cryptocurrency or stablecoin rather than introduce multiple networks and tokens immediately.

The website must display the required stake, network, token, transaction fees and total financial commitment before asking either player to approve a transaction.

4. Match Creation and Smart Contract Escrow

Once a player challenges another player and the challenge is accepted, a match is created.

Each match receives a unique identifier.

The match information includes:

  • Match ID.
  • Player 1 wallet address.
  • Player 2 wallet address.
  • Game identifier.
  • Game version.
  • Stake amount.
  • Accepted token.
  • Blockchain network.
  • Match rules.
  • Match creation timestamp.
  • Deposit deadline.
  • Match status.

The smart contract manages the escrow. The recommended arrangement is to use one shared escrow contract that manages multiple individual matches through unique match IDs. There is no need to deploy an entirely new Solidity contract for every game.

The deposit process

  1. Player 1 creates the match and deposits their stake.
  2. The contract records the deposit and changes the match status to awaiting Player 2.
  3. Player 2 accepts the invitation and deposits exactly the same amount.
  4. The smart contract verifies that the caller is the invited opponent, the match is still open, the deposit amount is correct, the correct cryptocurrency is being deposited, Player 1 has already deposited and the match has not expired.
  5. Only after both deposits are confirmed does the match become eligible to start.

The money remains locked in escrow. Neither player can withdraw their stake while the match is in progress.

The contract must also handle unsuccessful matches. For example, when the second player does not deposit before the deadline, Player 1 must be able to cancel the match and recover their original deposit.

5. Starting the Game

Once both players have deposited their stakes, the match room becomes available.

The players are redirected to the selected game. The game receives the unique match ID, player identities, agreed rules and game configuration.

Both players must confirm readiness before the game starts.

The game room should be accessible only to the two participating wallet addresses. A shared invitation link alone must not grant someone the ability to participate.

The game itself should operate independently of the blockchain.

There is no reason to record every movement, button press, football pass or fighting-game attack on a blockchain. That would introduce unnecessary transaction fees and latency.

Instead, the game runs through a conventional multiplayer game server, which communicates with both players in real time.

The smart contract is responsible for the money, not the actual gameplay.

6. Game Server and Winner Determination

This is one of the most important parts of the entire project.

The game server must establish the authoritative outcome of the match. It cannot simply accept a message from Player 1 saying that they won, or allow either player's browser to submit the winner.

A dishonest player could otherwise manipulate their browser and submit a fake winning result.

The game should use server-authoritative gameplay wherever possible.

Both players send their game inputs to the server. The server validates those inputs, maintains the official game state and determines the result.

The clients display the game and send player actions, but they do not have final authority over the score or winner.

At the conclusion of a match, the server generates a result containing:

  • Match ID.
  • Player 1.
  • Player 2.
  • Winner.
  • Final score.
  • Game identifier and version.
  • Match rules version.
  • Result timestamp.
  • A hash identifying the match record or replay.

The platform then verifies and submits the result to the smart contract.

7. Result Verification and Smart Contract Settlement

The smart contract must not accept arbitrary winner declarations.

For the initial implementation, the game server should have a designated signing identity. It signs the official match result using an authorised private key held securely by the backend, not in the browser.

The contract verifies the signature and confirms that:

  • The match exists.
  • Both players funded the match.
  • The match is eligible for settlement.
  • The proposed winner is one of the two registered players.
  • The signature belongs to an authorised result signer.
  • The result has not previously been processed.
  • The match ID and game rules correspond to the original agreement.

The signed message should use a structured-message standard such as EIP-712.

The signed message should include replay protection, including the match ID, contract address, chain ID and appropriate nonce or one-time match state.

For additional protection, both players can be shown the final score and invited to acknowledge it.

If both agree, settlement can proceed immediately. If either player contests the result, a predefined dispute process applies.

A server signature establishes that an authorised server reported a result. It does not mathematically prove that the result was fair. The platform must therefore protect its game servers, retain appropriate match records and provide a dispute mechanism.

8. Prize Distribution

Once the result has been approved, the smart contract credits the winner with the prize.

For a $10 versus $10 match:

DescriptionAmount
Player 1 contribution$10
Player 2 contribution$10
Total prize pool$20
Winner receives$20

The winner can withdraw their funds through the smart contract.

The platform could eventually introduce a disclosed service fee, but this should be a separate, transparent calculation. The initial implementation could use a zero-fee model.

The contract should use a secure withdrawal-credit system rather than relying on a direct payment to the winner during match settlement.

This allows the match to be settled even if the winning wallet has unusual transaction requirements or cannot receive a direct transfer at that moment. The prize remains available for the winner to withdraw.

9. Returning Players to the Kiosk

After settlement, the match is marked as completed.

Both players are returned to the kiosk.

Their match histories and statistics are updated:

  • Match ID.
  • Game played.
  • Opponent.
  • Stake.
  • Winner.
  • Final score.
  • Prize awarded.
  • Date and time.

The players can challenge each other again or select another opponent.

The kiosk becomes a continuously operating environment where people can find opponents and participate in competitive matches.

10. How the Complete System Works

The following illustrates the complete lifecycle of a match:

  1. Player A registers and connects a wallet.
  2. Player B registers and connects a wallet.
  3. Both players appear in the online kiosk.
  4. Player A selects Player B.
  5. Player A chooses a game.
  6. Player A selects the stake amount.
  7. Player B receives the challenge.
  8. Player B accepts the challenge.
  9. The platform creates a unique match ID.
  10. Player A deposits their ante into escrow.
  11. Player B deposits the matching ante.
  12. The backend detects both confirmed deposits.
  13. The game room is opened.
  14. Both players confirm readiness.
  15. The match starts.
  16. Both players compete in the game.
  17. The authoritative game server establishes the result.
  18. The game server signs the result.
  19. The result is submitted to the smart contract.
  20. Both players can acknowledge the result or invoke the dispute procedure.
  21. The contract settles the match.
  22. The winning player receives a claimable balance equal to the prize.
  23. The winner withdraws their cryptocurrency.
  24. The match is marked completed.
  25. Both players return to the kiosk.

The process should be largely automated. A user should not need to communicate manually with an administrator to arrange a match or collect winnings.

11. Smart Contract Architecture

The original Solidity contract provides a starting illustration of the intended concept, but it should be replaced with a proper escrow implementation.

The smart contract should operate as a match-management and financial-settlement system.

A suggested interface is:

FunctionPurpose
createMatch()Creates a match and records Player 1's deposit.
joinMatch()Allows the invited Player 2 to deposit the matching stake.
cancelMatch()Allows a valid cancellation before the match begins.
startMatch()Moves a fully funded match into an active state, subject to the agreed authorisation rules.
submitResult()Submits the authorised match result and signature.
challengeResult()Allows a player to dispute a submitted outcome.
resolveDispute()Records an authorised dispute decision.
finalizeMatch()Finalises an approved outcome and credits the prize.
refundMatch()Returns stakes when a match is legitimately voided.
withdraw()Allows players to withdraw their available balances.

The contract should maintain a separate state for each match.

Suggested states:

  • OPEN — Player 1 has created the challenge.
  • AWAITING_OPPONENT — Waiting for Player 2's deposit.
  • FUNDED — Both players have deposited.
  • IN_PROGRESS — Game is active.
  • RESULT_PENDING — Game result has been submitted.
  • DISPUTED — A result has been challenged.
  • SETTLED — Winner has been determined and funds allocated.
  • REFUNDED — Match has been cancelled and stakes returned.

This approach prevents one game from interfering with another and makes it easier to track the financial status of every match.

Handling Different Cryptocurrencies

The initial implementation should support a single asset. Later, the escrow contract can be extended to accept ERC-20 tokens as well as the blockchain's native currency.

When ERC-20 tokens are used, the contract must correctly verify token transfers, handle token decimals and use safe token-transfer methods.

The match must record the exact token contract address and amount. Players must never be able to deposit one asset and receive a payout calculated using another.

Important Contract Security

The contract should incorporate established smart contract security practices:

  • Checks-effects-interactions.
  • Reentrancy protection.
  • Restricted result-authorisation permissions.
  • Replay protection.
  • Correct state transitions.
  • Deposit deadlines.
  • Refund mechanisms.
  • Emergency pause functionality.
  • Safe token-transfer handling.
  • Events for every important financial operation.

The winner's funds should be credited before withdrawal, following a pull-payment design.

Useful security references:

The contract should be extensively tested and independently audited before real funds are accepted.

12. The Game Development Component

The game itself should be modular.

There should be a common platform interface that allows individual games to be registered and accessed through the kiosk.

Each game must provide:

  • Game loading.
  • Player assignment.
  • Match initialisation.
  • Multiplayer communication.
  • Game-state management.
  • Score tracking.
  • Winner determination.
  • End-of-match notification.
  • Result generation.

The kiosk should not need to understand the internal mechanics of each game. It needs only to understand how to launch a match, identify the participants and receive the verified outcome.

Games Worth Investigating

1. Beat 'em up — HTML5 Mortal Kombat-style Game

https://github.com/simonsablowski/beatemup

This is interesting because it is written in HTML5 and JavaScript and runs directly in the browser.

It includes a game engine, fighter state machines, character definitions, animation handling, collision detection and input handling.

It is a useful reference for examining how a browser-based fighting game could be structured. However, its assets and branding cannot simply be adopted for a commercial gaming platform. It also needs substantial multiplayer networking and authoritative server development.

2. Battle Bros — Python Arcade

https://github.com/njbittner/battle-bros-pyarcade

A Mortal Kombat-style fighting game written with Python Arcade.

It has basic fighter movement, animations and combat mechanics. It is a useful reference for the mechanics of a fighting game, but it is designed around two players sharing a local keyboard and would require substantial work to become a browser-based multiplayer game.

3. Street Fighter CSS

https://github.com/jkneb/street-fighter-css

A small experiment recreating Street Fighter-style animation using CSS and JavaScript.

It is interesting from a rendering perspective but is not a finished multiplayer fighting game. It also contains copyrighted Street Fighter material.

4. Battleship Online

https://github.com/carabus/battleship-online

A useful example of a two-player online game.

It implements game-room creation, invitation links, player identities, turn-based multiplayer and Socket.IO communication.

The project uses Node.js, Express, MongoDB and Socket.IO. It is more useful as a reference for the lobby and room-management infrastructure than as a template for a real-time fighting game.

5. Multiplayer Quiz

https://github.com/shaan1337/quiz

A browser-based, real-time multiplayer quiz application using Node.js and Socket.IO.

It supports player participation, authentication codes, spectators, leaderboards and administrator controls.

Although it is not a fighting game, several of its multiplayer-management features could be adapted to the kiosk.

Game Selection Recommendation

Rather than attempting to adapt Street Fighter, Mortal Kombat or Tekken themselves, the platform should start with an original or properly licensed game.

The first game should be deliberately simple to integrate, with well-defined rules and an authoritative game server.

It is important to prove the entire process works before spending significant resources creating a sophisticated game.

The architecture should allow additional games to be introduced later without modifying the underlying escrow system.

13. Lobby and Matchmaking Architecture

The kiosk needs to handle both direct challenges and general matchmaking.

Direct Challenges

This is the simplest approach.

A player browses the online list, selects an opponent and sends a challenge. The receiving player accepts or declines.

The challenge contains the game, stake, currency, rules and expiration time.

Once accepted, the match is reserved for those two players.

Open Matchmaking

A second option is a queue system.

A player selects:

  • Game.
  • Stake range.
  • Preferred competitive level.
  • Optional geographic region or server preference.

The platform searches for another available player with compatible requirements.

Once a match is found, both players are presented with the proposed match and must accept.

This is useful when the platform has a large number of users.

Match Rooms

Each match should have a private room.

The room contains the match details, two participating players, deposit status, readiness status, game session and result.

The room should prevent additional players from entering as competitors. Spectators could be introduced later with read-only access.

The match room can also display an on-chain link to the escrow transaction so players can independently verify that their stakes have been deposited.

14. Technical Implementation

A practical division of responsibilities would be:

ComponentSuggested Technology
Website and kioskHTML5, JavaScript, React or Next.js
Game renderingHTML5 Canvas or a suitable browser game engine
Multiplayer communicationWebSockets / Socket.IO
Game serverNode.js or TypeScript
Matchmaking and presenceWebSocket service with Redis
User accounts and match historyPostgreSQL
Blockchain communicationethers.js or viem
Wallet integrationEIP-1193 wallet providers / WalletConnect
Smart contractsSolidity
Contract development and testingFoundry or Hardhat
Blockchain event monitoringBackend chain listener / indexer

System Architecture

                    PLAYERS
                       |
                       v
                WEBSITE / KIOSK
                       |
              +--------+--------+
              |                 |
              v                 v
         MATCHMAKING         WALLET
              |                 |
              v                 v
         MATCH SERVICE     SMART CONTRACT
              |              (ESCROW)
              |                 |
              v                 |
          GAME SERVER            |
              |                 |
              v                 |
        GAME RESULT              |
              |                 |
              v                 |
       RESULT SIGNER             |
              |                 |
              +--------+--------+
                       |
                       v
               SMART CONTRACT
                       |
                       v
                WINNER PAYOUT

The chain listener monitors deposits, settlement events, refunds and withdrawals. The backend must use confirmed blockchain events rather than trusting a browser's claim that a transaction succeeded.

Why Keep Gameplay Off-Chain?

A fast-paced fighting or football game could generate hundreds or thousands of player actions during a match.

Writing all those actions to a blockchain would make the game expensive, slow and unnecessarily complicated.

Instead:

  • Player inputs travel to the game server.
  • The game server processes the gameplay.
  • The game server establishes the official outcome.
  • Only the final result and settlement are handled on-chain.

This hybrid approach retains blockchain-based escrow without attempting to turn the blockchain into a real-time game engine.

15. Essential Issues That Must Be Resolved

The platform must handle situations where matches do not proceed normally.

Opponent Never Deposits

The first player's deposit is returned after the invitation expires.

Player Disconnects

The game should have a reconnection period. If the player fails to return, the match follows predetermined forfeit or cancellation rules.

The Game Ends in a Draw

The rules must specify whether the match is replayed or both players receive their original stakes back.

The Game Server Becomes Unavailable

The match must not remain permanently locked. A timeout and refund or dispute mechanism is required.

A Player Disputes the Winner

The platform should have a documented procedure for investigating match records, replay data and server logs. An authorised arbitrator or dispute mechanism makes the final decision.

A Player Attempts to Cheat

The game server should validate player actions, prevent impossible game states and reject manipulated scores.

A Player Attempts to Submit the Same Result Twice

The smart contract must enforce one-time settlement for every match ID.

A Smart Contract Transaction Fails

The match status and deposit records must remain consistent, and the players must be able to retry the appropriate operation without accidentally depositing twice.

Blockchain Transaction Delays

The game must not start until both stakes have been confirmed. The interface should clearly display pending, confirmed and failed transactions.

16. Dispute Resolution and Decentralisation

There are two different levels of decentralisation.

The first is financial decentralisation: the players' money is held in a smart contract, and the operator cannot arbitrarily transfer the escrow to itself.

The second is gameplay decentralisation: the result of a game is independently verifiable without trusting a central server.

The first is considerably easier to implement.

For an initial release, a central authoritative game server can sign the results. This is practical and allows conventional online games to be integrated.

However, this means players are trusting the platform's result-verification infrastructure.

A more advanced implementation could introduce:

  • Both players signing the final match result.
  • Independently operated result-verification nodes.
  • Multiple authorised result signers.
  • Third-party arbitrators.
  • Cryptographically verifiable game replays.
  • Deterministic game simulation and independently reproducible outcomes.
  • Zero-knowledge proofs for games where sufficiently practical.

It is not necessary to implement all of these at the outset.

The important requirement is to design the smart contract so that the result-verification method can be upgraded without replacing the entire gaming platform.

17. Development Roadmap

The project should be developed in stages.

Stage 1: Smart Contract Escrow

Build the financial foundation first.

Create and test the contract for match creation, two-player deposits, escrow locking, result submission, disputes, refunds and withdrawals.

Use a test network and simulated wallets. Do not initially involve complicated multiplayer games.

Stage 2: Player Registration and Kiosk

Implement registration, wallet authentication, profiles, online status and player listings.

Allow users to select another player and send a challenge.

Stage 3: Matchmaking and Match Rooms

Implement challenge acceptance, match IDs, private game rooms, reservation of players and deposit confirmation.

Players should be unable to start a match until the contract confirms both deposits.

Stage 4: First Multiplayer Game

Integrate one simple browser-based game.

Implement multiplayer communication, authoritative server-side game state, score tracking and winner determination.

The game should communicate with the platform through a defined interface.

Stage 5: Automated Settlement

Connect the game server to the result-signing system.

Once a match is complete, submit its signed result, apply the agreed dispute procedure and settle the smart contract.

The winning player should be able to withdraw their winnings.

Stage 6: Complete the Platform

Add:

  • Match history.
  • Player rankings.
  • Leaderboards.
  • Player statistics.
  • Rematches.
  • Open matchmaking.
  • Spectator mode.
  • Additional games.
  • Additional stake levels.
  • Additional supported tokens, if justified.

Stage 7: Production Security and Compliance

Before accepting real cryptocurrency:

  • Commission an independent smart contract audit.
  • Test game-server security and anti-cheat mechanisms.
  • Test deposit, payout, refund and dispute procedures.
  • Protect result-signing keys.
  • Implement monitoring and incident response.
  • Establish the required legal and regulatory operating arrangements.

18. Legal and Operating Considerations

There is one important non-technical issue.

A platform where two users stake cryptocurrency on the outcome of an online game may fall within gambling, betting or regulated skill-gaming legislation, depending on the jurisdiction and the precise operating model.

Calling something a game of skill does not automatically exempt it from regulation.

For example, the UK's Gambling Commission regulates remote gambling and identifies licensing requirements for relevant remote gambling software and operators. Its requirements can apply to businesses based overseas when they provide facilities to consumers in Great Britain.

The platform therefore needs jurisdiction-specific legal analysis before public operation.

Depending on where it operates, relevant requirements may include licensing, age verification, geographical restrictions, KYC/AML, sanctions controls, payment restrictions, consumer protection and tax reporting.

Smart contracts do not remove these responsibilities.

19. Critical Analysis of the Original Solidity Contract

The supplied contract has several fundamental problems. These are not minor improvements; the financial logic needs to be rewritten.

ProblemWhy It Matters
Only one player depositsplay() receives one betAmount, not two independent deposits.
Incorrect transfersThe contract attempts to transfer betAmount to both players despite receiving only one bet. On a fresh contract, the second transfer will fail and revert the transaction.
No escrow lifecycleThere is no proper process for accepting a challenge, funding it and locking the funds.
No caller authenticationAnyone can call play(), not just the two registered players.
Both moves are submitted togetherOne caller supplies both players' moves and can manipulate the result.
No move validationThe contract does not properly restrict moves to the permitted values.
No draw resolutionA draw assigns the winner to address(0), leaving no valid claimant.
Incorrect payoutclaimWinnings() attempts another payment of twice the bet, although the funds have already been transferred or the contract cannot afford it.
No match separationThere is no unique match ID or independent state for multiple games.
Unsafe payment designDirect transfer() payments are not the preferred approach for a modern payout system.
No timeout or dispute handlingA match can become impossible to resolve properly.

There is another issue with the original JavaScript example. It reads both players' wallet addresses but submits only one transaction, from Player 1. Player 2 never independently authorises or deposits anything.

The correct financial model is two separate deposit transactions, one from each player.

The actual game result then becomes a separate operation.

One terminology clarification: the supplied code is Solidity for an EVM-compatible blockchain, not a Solana program. If the intended deployment is Solana, the smart contract/program implementation would need to be different.

20. Recommended First Working Demonstration

I would avoid developing the complete platform and a sophisticated fighting game simultaneously.

The biggest development risk is not the kiosk or wallet connection. It is getting a trustworthy game-result mechanism connected to an escrow contract.

I would develop the following as the first working demonstration:

  1. Two players enter the kiosk. Both connect wallets and appear in the online player list.
  2. Player A challenges Player B. Both agree on a game and a fixed cryptocurrency stake.
  3. Both deposit into escrow. The contract independently verifies both deposits.
  4. The game starts. A simple original browser-based two-player game runs on the game server.
  5. The game determines the winner. The authoritative server records and signs the outcome.
  6. The contract settles the match. The winner receives a claimable balance representing the entire prize pool.
  7. The winner withdraws. The match closes and the players return to the kiosk.

Once this entire process works reliably, introducing additional games becomes a much more manageable exercise.

21. Final Project Objective

The ultimate aim is to create a universal PvP gaming kiosk.

Instead of building a separate cryptocurrency wagering system for each game, we build one common platform and integrate multiple games into it.

A player visits the kiosk, sees other players who are online, selects an opponent, chooses a game, agrees to a stake and enters a match.

Both players deposit their cryptocurrency into a smart contract.

The game runs independently, the result is verified, and the contract distributes the prize.

The platform could eventually support dozens or hundreds of games without having to reinvent the financial system or matchmaking infrastructure for every new title.

The real project is not simply a fighting game with cryptocurrency attached. It is a reusable competitive gaming infrastructure with wallet-based identities, peer-to-peer matchmaking, smart contract escrow, game-result verification and automated prize distribution.

Version 1 of the article

The smart contract handles the money, the game server handles the match, and a trusted result-verification mechanism connects the two.

PvP, stands for player versus player. This is Eth contract where two parties enter into the contract, they both put some amount of crypto in and depending on the outcome of the game, the winner takes all the crypto.

What is required?

The kiosk, where players are organized to play. A player clicks on another player in a list. Before game commence, a web3 contract is setup for the game, players ante into the game. Wallets are deducted the ante of the game and locked into the contract. They enter and play a game of skill, such as Street Fighter 2, Mortal Kombat or Tekkan style game. The game registers the winner and executes the contract to send all the takings to the winner of the bout.

Here the sol contract is supplied.

The kiosk, the pre-game management, the game and outcome have not been developed.

The contract allows two players to play a game of rock-paper-scissors by calling the play() function and passing in their moves as arguments. The contract then determines the winner and sets the winner variable accordingly. The winner can then call the claimWinnings() function to receive their winnings, which is twice the amount of the bet.

To call the contract's functions from a web program, you could use a library such as web3.js. Call the play() function from a web program:

const Web3 = require('web3'); const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

// Set the contract address and ABI (generated from the Solidity contract) const contractAddress = '0x12345...'; const contractABI = []; const contract = new web3.eth.Contract(contractABI, contractAddress);

// Get the player addresses and bet amount from the form input const player1Address = document.getElementById('player1Address').value; const player2Address = document.getElementById('player2Address').value; const betAmount = document.getElementById('betAmount').value;

// Call the play function contract.methods.play(player1Move, player2Move).send({ from: player1Address, value: betAmount }) .then(function(receipt) { console.log(receipt); });

The code sends a transaction to the Ethereum network to call the play() function on the contract, with the player addresses and bet amount provided as input. The transaction is sent from player1Address, and the value field indicates the amount of ETH to send along with the transaction.

Call claimWinnings() function in a similar way, by replacing play() with claimWinnings() and providing the winner's address as the from field.

Potential Games To Develop

- https://github.com/jkneb/street-fighter-css

- https://github.com/simonsablowski/beatemup

- https://github.com/njbittner/battle-bros-pyarcade

- https://github.com/carabus/battleship-online

- https://github.com/shaan1337/quiz

How The Game Lobby Might Work?

Online multiplayer lobby maintains a list of all users who are currently online and available to play. They must register. When a user starts a new game, the system generates a unique link to the game room that can be shared with other online players. Other players can then accept the invitation to join the game, and the game room is locked to prevent any additional players from joining the game, the smart contract is executed, and the ante is taken from accounts and locked in the smart contract. The game is then initiated and the players can begin the match. The winner of the game is known and the smart contract winner function executed. The users are returned to the lobby to try again.

pragma solidity 0.6.0;

contract Game {

address public player1;

address public player2;

uint public betAmount;

bool public gameOver;

address public winner;

constructor(address _player1, address _player2, uint _betAmount) public {

player1 = _player1;

player2 = _player2;

betAmount = _betAmount;

gameOver = false;

}

function play(uint8 _player1Move, uint8 _player2Move) public payable {

require(!gameOver, "The game is already over.");

require(msg.value == betAmount, "Incorrect bet amount.");

player1.transfer(betAmount);

player2.transfer(betAmount);

// Determine the winner

if ((_player1Move == 1 && _player2Move == 3) || (_player1Move == 2 && _player2Move == 1) || (_player1Move == 3 && _player2Move == 2)) {

winner = player1;

} else if ((_player2Move == 1 && _player1Move == 3) || (_player2Move == 2 && _player1Move == 1) || (_player2Move == 3 && _player1Move == 2)) {

winner = player2;

} else {

winner = address(0);

}

gameOver = true;

}

function claimWinnings() public {

require(gameOver, "The game is not over yet.");

require(msg.sender == winner, "Only the winner can claim the winnings.");

winner.transfer(2 * betAmount);

gameOver = false;

}

}

  

📝 📜 ⏱️ ⬆️