xiaohongshu
xiaohongshu
dojo-transactions
Use when executing game actions and sending transactions in dojo.js. Triggers: send transaction, execute action, dojo action, contract call, DojoProvider, execute, sendMessage, batch transaction, invoke
Full skill instructions
Use this skill when:
Execute contract calls using the DojoProvider:
import { useDojoSDK } from "@dojoengine/sdk/react";
import { useAccount } from "@starknet-react/core";
function GameActions() {
const { provider } = useDojoSDK();
const { account } = useAccount();
const spawn = async () => {
const tx = await provider.execute(
account,
{
contractName: "actions",
entrypoint: "spawn",
calldata: []
},
"game" // namespace
);
console.log("Transaction hash:", tx.transaction_hash);
};
const move = async (direction: number) => {
const tx = await provider.execute(
account,
{
contractName: "actions",
entrypoint: "move",
calldata: [direction]
},
"game"
);
};
}
Execute multiple calls in a single transaction:
const executeBatch = async () => {
const tx = await provider.execute(
account,
[
{
contractName: "actions",
entrypoint: "collect_resources",
calldata: []
},
{
contractName: "actions",
entrypoint: "build_structure",
// Calldata must match contract ABI types (u32, felt252, etc.)
calldata: [structureType, x, y]
}
],
"game"
);
};
Send signed messages without on-chain transactions:
const { sdk } = useDojoSDK();
// Generate typed data
const typedData = sdk.generateTypedData(
"game-Move", // namespace-ModelName
{
player: account.address,
direction: 1,
timestamp: Date.now()
}
);
// Send signed message
const result = await sdk.sendMessage(typedData, account);
if (result.isOk()) {
console.log("Message sent:", result.value);
} else {
console.error("Failed:", result.error);
}
const messages = [
sdk.generateTypedData("game-Move", { direction: 1 }),
sdk.generateTypedData("game-Move", { direction: 2 }),
sdk.generateTypedData("game-Move", { direction: 3 })
];
const result = await sdk.sendMessageBatch(messages, account);
async function executeWithOptimism(action: string, calldata: any[]) {
const { provider, useDojoStore } = useDojoSDK();
const store = useDojoStore.getState();
const transactionId = `${action}-${Date.now()}`;
// Apply optimistic update - draft is a mutable copy of your store state
store.applyOptimisticUpdate(transactionId, (draft) => {
// Example: update player position optimistically
const player = draft.entities[account.address];
if (player?.models?.game?.Position) {
player.models.game.Position.x = newX;
player.models.game.Position.y = newY;
}
});
try {
const tx = await provider.execute(
account,
{ contractName: "actions", entrypoint: action, calldata },
"game"
);
// Wait for transaction to be accepted
await account.waitForTransaction(tx.transaction_hash);
store.confirmTransaction(transactionId);
} catch (error) {
store.revertOptimisticUpdate(transactionId);
throw error;
}
}
const { provider } = useDojoSDK();
// Call view function
const result = await provider.call(
"game", // namespace
{
contractName: "actions",
entrypoint: "get_player_stats",
calldata: [playerAddress]
}
);
DojoProvider generates typed methods from your manifest.json at initialization. Available methods correspond to your contract's systems - check your manifest or use TypeScript autocomplete to discover them.
// Methods are generated based on your contract definitions in manifest.json
// If your contract has a "spawn" system, you can call it directly:
const tx = await provider.spawn(account);
// For actions with arguments:
const tx = await provider.move(account, { direction: 1 });
// For view functions (no account needed):
const stats = await provider.get_stats({ player: address });
const tx = await provider.execute(
account,
call,
"game",
{
maxFee: "0x1000000000", // Max fee in wei
nonce: 5, // Explicit nonce
version: 1, // Transaction version
}
);
try {
const tx = await provider.execute(account, call, "game");
await account.waitForTransaction(tx.transaction_hash);
} catch (error) {
if (error.message.includes("insufficient funds")) {
console.error("Not enough ETH for gas");
} else if (error.message.includes("nonce")) {
console.error("Nonce mismatch - retry");
} else {
console.error("Transaction failed:", error);
}
}
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