Cascade
Getting Started

JavaScript/ TypeScript SDK

Overview of the @lumera-protocol/sdk-js architecture and modules.

Overview

The JavaScript/ TypeScript SDK is the primary way to interact with Cascade from web and Node.js applications. It works in Node.js v18+ as well as browsers with Keplr and Leap wallets. File operations are routed through SN-API Supernode REST gateway.

Installation

# Initialize a project if you don't have one yet
npm init -y
 
# Install the SDK along with dependencies for transaction signing and blockchain queries
npm install @lumera-protocol/sdk-js @cosmjs/proto-signing @cosmjs/stargate

Architecture

The SDK follows a three-layer architecture:

LayerAccess viaPurpose
Blockchainclient.BlockchainChain queries: actions, supernodes, fees, transactions
Cascadeclient.CascadeFile upload, download, and task management
WalletPassed as signerTransaction signing and ADR-036 authentication

Client Setup

import { createLumeraClient } from "@lumera-protocol/sdk-js";
 
const client = await createLumeraClient({
  preset: "testnet",
  signer: signer as any,          // Keplr, Leap, or DirectSecp256k1HdWallet
  address: account.address,
  gasPrice: "0.025ulume",
});

The signer must support signDirect, signAmino, and signArbitrary (ADR-036). Browser wallets like Keplr provide all three natively. For Node.js, see Client Setup to build a compatible signer from a mnemonic.

Upload a File

const file = new TextEncoder().encode("Hello, Lumera!");
const expirationTime = String(Math.floor(Date.now() / 1000) + 25 * 60 * 60); // 25 hours from now 
 
const task = await client.Cascade.uploader.uploadFile(file, {
  fileName: "hello.txt",
  isPublic: true,
  expirationTime,
});
 
console.log("Upload task:", task.taskId, "status:", task.status);

Download a File

const stream = await client.Cascade.downloader.download(actionId);
const reader = stream.getReader();
const chunks: Uint8Array[] = [];
 
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  if (value) chunks.push(value);
}

Query the Chain

// Action parameters and fees (getActionFee takes size in KB, rounded up)
const params = await client.Blockchain.Action.getParams();
const fee = await client.Blockchain.Action.getActionFee(Math.ceil(file.length / 1024));
 
// Look up a specific action
const action = await client.Blockchain.Action.getAction(actionId);
 
// List supernodes
const nodes = await client.Blockchain.Supernode.listSupernodes();

Wallet Helpers

The SDK provides helpers for browser wallet integration:

import { getKeplrSigner, isKeplrAvailable } from "@lumera-protocol/sdk-js";
 
if (!isKeplrAvailable()) {
  throw new Error("Please install the Keplr extension");
}
 
const keplrSigner = await getKeplrSigner("lumera-testnet-2");

getKeplrSigner returns a unified signer with signDirect, signAmino, and signArbitrary already wired up.

Key Exports

import {
  createLumeraClient,
  type LumeraClient,
  CHAIN_PRESETS,
 
  // Cascade
  CascadeUploader,
  CascadeDownloader,
  SNApiClient,
  TaskManager,
 
  // Blockchain utilities
  buildBatchMessages,
  estimateGas,
  calculateCascadeFee,
  BlockchainActionAdapter,
 
  // LEP-1 (internally used by CascadeUploader)
  createSingleBlockLayout,
  generateIds,
  buildIndexFile,
 
  // Wallet
  getKeplrSigner,
  isKeplrAvailable,
} from "@lumera-protocol/sdk-js";

Type Safety

The SDK is fully typed with TypeScript. All SN-API responses are validated against OpenAPI-generated types, and blockchain messages use Telescope-generated protobuf codecs.

Next Steps

Edit this page

On this page