Nightcast

Nightcast Developers

Fair randomness in a few lines of code.

Ask Midnight for a random value. It comes back with a proof, and the SDK turns it into winners, shuffles, dice or prizes that anyone can check for themselves.

npm install @nightcast/sdk @nightcast/contract

Read the developer guide View the source

import { listCommitment, pickMany } from '@nightcast/sdk';

const entrants = ['Ava', 'Ben', 'Chloe', 'Dev', 'Ella'];

// Seal the list: its fingerprint is the request's seed.
// Publish it first, so the list can't change later.
const seed = listCommitment(entrants);

// Once Nightcast answers, the same output gives
// the same winners on any computer.
const winners = pickMany(output, entrants, 2);

From a request to a result

  1. Seal what it's for

    Fix the entrants, prizes and rules first, and put their fingerprint in the request as its seed.

    In your app, instantly

  2. Request

    One transaction on the Nightcast contract, with a deadline and an address for a refund.

    0.1 tNIGHT on Preprod

  3. The oracle answers

    Its answer is a zero-knowledge proof: Midnight's validators accept only the one value its key allows.

    Usually within a minute or two

  4. Derive and publish

    Turn the 32 bytes into your result. Anyone with the same inputs gets the same answer.

    With the SDK, offline

If the deadline passes without an answer, anyone can expire the request, and the fee and the oracle's collateral go to your refund address. Decide in advance what happens then: usually, announce a new draw. Never ask again until the result looks right.

Three ways in

TypeScript SDK

For apps and back ends. @nightcast/sdk turns one answer into any kind of choice, and runs an oracle or checks one.

@nightcast/sdk on npm

AI agents

An MCP server with five tools: fingerprint a list, request, check, derive and explain. A draw with no person in the loop, that people can still audit.

Set up the MCP server

Inside a Compact contract

For randomness in a circuit. Today a contract embeds the same VRF, as Lunardraw's Starfall does, and the NightcastWords module turns its output into words.

Randomness in your contract

An example: fair breeding

In the Quinelings ranch, one 32-bit number decides what two creatures' child looks like, so whoever picks it can keep trying. This demo seals each pair first, then lets Nightcast draw the number on Midnight Preprod. Three real breedings, each checkable in your browser.

An independent demonstration using the open-source Quinelings, by Charles Hoskinson. Not made or endorsed by the Quinelings project.

See fair breeding

The SDK at a glance

Every function takes the 32-byte answer and gives the same result on every computer, so the people your draw affects can repeat it.

Batches are new: many numbers from one request, each with a receipt. The SDK part is on GitHub and comes to npm in the next release; the service that answers them is being built.

FunctionGives you
pickMany(output, items, k)k different winners, in the order drawn.
pick(output, items)One item from a list.
shuffle(output, items)The whole list in a fair order.
randomInt(output, min, max)A whole number in a range, with no bias.
rollDice(output, count, sides)Dice, six-sided unless you say.
weightedPick(output, weights)A prize table: rarer prizes come up less often.
listCommitment(items)A list's fingerprint, to seal it before the draw.
randomWords(output, n)Many independent 32-byte words from one answer.
sealBatch, makeReceipt, checkReceiptMany numbers from one request, each with its own receipt. On GitHub now; in the next npm release.

Live on Preprod

Both contracts are locked: nobody, including us, can change their code after deployment.

Nightcast v1, one oracle

Use this today
eaae909ead…b044a73adb
Deployed
9 Nov 2026
Request fee
0.1 tNIGHT
Collateral a request
1 tNIGHT
Deadline
1 minute to 24 hours

Answers LunaSpin's spins.

Threshold network

Test deployment
46d0489c7d…4e999b1ead
Deployed
24 Nov 2026
Request fee
0.5 tNIGHT
Answering time
100 minutes
Contract calls
18, all proved

A test deployment for measuring real proofs and fees: short epochs and test pool keys. It will be replaced. See it running

The full records, with verifier keys and transaction ids: deployments on GitHub.

Know this before you build

Building something?

Tell us what you're making. We'll help you wire it up on Preprod, and you'll be first to hear when Mainnet opens.

We only use your email for Nightcast early access. We don't share it. Privacy