MOONLIGHT[ Rise → ]

§ Docs · v0.9.3

The Moonlight SDK

A thin websocket client. Point it at a Solana wallet, subscribe to jobs, submit proofs. USDC lands the moment a job clears verification.

Install

Add the SDK to any modern web project. It ships as an ES module with typings included. Bundle size: 14.2 kB gz.

npm install @moonlight/sdk
# or
bun add @moonlight/sdk

Quickstart

Ten lines to first payout. Link a Solana address, listen for jobs, submit proofs.

import { Moonlight } from "@moonlight/sdk";

const worker = await Moonlight.connect({
  wallet: "So1anaWa11etAddress…",
  runtime: "webgpu",           // falls back to wasm
  payout: { asset: "USDC", chain: "solana" },
});

worker.on("job", async (job) => {
  const proof = await job.run();
  await job.submit(proof);     // paid $0.12 on verify
});

worker.on("settled", ({ usdc, sig }) => {
  console.log(`+${usdc} USDC · ${sig}`);
});

Connect

Moonlight.connect() opens an authenticated websocket to gateway.moonlight.compute, negotiates a TLS session, and registers your device on the queue.

type ConnectOptions = {
  wallet: string;              // Solana base58 address
  runtime?: "webgpu" | "wasm"; // default: auto
  payout: {
    asset: "USDC";
    chain: "solana";
  };
};

Jobs

Every job is a deterministic kernel plus a seed. Run it, digest the output, submit the proof. The gateway re-runs the same seed on its side and compares digests bit-for-bit.

worker.on("job", async (job) => {
  console.log(job.id, job.kernel, job.seed);
  const proof = await job.run();
  await job.submit(proof);
});

Payouts

Verified jobs credit $0.12 USDC to your balance on Solana. Once your balance clears $1.00, withdraw to any Solana wallet. Nothing is locked up.

worker.on("settled", ({ usdc, sig }) => {
  // sig: Solana transaction signature
});

await worker.withdraw({ to: "So1anaWa11etAddress…" });

Runtime

Kernels run on WebGPU in Chrome, Edge, or Brave. On unsupported browsers the SDK falls back to a WASM runtime. Slower, but no install, drivers, or extensions required.

  • · Bundle: 14.2 kB gz
  • · Latency: ~42 ms rtt
  • · Runtime: WebGPU · WASM
  • · License: Apache 2.0

Errors

The SDK emits typed errors for the common failure cases. Handle them or let them bubble.

worker.on("error", (err) => {
  switch (err.code) {
    case "PROOF_MISMATCH":  break; // digest didn't match gateway
    case "TIMEOUT":         break; // kernel exceeded window
    case "WALLET_INVALID":  break; // wallet failed signature check
  }
});

Next

See a live proof

Every job's kernel, seed, and digest is public. Watch verification happen in real time.

Open proof →