Step 1 - Install repo dependencies
The CLI package is in this monorepo. Until npm publishing is confirmed, use the repo-local toolchain.
git clone https://github.com/trillskillz/KasGraph
cd KasGraph
npm install
npm run typecheck
npm testtutorial
A local-first walkthrough for defining, building, deploying, indexing, and querying a simple KRC-style subgraph without pretending hosted commands exist before validation.
The CLI package is in this monorepo. Until npm publishing is confirmed, use the repo-local toolchain.
git clone https://github.com/trillskillz/KasGraph
cd KasGraph
npm install
npm run typecheck
npm testThis command is implemented and scaffolds manifest, schema, mapping, and README files.
npx kasgraph init krc20-tracker
cd krc20-trackerEdit schema.graphql to model the application data you want to query.
type Token @entity {
id: ID!
ticker: String!
totalSupply: BigInt!
holdersCount: Int!
}
type Holder @entity {
id: ID!
token: Token!
balance: BigInt!
}
type Transfer @entity {
id: ID!
token: Token!
from: String
to: String
amount: BigInt!
txHash: String!
}The scaffolded mapping is editable. This transfer handler is a tutorial preview, not a copied production handler.
// Preview mapping shape. Adjust handler names to match your manifest.
export function handleTransfer(event: Krc20Transfer): void {
const token = Token.load(event.ticker) ?? new Token(event.ticker);
token.ticker = event.ticker;
const from = event.from ? loadHolder(event.ticker, event.from) : null;
const to = loadHolder(event.ticker, event.to);
if (from) from.balance = from.balance.minus(event.amount);
to.balance = to.balance.plus(event.amount);
token.save();
from?.save();
to.save();
}Generate TypeScript types and compile the AssemblyScript mapping to WASM.
npx kasgraph codegen
npx kasgraph buildDirect database deployment is implemented. Hosted-node deployment also exists behind --node once a node is available.
# Direct local registry write, requires Postgres.
npx kasgraph deploy --database-url "$DATABASE_URL"
npx kasgraph status krc20-trackerThere is no implemented kasgraph index CLI command yet; run the Rust node with the documented environment variables.
DATABASE_URL="$DATABASE_URL" \
KASGRAPH_INGEST_MODE=continuous \
KASGRAPH_NOTIFICATION_WS_URL=wss://your-kaspa-node/wrpc/json \
KASGRAPH_RELOAD_INTERVAL_SECS=30 \
cargo run -p kasgraph-nodeRun the API/gateway against the same Postgres-backed registry, then query the generated schema.
query {
tokens(first: 10) {
id
ticker
holdersCount
totalSupply
}
}Use the operational CLI for public API status, latest POI checkpoint, and database counts. Range verification remains pending.
# POI inspection is implemented in the core verifier/checkpoint path.
# Latest checkpoint inspection is available against Postgres.
npx kasgraph poi latest --database-url "$DATABASE_URL"
npx kasgraph db stats --database-url "$DATABASE_URL" --json
npx kasgraph health --node http://localhost:4000