0x0df75087…7bb9sent to0xb7278a61…e575·#24,390,298·view on Etherscan
# v0.1.0
# { "Depends": "py-genlayer:latest" }
from genlayer import *
class FootballScore(gl.Contract):
team1_score: u256 = 0
team2_score: u256 = 0
match_active: bool = False
def __init__(self):
pass # No init params
@gl.public.view
def get_scores(self) -> str:
return f"{self.team1_score}-{self.team2_score}"
@gl.public.write
def goal_team1(self) -> None:
if not self.match_active:
gl.revert("Match not started")
self.team1_score += 1
@gl.public.write
def goal_team2(self) -> None:
if not self.match_active:
gl.revert("Match not started")
self.team2_score += 1
@gl.public.write
def start_match(self) -> None:
self.match_active = True
self.team1_score = 0
self.team2_score = 0
@gl.public.write
def end_match(self) -> None:
self.match_active = False