📃Smart Contract

The Race Protocol smart contract serves as the trustless and transparent foundation for managing games and assets within the Race ecosystem. It provides a set of instructions that enable various functionalities, including game creation, player interactions, server management, and secure settlements.

Overview of Contract Functionality

The Race contract offers instructions for the following key functionalities:

  • Game Management:

    • Create Game Account: This instruction allows anyone to create a new game account on the blockchain, specifying the game title, bundle address, token used for gameplay, maximum number of players, entry type, and other game-specific data.

    • Close Game Account: This instruction allows the game owner to close an empty game account, retrieving the remaining assets and removing the game from the blockchain.

    • Register Game: This instruction allows the game owner to register their game in a public or private registration account, making it discoverable by players and servers.

    • Unregister Game: This instruction allows the game owner or the registration owner to remove a game from the associated registration account.

  • Player Interactions:

    • Create Player Profile: This instruction allows players to create their on-chain profiles, specifying their nickname and optional avatar NFT.

    • Join Game: This instruction allows players to join a game by depositing the required tokens into the game's stake account.

    • Deposit: This instruction allows players to deposit additional tokens into the game's stake account during gameplay.

  • Server Management:

    • Register Server: This instruction allows server owners to register their servers on-chain, specifying the server's endpoint and other relevant information.

    • Serve Game: This instruction allows a server to declare its intention to serve a specific game, writing its address into the game account and potentially becoming the Transactor.

    • Vote: This instruction allows players and servers to vote on the Transactor's inactivity or misbehavior, potentially triggering a game halt and requiring intervention.

  • Settlements:

    • Settle: This instruction, typically sent by the Transactor, handles the finalization of a game. It processes settlements for players, distributes winnings, handles player exits, and updates the game account with the final state and checkpoint data.

These instructions provide a comprehensive set of tools for managing the lifecycle of Race games, from creation and player interactions to server management and secure settlements.

The following sections will provide detailed descriptions of each instruction, including their specific parameters, required accounts, and expected behavior.

Last updated