xiaohongshu
xiaohongshu
dojo-events
Use when subscribing to game events and tracking tokens in dojo.js. Triggers: subscribe events, game events, token balance, event query, achievements, event subscription, onTokenBalanceUpdated, activity tracking
Full skill instructions
Use this skill when:
import { ToriiQueryBuilder } from "@dojoengine/sdk";
import { useDojoSDK } from "@dojoengine/sdk/react";
const { sdk } = useDojoSDK();
const [initialEvents, subscription] = await sdk.subscribeEventQuery({
query: new ToriiQueryBuilder<typeof schema>()
.addEntityModel("game-GameEvent")
.withLimit(100),
callback: ({ data, error }) => {
if (error) {
console.error("Event error:", error);
return;
}
console.log("New event:", data);
}
});
// Process initial events
initialEvents.items.forEach(event => {
console.log(event.models.game.GameEvent);
});
// Cleanup
subscription.cancel();
const events = await sdk.getEventMessages({
query: new ToriiQueryBuilder<typeof schema>()
.addEntityModel("game-PlayerAction")
.addOrderBy("game-PlayerAction.timestamp", "Desc")
.withLimit(50)
});
const [balances, subscription] = await sdk.subscribeTokenBalance({
// Contract addresses must be full hex strings with 0x prefix
contractAddresses: ["0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"],
accountAddresses: [playerAddress],
callback: (balance) => {
console.log("Balance updated:", balance.balance);
}
});
// Initial balances
balances.items.forEach(b => {
console.log(`Token: ${b.token_id}, Balance: ${b.balance}`);
});
const balances = await sdk.getTokenBalances({
contractAddresses: ["0x..."],
accountAddresses: [playerAddress],
pagination: { limit: 100 }
});
const subscription = await sdk.onTokenBalanceUpdated({
contractAddresses: ["0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"],
accountAddresses: [playerAddress],
// Empty array for all tokens (ERC20); for ERC721 use specific IDs: ["0x1", "0x2"]
tokenIds: [],
callback: (balance) => {
updateUI(balance);
}
});
const [transfers, subscription] = await sdk.subscribeTokenTransfer({
contractAddresses: ["0x..."],
accountAddresses: [playerAddress],
callback: (transfer) => {
console.log(`Transfer: ${transfer.from} -> ${transfer.to}`);
}
});
// Get tokens
const tokens = await sdk.getTokens({
contractAddresses: ["0x..."],
pagination: { limit: 100 }
});
// Get token contracts
const contracts = await sdk.getTokenContracts({
contractTypes: ["ERC20", "ERC721"]
});
// Get achievements
const achievements = await sdk.getAchievements({
worldAddresses: [worldAddress],
namespaces: ["game"]
});
// Get player achievements
const playerAchievements = await sdk.getPlayerAchievements({
playerAddresses: [playerAddress]
});
// Subscribe to achievement progress
const subscription = await sdk.onAchievementProgressionUpdated({
worldAddresses: [worldAddress],
playerAddresses: [playerAddress],
callback: (progression) => {
console.log("Achievement progress:", progression);
}
});
// Get activities
const activities = await sdk.getActivities({
world_addresses: [worldAddress],
namespaces: ["game"],
caller_addresses: [playerAddress]
});
// Subscribe to activities
const subscription = await sdk.onActivityUpdated(
[worldAddress],
["game"],
[playerAddress],
(activity) => {
console.log("New activity:", activity);
}
);
// Get aggregated data
const aggregations = await sdk.getAggregations({
aggregator_ids: ["total_players", "total_games"],
pagination: { limit: 10 }
});
// Subscribe to aggregation updates
const subscription = await sdk.onAggregationUpdated(
["total_players"],
null,
(aggregation) => {
console.log("Aggregation updated:", aggregation);
}
);
// Update token balance subscription
await sdk.updateTokenBalanceSubscription({
subscription,
contractAddresses: newContracts,
accountAddresses: newAccounts,
tokenIds: []
});
// Update entity subscription
await sdk.updateEntitySubscription(
subscription,
newClause
);
For complex async state:
import { createEventQueryAtom, createEventUpdatesAtom } from "@dojoengine/react/effect";
// One-time event query
const eventsAtom = createEventQueryAtom(runtime, query);
// Live event updates
const updatesAtom = createEventUpdatesAtom(runtime, clauses);
// Combined query + updates
const liveEventsAtom = createEventQueryWithUpdatesAtom(runtime, query, clauses);
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience