Common problems and solutions
Model Bindings
When modifying the bindings generated by Dojo, ensure that all fields in the model bindings are declared as public.
⚠️ Failing to do so can result in the values of the fields not being loaded properly.
For example:
public class RoomHero : ModelInstance {
[ModelField("room_id")]
private uint room_id; ❌
}
public class RoomHero : ModelInstance {
[ModelField("room_id")]
public uint room_id; ✅
}
By declaring fields as
public
, you ensure proper loading and access to the values within the model bindings.
Slot on Desktop
Currently, Slot functionality is not available on desktop platforms due to a server error preventing the initialization of the ToriiClient within the WorldManager component. This results in the following exception:
Exception: status: Unknown, message: "h2 protocol error: http2 error: connection error detected: frame with invalid size", details: [], metadata: MetadataMap { headers: {} }
Dojo.Torii.ToriiClient..ctor (System.String toriiUrl, System.String rpcUrl, System.String world, dojo_bindings.dojo+KeysClause[] entities) (at Assets/Dojo/Runtime/Torii/ToriiClient.cs:40)
Dojo.WorldManager.Start () (at Assets/Dojo/Runtime/WorldManager.cs:28)
💡 If you intend to use Slot, you must build the game for WebGL platform instead.
WebGL Build Errors
Encountering the following error during a WebGL build?
Here are the steps to address it:
-
Verify Dojo Template Selection:
- Navigate to
Edit > Project Settings > Player
(or directly through the Project Settings window).Example without
Dojo
template selected - Select the WebGL tab.
- Under
Resolution and Presentation
, ensure theDojo
Template is selected. - If the Dojo template is missing, proceed to
step 2
.
- Navigate to
-
Download WebGL Templates Folder: If the Dojo template is unavailable in Player Settings, it's likely missing from your project.
- Navigate to the Dojo Unity repository
- Download the
WebGL templates
folder. - Add this folder to your project's Assets directory.
-
Rebuild Your Project: After ensuring the Dojo template is selected or added, try rebuilding your project for WebGL.
Async calls not Working
If asynchronous calls to the Dojo systems are not functioning as expected, ensure that the UnityMainThreadDispatcher
is present in your scene.
return await account.ExecuteRaw(new dojo.Call[] {
new dojo.Call{...}
}
If you don't have it, add it to your scene.
The
UnityMainThreadDispatcher
can be found inAssets/Dojo/Runtime directory
.
Bingen plugin error
When executing the command
Sozo build --unity
to generate the bingens for your Unity project, you might encounter the following error:
thread 'main' panicked at crates/dojo-bindgen/src/plugins/unity/mod.rs:188:50:
called Result::unwrap() on an Err value: ConversionFailed("Can't convert token into composite, got CoreBasic(CoreBasic { type_path: \"core::starknet::contract_address::ContractAddress\" })")
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
To resolve this issue, it's recommended to upgrade your Dojo version to at least
v0.6.0
. You can achieve this by running the following command in your terminal:
dojoup --version v0.6.0
Torii Communication Error
Encountering the following error when running your Unity program?
Exception: transport error
Dojo.Torii.ToriiClient..ctor (System.String toriiUrl, System.String rpcUrl, System.String relayUrl, System.String world) (at Assets/Dojo/Runtime/Torii/ToriiClient.cs:33)
Dojo.WorldManager.Awake () (at Assets/Dojo/Runtime/WorldManager.cs:25)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <2ccb053bed3740ab940e67afec38ab31>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:153)
UnityEngine.UnitySynchronizationContext.Exec () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107)
This error message indicates that your Unity program cannot establish communication with the Torii server
.
Troubleshooting Steps:
- Verify Torii URL: Double-check the Torii URL configured in your Unity project settings.
- Confirm Torii Status: Make sure the Torii server is up and running.
Authentication Error During Transaction Execution
While executing a transaction from your Unity project, you encounter the following error in the Katana terminal:
2024-03-19T18:05:46.841197Z WARN executor: Transaction execution error: "Error in the called contract (0x00280a3deba2004bbbdb3d60a619f3059305f2399ab1e1cd630ec20249abe5fa):
Error at pc=0:4573:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:67)
Unknown location (pc=0:1835)
Unknown location (pc=0:2478)
Unknown location (pc=0:3255)
Unknown location (pc=0:3795)
Error in the called contract (0x05024efa0bbd4ec33a2f56251a5d67d8ed2b1e88cbdba566cbce6d3d757db21f):
Error at pc=0:1867:
Got an exception while executing a hint: Hint Error: Execution failed. Failure reason: 0x6e6f7420777269746572 ('not writer').
Cairo traceback (most recent call last):
Unknown location (pc=0:256)
Unknown location (pc=0:634)
Error in the called contract (0x01bf3dfc0c2b66b3d4abb47e9c8e4c5552992dbc70bb2566b9f6d6ee9b707317):
Execution failed. Failure reason: 0x6e6f7420777269746572 ('not writer').
💡Solution:
- Execute default_auth.sh: Navigate to the
src
directory within your Dojo project. Run the scriptdefault_auth
.sh using your terminal.