Cascade
Getting Started

Quick Start

Upload your first file to Cascade in under five minutes.

Install Dependencies

npm install @lumera-protocol/sdk-js @cosmjs/proto-signing @cosmjs/stargate

Upload a File

upload.ts
import { createLumeraClient } from "@lumera-protocol/sdk-js";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Secp256k1HdWallet, makeSignDoc as makeAminoSignDoc } from "@cosmjs/amino";
 
const MNEMONIC = "your twelve word mnemonic goes here";
 
async function main() {
  const directWallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: "lumera" });
  const aminoWallet = await Secp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: "lumera" });
  const [account] = await directWallet.getAccounts();
 
  // Combine direct + amino wallets and add signArbitrary (ADR-036) for Cascade
  const signer = {
    getAccounts: () => directWallet.getAccounts(),
    signDirect: (addr: string, doc: any) => directWallet.signDirect(addr, doc),
    signAmino: (addr: string, doc: any) => aminoWallet.signAmino(addr, doc),
    async signArbitrary(chainId: string, signerAddress: string, data: string) {
      const signDoc = makeAminoSignDoc(
        [{
          type: "sign/MsgSignData",
          value: {
            signer: signerAddress,
            data: Buffer.from(data).toString("base64"),
          },
        }],
        { gas: "0", amount: [] },
        "",  // ADR-036 requires empty chain_id
        "",
        0,
        0
      );
      const { signature } = await aminoWallet.signAmino(signerAddress, signDoc);
      return { signed: data, signature: signature.signature, pub_key: signature.pub_key };
    },
  };
 
  const client = await createLumeraClient({
    preset: "testnet",
    signer: signer as any,
    address: account.address,
    gasPrice: "0.025ulume"
  });
 
  // The file to upload. 
  const file = new TextEncoder().encode("Hello, Lumera!");
 
  // The deadline for supernodes to process the upload action. 
  // If not finalized by this time, the fee will be refunded. 
  const expirationTime = String(Math.floor(Date.now() / 1000) + 25 * 60 * 60); //  25 hours from now
 
 
  const result = await client.Cascade.uploader.uploadFile(file, {
    fileName: "hello.txt",
    isPublic: true,
    expirationTime
  });
 
  console.log("Upload complete:", result);
  // result.action_id is your permanent on-chain reference
}
 
main();

Security: Never hardcode mnemonics in production code. Use environment variables or a secrets manager.

Next Steps

Edit this page

On this page