Get up and running with the DEMOS SDK in under 5 minutes. This tutorial walks you through installation, wallet setup, and your first blockchain queries.
This guide will have you connected to the DEMOS Network and querying the blockchain in just a few minutes.
1
Install the SDK
Add the DEMOS SDK to your project using bun (recommended):
bun add @kynesyslabs/demosdk@latest
For browser environments, you’ll need Buffer polyfills. See Getting Started for Vite configuration.
2
Create a Wallet
Generate a new wallet with a mnemonic seed phrase:
import { Demos } from "@kynesyslabs/demosdk/websdk"const demos = new Demos()// Generate a new mnemonic (save this securely!)const mnemonic = demos.newMnemonic()console.log("Your mnemonic:", mnemonic)// Connect using the mnemonicconst publicKey = await demos.connectWallet(mnemonic, { algorithm: "ed25519",})console.log("Your public key:", publicKey)
Security: Never share your mnemonic. Store it securely - it controls access to all your keys.
3
Connect to the Network
Connect to a DEMOS RPC node:
await demos.connect("https://node2.demos.sh")if (demos.connected) { console.log("Connected to DEMOS Network!")}
4
Query the Blockchain
Now you can read data from the blockchain:
// Get the latest block numberconst blockNumber = await demos.getLastBlockNumber()console.log("Latest block:", blockNumber)// Get the latest block hashconst blockHash = await demos.getLastBlockHash()console.log("Latest block hash:", blockHash)// Get your wallet infoconst address = demos.getAddress()const addressInfo = await demos.getAddressInfo(address)console.log("Your wallet info:", addressInfo)
5
Sign a Message
Test your wallet by signing and verifying a message: