Skip to main content
For the complete documentation index, see llms.txt

Leaderboard tutorial

Prerequisites: work through the ZK Loan tutorial first. This tutorial assumes you can compile a contract, write a witness, and read a Midnight.js test suite.

Every example so far has run from a test suite. This one ends as a website. You take a small Compact contract, wrap it in a TypeScript API that both a browser and Node can use, build a React DApp that talks to the Lace wallet, and deploy it to Vercel as a static site.

The contract is an arcade-style leaderboard. Players submit scores, under a name they choose or anonymously, and every submission becomes a new public entry. Each entry also stores a commitment to the player's secret key, so a player can later prove with a zero-knowledge proof that an entry is theirs, without revealing the key.

The source for this tutorial is examples/leaderboard in midnight-examples. Its SPEC.md is the design card, including what the leaderboard makes public.

Set up​

Clone midnight-examples, install the workspace, and compile every contract:

git clone https://github.com/midnightntwrk/midnight-examples.git
cd midnight-examples
npm install && npm run compile

Then move into the example:

cd examples/leaderboard