Skip to content

ethtaipei-footballmanager/smartcontracts-taipei

Repository files navigation

Ten Taipei Football Manager

logo

⚽ Ten Taipei Football Manager is an on-chain football manager game that leverages the privacy that TEN Protocol provides to hide players' strategies from opponents.

** This project is build using frontend components from a previous hackathon project Super Leo Lig. All smart contracts and contract interactions are created from scratch during this hackathon.

⚙️ Built using Solidity, Hardhat, wagmi, React and Javascript.

  • 🧾 Privacy on TEN: Players commit to a strategy privately using TEN Protocol.
  • ⛓️ Smart contracts: Verifies strategies and results of the game.
  • ⏱️ Timelock funds: The wagered amount is secured by a timelock, to prevents ghosting by losing players.
  • 🖼️ Frontend: Results are generated in the browser based on strategies.

Contents

Game flow

The game has 3 main steps:

1: proposeGame

To start a new game, a challenger calls this functions with 3 parameters:

  • opponent (address): Address of the opponent
  • wagerAmount (uint256): Amount to be wagered in gwei
  • formation (uint256): Array of player_id's

This function creates a game object and stores it in a mapping by gameId. The formation is is stored privately in a seperate mapping.

2: acceptGame

To accept a game, an opponent calls this functions with 2 parameters:

  • gameId (uint256): Unique id for the game
  • formation (uint256): Array of player_id's This function publicly stored the opponent's formation in the games mapping.

3: revealOutcome

Challenger calls this function to settle a game. The function takes 1 input

  • gameId (uint256): Unique id for the game

This function reveals challenger formation, determines the outcome and pays out the winner.

3b: revealOutcome

Opponent calls this function to settle a game if the challenger does not call revealOutcome within the timelimit. The function takes 1 input

  • gameId (uint256): Unique id for the game

This function is only available after X blocks have passed since acceptGame was executed. It pays out the wagered amounts to the opponent, punishing the challenger for ghosting.

Scripts

To test the smart contract interactions via a script, execute these scripts: /scripts/loadPlayers.js - run once to load player profiles for 6 teams. /scripts/gameFlow.js - run to test a game of two identical teams matched against eachother.

Deployed contracts

  • TEN deployed contract 0x40B10e8A06fBE442D82Eda1D547A278Ce372CA9A in tx 0xec761365ad14fca87c5dcbbe08a781b4bebe971bf88923e1ee5903fd4ad39fe0 ten token old 0x479a15a13358561c3fe9B982b69c3da191aB4F92 ten token new 0x7d671aed0E98286525a94b2F56422375EFc79886 ten new 0xA8FCcd8B3b0e5b68E9171585fF6b2D514dc2e3a2
  • Scroll
  • Linea
  • Optimism
  • Polygon zkEVM cardona
  • Thundercore

Links

Team

This project was build at EthTaipei 2024 by: