Skip to content

Latest commit

 

History

History
 
 

game_utils

Discord Twitter

This is an image

🎮 Game Utils

Game Utils - A collection of game utilities built on StarkNet.

This folder has a collection of reusable utility contracts for on-chain games (e.g. Desiege).

This folder contains Game Utility contracts. If you're looking for another contract, please see the directory of our Realms Smart Contracts.

Utility contract overview

Module Function Current Status
game_structs Structs for desiege Shields In review
grid_position Converts a felt into a 2D grid In review
open_simplex A gradient noise function In review

Understanding the code

🤔 What are these utils?

🏗️ System architecture
  • TODO: Add system architecture here
📦 Contract hierarchy

  • TODO: Add contract heirarchy here


Getting Setup

Initial Setup

Clone this repo and use our docker shell to interact with starknet:

git clone git@github.com:BibliothecaForAdventurers/realms-contracts.git
cd realms-contracts
scripts/shell starknet --version

The CLI allows you to deploy to StarkNet and read/write to contracts already deployed. The CLI communicates with a server that StarkNet runs, which bundles the requests, executes the program (contracts are Cairo programs), creates and aggregates validity proofs, then posts them to the Goerli Ethereum testnet. Learn more in the Cairo language and StarkNet docs here, which also has instructions for manual installation if you are not using docker.

Development Workflow

If you are using VSCode, we provide a development container with all required dependencies. When opening VS Code, it should ask you to re-open the project in a container, if it finds the .devcontainer folder. If not, you can open the Command Palette (cmd + shift + p), and run “Remote-Containers: Rebuild and Reopen in Container”.

Outline

Flow:

  1. Compile the contract with the CLI
  2. Test using pytest
  3. Deploy with CLI
  4. Interact using the CLI or the explorer

Compile

The compiler will check the integrity of the code locally. It will also produce an ABI, which is a mapping of the contract functions (used to interact with the contract).

Compile all contracts:

nile compile

Compile an individual contract:

nile compile contracts/game_utils/grid_position.cairo

Test

Run all github actions tests: scripts/test

Run individual tests

scripts/shell pytest -s contracts/game_utils/grid_position_test.py

Deploy

Start up a local StarkNet devnet with:

nile node

Then run the deployment of all the contracts. This uses nile and handles passing addresses between the modules to create a permissions system.

scripts/deploy

Contributing

Modules in progress
  • TODO: Add modules in progress here
How to Contribute

We encourage pull requests!

  1. Create an issue to describe the improvement you're making. Provide as much detail as possible in the beginning so the team understands your improvement.
  2. Fork the repo so you can make and test changes in your local repository.
  3. Test your changes Follow the procedures for testing in each contract sub-directory (e.g. /contracts/settling_game and make sure your tests (manual and/or automated) pass.
  4. Create a pull request and describe the changes you made. Include a reference to the Issue you created.
  5. Monitor and respond to comments made by the team around code standards and suggestions. Most pull requests will have some back and forth.

If you have further questions, visit #builders-chat in our discord and make sure to reference your issue number.

Thank you for taking the time to make our project better!


External Reading Sources

StarkNet is very new. Best practices are being discovered. We have amalgamated the best resources we think to guide you on your journey.

Guides & Docs
Discords to Join

Realms Repositories

The Realms Settling Game spans a number of repositories:

View the list of repositories in /README.md