Home

Awesome

RYO

Roll Your Own - A Dope Wars open universe project.

A modular game engine architecture for the StarkNet L2 roll-up, where computation is cheap and new game styles are being explored. Roll your own module and join the ecosystem.

What

A community-driven collection of contracts that allows sharing of game states between different game modules. Games all fit within the Dope Wars ecosystem, which is an open-ended project where anyone can add something for the community to enjoy.

Design a new game module that interests you. Call other modules and read their state to create composable game interactions. Create new artefacts that other future modules can use.

Games can pull inspiration from the DOPE ERC721 NFT on Mainnet, the item-equipped Hustler ERC1155 characters on Optimism, or other community ideas that are fun.

Some modules are outlines waiting to be explored and expanded. The first module is an implementation of the Drug Wars drug arbitrage game on TI-83-era calculators.

History:

From there the idea evolved to be a system where, just like the open-ended nature of the DOPE NFT, anyone can come and build what they like. To achieve that, the modules are able to read from each other by using a central coordinator contract. There is even the possibility to have contracts grant write access to each other, potentially though a governance process.

Join in

Everyone is welcome to join in:

The modules here are by their nature experimental and assumed to be broken by default. The goal is to have fun exploring new ideas. As modules mature, they might be suitable to be slotted into the front end game, where players can use their characters. For example, a player might go to a payphone and partake in Module 01 to make a drug trade (single transaction), then go to a car park and start a fight using Module 08 (open channel with a single transaction).

Game modules can take any form, and if revenue is generated, there is a cultural norm to direct 5% to the DOPE DAO. If the community likes your idea, perhaps the DOPE DAO might vote to support you in your efforts!

System architecture

Modules can exist in isolation, or they can read or even write to other modules.

The game mechanics are separated from the game state variables. A controller system manages a mapping of modules to deployed addresses and a governance module may update the controller.

For example all these modules could read and write from the state modules and be connected-but-distinct game interactions:

Contract hierarchy

It is also worth pointing out that StarkNet has account abstraction (see background notes here). This means that transactions are actioned by sending a payload to a personal Account contract that holds your public key. The contract checks the payload and forwards it on to the destination.

For more information see

Status

ModuleDescriptionStatus
01 DopeWarsSelf-contained Drug Game with random hazardsNeeds event/item effect paramater tweaks and improved call to user-registry
02 LocationOwnedStorage for module 01 dealer drug quantitiesFunctional. Can adjust initial values for different 'vibes'.
03 UseOwnedStorage for module 01 player drug quantitiesFunctional
04 UserRegistryStores cross-chain NFT ownershipNeeds implementation of storage/input mechanism (E.g., storage proofs later if available)
05 CombatKing-of-the-hill fights from pre-planned movesNeeds design of combat data structure and calculations
06 DrugLordStorage for module 05 winnersFunctional
07 PseudoRandomSource of pRandom numbersReady for low importance uses
08 StateChannel1v1 move-by-move off chain gameNeeds design of data structure for messages
09 WallStore and vote on text 'graffiti'Needs testing, could bve expanded.
10 ReportCardToken that represents player performanceIdea only, no code. Likely suitable as ERC1155
11 BellLabsA three-axis scoring system for dope elementsBoiler-plate code and ideas only. Needs design/setting of values for each item on each axis
AccountIdentity/contract/wallet for each userRegularly refresh from OpenZepellin's latest
ArbiterCan tell the module controller that one module has write access over anotherMight be good to upgrade this to a governance contract to vote through write access changes
ModuleControllerKeeps module addresses so they can read or even write to each otherFunctional. Can add new modules to initial module addresses set function

Setup

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

git clone git@github.com:dopedao/RYO.git
cd RYO
bin/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: 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/01_DopeWars.cairo

Test

Run all github actions tests: bin/test

Run individual tests

bin/shell pytest -s testing/01_DopeWars_contract_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.

bin/deploy

Next steps

Welcome: