Loading...
Loading...
Set up and configure Torii indexer for GraphQL queries, gRPC subscriptions, and SQL access. Use when indexing your deployed world for client queries or real-time updates.
npx skill4agent add dojoengine/book dojo-indexertorii --world <WORLD_ADDRESS>http://localhost:8080/graphqlhttp://localhost:8080torii --world <WORLD_ADDRESS> --indexing.controllerstorii --world <WORLD_ADDRESS> --db-dir ./torii-db --indexing.controllershttp://localhost:8080/graphqlentitiesmodelstransactions{modelName}ModelspositionModelsmovesModelsquery {
movesModels {
edges {
node {
player
remaining
last_direction
}
}
}
}query {
models {
edges {
node {
id
name
classHash
contractAddress
}
}
totalCount
}
}query {
entities(first: 10) {
edges {
cursor
node {
id
}
}
pageInfo {
hasNextPage
endCursor
}
}
}query {
entities(first: 10, after: "cursor_value") {
edges {
cursor
node { id }
}
}
}query {
entities(offset: 20, limit: 10) {
edges {
node { id }
}
totalCount
}
}subscription {
entityUpdated(id: "0x54f58...") {
id
updatedAt
models {
__typename
... on Position {
vec {
x
y
}
}
... on Moves {
remaining
}
}
}
}subscription {
eventEmitted {
id
keys
data
transactionHash
}
}subscription {
modelRegistered {
id
name
namespace
}
}sqlite3 torii.db-- Count entities
SELECT COUNT(*) FROM entities;
-- Custom aggregations
SELECT AVG(value) FROM model_data WHERE model_name = 'Health';import { createClient } from '@dojoengine/torii-client';
const client = await createClient({
rpcUrl: "http://localhost:5050",
toriiUrl: "http://localhost:8080",
worldAddress: WORLD_ADDRESS,
});
// Query entities
const positions = await client.getEntities({
model: "Position",
limit: 10
});
// Subscribe to updates
await client.onEntityUpdated(
[{ model: "Position", keys: [playerId] }],
(entity) => console.log("Position updated:", entity)
);import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
uri: 'http://localhost:8080/graphql',
cache: new InMemoryCache(),
});
const { data } = await client.query({
query: gql`
query GetMoves {
movesModels {
edges {
node {
player
remaining
}
}
}
}
`
});| Option | Description | Default |
|---|---|---|
| World contract address | Optional (since Torii 1.6.0) |
| RPC endpoint URL | |
| Database directory | In-memory |
| Path to TOML configuration file | None |
| CORS origins | |
# torii.toml
world_address = "<WORLD_ADDRESS>"
rpc = "<RPC_URL>"
[indexing]
controllers = trueslot auth login
slot deployments create <PROJECT_NAME> torii --config torii.toml --version <DOJO_VERSION># Stream logs
slot deployments logs <PROJECT_NAME> torii -f
# Delete and recreate (safe — all data is on-chain)
slot deployments delete <PROJECT_NAME> toriikatana --dev --dev.no-feesozo build && sozo migratetorii --world <WORLD_ADDRESS> --http.cors_origins "*"entitiesdojo-client