Kaspalytics Learn is a work in progress.
Updated: Aug 2, 2026

Getting Started

Install a Kaspa SDK, connect to the network, and read live DAG state from Rust, JavaScript, or Python.

The shortest path from nothing to live network data. Pick a language, install the SDK, connect, and print the tip of the DAG. No node required — the Resolver finds a public one for you.

All three SDKs are built from the same rusty-kaspa codebase, so the APIs line up almost method for method. See SDKs for what state each one is in.

1. Install

# Cargo.toml — the crates.io publications are stale, use git dependencies
[dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
kaspa-rpc-core = { git = "https://github.com/kaspanet/rusty-kaspa" }
kaspa-wrpc-client = { git = "https://github.com/kaspanet/rusty-kaspa" }
# Download kaspa-wasm32-sdk-<version>.zip from the rusty-kaspa releases page
# and unzip it into your project.
npm install websocket
pip install kaspa

The WASM zip contains nodejs/kaspa (CommonJS) and web/kaspa (ES modules) plus its own docs and examples. Grab it from the releases page.

2. Connect and read the DAG

use std::time::Duration;

use kaspa_rpc_core::api::rpc::RpcApi;
use kaspa_wrpc_client::{
    client::{ConnectOptions, ConnectStrategy},
    prelude::{NetworkId, NetworkType},
    KaspaRpcClient, Resolver, WrpcEncoding,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = KaspaRpcClient::new(
        WrpcEncoding::Borsh,
        None,                                             // url — None uses the resolver
        Some(Resolver::default()),
        Some(NetworkId::new(NetworkType::Mainnet)),
        None,                                             // subscription context
    )?;

    client
        .connect(Some(ConnectOptions {
            block_async_connect: true,
            connect_timeout: Some(Duration::from_millis(5_000)),
            strategy: ConnectStrategy::Fallback,
            ..Default::default()
        }))
        .await?;

    let info = client.get_block_dag_info().await?;
    println!("Blocks: {}", info.block_count);
    println!("Virtual DAA score: {}", info.virtual_daa_score);
    println!("Pruning point: {}", info.pruning_point_hash);

    client.disconnect().await?;
    Ok(())
}
// Node needs a W3C WebSocket shim before the SDK loads.
globalThis.WebSocket = require('websocket').w3cwebsocket;

const kaspa = require('./kaspa-wasm32-sdk/nodejs/kaspa');
const { RpcClient, Resolver } = kaspa;
kaspa.initConsolePanicHook();

(async () => {
	const rpc = new RpcClient({
		resolver: new Resolver(),
		networkId: 'mainnet'
	});

	await rpc.connect();
	console.log('Connected to', rpc.url);

	const info = await rpc.getBlockDagInfo();
	console.log('Blocks:', info.blockCount);
	console.log('Virtual DAA score:', info.virtualDaaScore);
	console.log('Pruning point:', info.pruningPointHash);

	await rpc.disconnect();
})();
import asyncio

from kaspa import Resolver, RpcClient


async def main():
    client = RpcClient(resolver=Resolver(), network_id="mainnet")
    await client.connect()

    info = await client.get_block_dag_info()
    print("Blocks:", info["blockCount"])
    print("Virtual DAA score:", info["virtualDaaScore"])
    print("Pruning point:", info["pruningPointHash"])

    await client.disconnect()


asyncio.run(main())

Run it with cargo run, node demo.js, or python demo.py. A successful run prints a DAA score in the hundreds of millions that climbs every second, and a block count in the low millions.

The block count is smaller than you might expect because it is not an all-time total. A node reports virtual DAA score − its retention root's DAA score, so a default pruning node counts only back to its pruning point — roughly the pruning depth, ~1,080,000 blocks. Only an --archival node reports a figure that tracks the whole chain.

Note the response shape differs by language: Rust returns typed structs with snake_case fields, JavaScript returns objects with camelCase keys, and Python returns dicts with camelCase keys even though its methods are snake_case.

3. In the browser

The web build has to be initialized with the WASM binary before anything else, and the page must be served over http(s)file:// cannot load WASM:

import * as kaspa from './kaspa/kaspa.js';
await kaspa.default('./kaspa/kaspa_bg.wasm');

const rpc = new kaspa.RpcClient({
	resolver: new kaspa.Resolver(),
	networkId: 'mainnet'
});
await rpc.connect();

Where to next

  • Networks — switch to testnet-10 and get free test KAS before you send anything.
  • Connecting — retry strategies, encodings, and pointing at your own node.
  • Transactions — build, sign, and submit a payment.
  • Wallet — the managed wallet, if you need accounts and persistence.
  • Run a Node — for anything security-critical, run your own.

Another language?

There are no official SDKs beyond these three. For anything else, generate a gRPC client from the proto definitions in rpc/grpc/core/protomessages.proto and rpc.proto are the two you need. Community libraries for other languages are cataloged in Developer Resources.

Kaspalytics strives to provide accurate data - our highest level of effort is given to data validation and maintenance. However, we cannot guarantee 100% accuracy. Data is subject to inaccuracies and change.

Contact | © 2026 Kaspalytics