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.
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 |
🤔 What are these utils?
🏗️ System architecture
- TODO: Add system architecture here
📦 Contract hierarchy
- TODO: Add contract heirarchy here
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”.
Flow:
- Compile the contract with the CLI
- Test using pytest
- Deploy with CLI
- Interact using the CLI or the explorer
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
Run all github actions tests: scripts/test
Run individual tests
scripts/shell pytest -s contracts/game_utils/grid_position_test.py
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
Modules in progress
- TODO: Add modules in progress here
How to Contribute
We encourage pull requests!
- 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.
- Fork the repo so you can make and test changes in your local repository.
- 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.
- Create a pull request and describe the changes you made. Include a reference to the Issue you created.
- 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!
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
The Realms Settling Game spans a number of repositories: