Skip to content

Commit

Permalink
Dojo Onchain Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AkankshaAttavar committed Jun 23, 2024
1 parent 86ec7e1 commit 5c27311
Show file tree
Hide file tree
Showing 74 changed files with 66,329 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Onchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DojoTutorial

## Smart contract

- url: https://drive.google.com/file/d/1VVLPm_jGUghxTgoB4lVKL7wid1cI5TaA/view?usp=drive_link

# Unity

- uri: https://drive.google.com/file/d/1VhxnXo1oYXwQelV4D5Eb9JaphCBP6m4V/view?usp=drive_link
Binary file added Onchain/assets/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Onchain/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Onchain/contract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset=".github/mark-dark.svg">
<img alt="Dojo logo" align="right" width="120" src=".github/mark-light.svg">
</picture>

<a href="https://twitter.com/dojostarknet">
<img src="https://img.shields.io/twitter/follow/dojostarknet?style=social"/>
</a>
<a href="https://github.com/dojoengine/dojo">
<img src="https://img.shields.io/github/stars/dojoengine/dojo?style=social"/>
</a>

[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.gg/PwDa2mKhR4)
[![Telegram Chat][tg-badge]][tg-url]

[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fdojoengine
[tg-url]: https://t.me/dojoengine

# Dojo Starter: Official Guide

The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo provable game up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world.

Read the full tutorial [here](https://book.dojoengine.org/tutorial/dojo-starter#hello-dojo)

---

## Contribution

This starter project is a constant work in progress and contributions are greatly appreciated!

1. **Report a Bug**

- If you think you have encountered a bug, and we should know about it, feel free to report it [here](https://github.com/dojoengine/dojo-starter/issues) and we will take care of it.

2. **Request a Feature**

- You can also request for a feature [here](https://github.com/dojoengine/dojo-starter/issues), and if it's viable, it will be picked for development.

3. **Create a Pull Request**
- It can't get better then this, your pull request will be appreciated by the community.

Happy coding!
22 changes: 22 additions & 0 deletions Onchain/contract/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "dojo"
version = "0.6.0"
source = "git+https://github.com/dojoengine/dojo?tag=v0.7.0-alpha.5#328004d65bbbf7692c26f030b75fa95b7947841d"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_plugin"
version = "0.3.11"
source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7d8aa29a92062fcb9e6659"

[[package]]
name = "dojo_starter"
version = "0.6.0"
dependencies = [
"dojo",
]
40 changes: 40 additions & 0 deletions Onchain/contract/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
cairo-version = "2.5.4"
name = "dojo_starter"
version = "0.6.0"

[cairo]
sierra-replace-ids = true

[scripts]
migrate = "sozo build && sozo migrate apply && ./scripts/default_auth.sh"
spawn = "./scripts/spawn.sh"
move = "./scripts/move.sh"

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.7.0-alpha.5" }

[[target.dojo]]

[tool.dojo]
initializer_class_hash = "0xbeef"

[tool.dojo.env]
rpc_url = "https://api.cartridge.gg/x/briansin/katana"
# Default account for katana with seed = 0
account_address = "0x7226d3d1659d654c1c43893c037b5eb041e738fa47d51c5f2560519469f46bd"
private_key = "0x66afda4477f5692b46b57894c0a71bedab32b070f7e902e64bc16e20d176fa"
world_address = "0x0559e9e223d83b6a3121ba33b1339323a3bdf4c7c302078fb3e755fddc68a2fb" # Update this line with your world address

[tool.dojo.world]
name = "Dojo starter"
description = "The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo Autonomous World up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world."
cover_uri = "file://assets/cover.png"
icon_uri = "file://assets/icon.png"
website = "https://github.com/dojoengine/dojo-starter"

[tool.dojo.world.socials]
x = "https://x.com/ohayo_dojo"
discord = "https://discord.gg/FB2wR6uF"
github = "https://github.com/dojoengine/dojo-starter"
telegram = "https://t.me/dojoengine"
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using System.Threading.Tasks;
using Dojo;
using Dojo.Starknet;
using UnityEngine;
using dojo_bindings;

// System definitions for `dojo_starter::systems::actions::actions` contract
public class Actions : MonoBehaviour {
// The address of this contract
public string contractAddress;


// Call the `dojo_resource` system with the specified Account and calldata
// Returns the transaction hash. Use `WaitForTransaction` to wait for the transaction to be confirmed.
public async Task<FieldElement> dojo_resource(Account account) {
return await account.ExecuteRaw(new dojo.Call[] {
new dojo.Call{
to = contractAddress,
selector = "dojo_resource",
calldata = new dojo.FieldElement[] {

}
}
});
}



// Call the `dojo_init` system with the specified Account and calldata
// Returns the transaction hash. Use `WaitForTransaction` to wait for the transaction to be confirmed.
public async Task<FieldElement> dojo_init(Account account) {
return await account.ExecuteRaw(new dojo.Call[] {
new dojo.Call{
to = contractAddress,
selector = "dojo_init",
calldata = new dojo.FieldElement[] {

}
}
});
}



// Call the `spawn` system with the specified Account and calldata
// Returns the transaction hash. Use `WaitForTransaction` to wait for the transaction to be confirmed.
public async Task<FieldElement> spawn(Account account) {
return await account.ExecuteRaw(new dojo.Call[] {
new dojo.Call{
to = contractAddress,
selector = "spawn",
calldata = new dojo.FieldElement[] {

}
}
});
}



// Call the `place_tile` system with the specified Account and calldata
// Returns the transaction hash. Use `WaitForTransaction` to wait for the transaction to be confirmed.
public async Task<FieldElement> place_tile(Account account, ushort x, ushort y) {
return await account.ExecuteRaw(new dojo.Call[] {
new dojo.Call{
to = contractAddress,
selector = "place_tile",
calldata = new dojo.FieldElement[] {
new FieldElement(x).Inner,
new FieldElement(y).Inner
}
}
});
}

}

26 changes: 26 additions & 0 deletions Onchain/contract/bindings/unity/Models/Block.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;


// Model definition for `dojo_starter::models::block::Block` model
public class Block : ModelInstance {
[ModelField("gameId")]
public uint gameId;

[ModelField("x")]
public ushort x;

[ModelField("y")]
public ushort y;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

37 changes: 37 additions & 0 deletions Onchain/contract/bindings/unity/Models/Counter.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;

// Type definition for `core::byte_array::ByteArray` struct
[Serializable]
public struct ByteArray {
public string[] data;
public FieldElement pending_word;
public uint pending_word_len;
}

// Type definition for `core::option::Option::<core::integer::u32>` enum
public abstract record Option<A>() {
public record Some(A value) : Option<A>;
public record None() : Option<A>;
}


// Model definition for `dojo_starter::models::counter::Counter` model
public class Counter : ModelInstance {
[ModelField("entityId")]
public uint entityId;

[ModelField("counter")]
public uint counter;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

33 changes: 33 additions & 0 deletions Onchain/contract/bindings/unity/Models/Game.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;

// Type definition for `dojo_starter::models::game::GameStatus` enum
public abstract record GameStatus() {
public record Lobby() : GameStatus;
public record InProgress() : GameStatus;
public record Over() : GameStatus;
}


// Model definition for `dojo_starter::models::game::Game` model
public class Game : ModelInstance {
[ModelField("player")]
public FieldElement player;

[ModelField("entityId")]
public uint entityId;

[ModelField("status")]
public GameStatus status;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

26 changes: 26 additions & 0 deletions Onchain/contract/bindings/unity/Models/Health.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;


// Model definition for `dojo_starter::models::health::Health` model
public class Health : ModelInstance {
[ModelField("entityId")]
public FieldElement entityId;

[ModelField("gameId")]
public uint gameId;

[ModelField("health")]
public ushort health;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

23 changes: 23 additions & 0 deletions Onchain/contract/bindings/unity/Models/Player.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;


// Model definition for `dojo_starter::models::player::Player` model
public class Player : ModelInstance {
[ModelField("player")]
public FieldElement player;

[ModelField("score")]
public ulong score;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

32 changes: 32 additions & 0 deletions Onchain/contract/bindings/unity/Models/Skill.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Generated by dojo-bindgen on Sat, 22 Jun 2024 20:40:02 +0000. Do not modify this file manually.
using System;
using Dojo;
using Dojo.Starknet;


// Model definition for `dojo_starter::models::skill::Skill` model
public class Skill : ModelInstance {
[ModelField("entityId")]
public FieldElement entityId;

[ModelField("gameId")]
public uint gameId;

[ModelField("attack")]
public ushort attack;

[ModelField("strongAttack")]
public ushort strongAttack;

[ModelField("healing")]
public ushort healing;

// Start is called before the first frame update
void Start() {
}

// Update is called once per frame
void Update() {
}
}

Loading

0 comments on commit 5c27311

Please sign in to comment.