Skip to main content

Midnight examples archive

Download the Midnight example DApps archive from the Midnight Testnet releases repository.

The examples ZIP file is named midnight-examples-x.y.z.zip (where x.y.z is the version) for some version x.y.z. Unzip the file wherever you would like to build and test Midnight DApps. Then go to the top level of the newly unzipped package.

unzip midnight-examples-0.1.3.zip
cd midnight-examples-0.1.3

Configure NVM for the examples

In the Midnight examples directory, there is a file .nvmrc which will configure NVM correctly for the purposes of this tutorial. Verify that your current directory is the midnight-examples-x.y.z directory, and run the following command:

nvm install

You should see output that begins with a line like this:

Found <somewhere>/midnight-examples-0.1.3/.nvmrc' with version <lts/hydrogen>

and includes a line like this near the end:

Now using node v18.19.1 (npm v10.2.4)

Configure Yarn to download Midnight libraries

You will be using Yarn to build Midnight example DApps. An easy way to install Yarn, now that you have Node configured, is with the corepack command:

corepack enable

This succeeds silently, but you should see version information now if you type:

yarn --version

You should see a version number printed, such as 4.1.0.

The best way to verify this step is to use Yarn to pull the Midnight examples dependencies. In the top level of your midnight-examples folder, simply invoke Yarn with no parameters:

yarn

You should see a lot of output, but no errors, although there may be some warnings. For example, the last line of output may say Done with warnings.

Configure the Compact compiler path

If you did not add COMPACT_HOME to your shell profile after installing the compiler, or if you have not restarted your shell since then, execute the following command:

export COMPACT_HOME='<absolute path to compactc directory>'