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.
The Dojo Starter contains the minimum required code to bootstrap your Dojo Autonomous World. This starter package is included in the dojoup
binary. For more detailed instructions, please refer to the official Dojo Book here.
Follow the steps below to setup and run your first Autonomous World.
Start by installing dojoup
. This cli tool is a critical component when building with Dojo. It manages dependencies and helps in building your project. Run the following command in your terminal:
curl -L https://install.dojoengine.org | bash
dojoup
The command downloads the dojoup
installation script and executes it.
The next step is to clone the repository to your local machine. Open your terminal and type the following command:
git clone https://github.com/dojoengine/dojo-starter.git && cd dojo-starter
This command will create a local copy of the Dojo Starter repository and enter the project directory.
With dojoup
installed, you can now build your example world using the following command:
sozo build
This command compiles your project and prepares it for execution.
Katana RPC is the communication layer for your Dojo World. It allows different components of your world to communicate with each other. To start Katana RPC, use the following command:
katana --allow-zero-max-fee
Finally, deploy your world using the sozo migrate
command. This command, deploys your world to Katana!
sozo migrate
Congratulations! You've successfully setup and deployed your first Dojo Autonomous World.
Explore and interact with your locally deployed world! This guide will help you fetch schemas, inspect entities, and execute actions using sozo
.
If you have followed the example exactly and deployed on Katana, you can use the world address generated to either:
-
use as an argument to
--world
when callingsozo
commands -
add it to Scarb.toml under
[tool.dojo.env]
table like so[tool.dojo.env] world_address = "<world_address>"
-
set it as an environment variable
export DOJO_WORLD_ADDRESS="<world_address>"
Let's start by fetching the schema for the Moves
component. Use the following command
sozo component schema Moves
You should get this in return:
struct Moves {
remaining: u8
}
This structure indicates that the Moves
component keeps track of the remaining moves as an 8-bit unsigned integer.
Let's check the remaining moves for an entity. In our examples, the entity is based on the caller address, so we'll use the address of the first Katana account as an example.
sozo component entity Moves 0x03ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0
If you haven't made an entity yet, it will return 0
.
No entity? No problem! You can add an entity to the world by executing the spawn
system. Remember, there's no need to pass any call data as the system uses the caller's address for the database.
sozo execute spawn
After adding an entity, let's refetch the remaining moves with the same command we used earlier:
sozo component entity Moves 0x03ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0
We can get the same results by executing this command
sozo component entity Moves --world <WORLD_ADDRESS> 0x03ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0
Congratulations! You now have 10
remaining moves! You've made it this far, keep up the momentum and keep exploring your world!
Make sure to read the Offical Dojo Book for detailed instructions including theory and best practices.
Your contributions are always welcome and appreciated. Following are the things you can do to contribute to this project:
-
Report a Bug
- If you think you have encountered a bug, and we should know about it, feel free to report it here and we will take care of it.
-
Request a Feature
- You can also request for a feature here, and if it's viable, it will be picked for development.
-
Create a Pull Request
- It can't get better then this, your pull request will be appreciated by the community.
For any other questions, feel free to reach out to us here.
Happy coding!