daramir / starknet-onboarding

[My progress on a] collection of exercices to discover Starknet programming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Starknet Onboarding

pull requests welcome badge follow on Twitter License License

Starknet onboarding with a game

Environment setup

Prerequisites

Installation

  • protostar install
  • python -m venv env
  • source env/bin/activate
  • pip install -r requirements.txt
  • nile install

How to use this repo

Tutorial

This repo has 2 difficulty levels: beginner, advanced, and then a final exercise.

contracts<beginner/advanced>/ex contrains exercises with instructions on what to do. Run pytest tests/test_<beginner/advanced>_ex00.py and pytest tests/test_<beginner/advanced>_ex00.py and code until the tests pass.

Repeat for all contracts. Have fun !

Final execise

Deploy

First, start a local node:

nile node

Then, deploy the contracts:

nile run scripts/deploy.py

Keep the addresses of the contracts, you'll need them later.

Goal

Implement your ship to catch as much dust as possible.

Get started

To add your ship, compile it and deploy it

nile compile
nile deploy <my-ship-contract>

Then, add the ship to the game's space

nile invoke <space-contract-address> add_ship <x> <y> <ship-contract-address>

Finally, call next_turn to let the game computes the next turn

nile invoke <space-contract-address> next_turn

Testing

  • make test

Coding your ship logic can be tricky, we suggest you use tests to check your code.

You can get inspiration from the static ship tests and run this specific test with pytest tests -k "test_next_turn_with_ship".

About

[My progress on a] collection of exercices to discover Starknet programming


Languages

Language:Cairo 53.2%Language:Python 46.6%Language:Makefile 0.1%Language:Shell 0.0%