> For the complete documentation index, see [llms.txt](https://gl-docs.gitbook.io/zkpass/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gl-docs.gitbook.io/zkpass/zkpass-developers-guide/sdk-tutorial/typescript/running-code.md).

# Running Code

{% hint style="info" %}
To install the Dvr Module Client lib separately, please refer to this section [Installing the Dvr Module Client lib](#installing-the-sdk)
{% endhint %}

## <mark style="color:blue;">System Requirements</mark>

1. Ubuntu version 20 or higher, WSL (Windows Subsystem for Linux) is also supported.
2. [Node.js 18.17.0](https://nodejs.org/en) or later.
3. [Git](https://git-scm.com/)

{% hint style="warning" %}
Make sure the VPN is off
{% endhint %}

### Installing WSL for Windows users

This command will enable the necessary features to run WSL and install the Ubuntu distribution of Linux.

{% hint style="info" %}
If your underlying system, like Ubuntu, is already Linux-based, you can skip this step.
{% endhint %}

{% hint style="warning" %}
If your Windows version is below Windows 10 2004, please refer to [this documentation](https://learn.microsoft.com/en-us/windows/wsl/install-manual) instead.
{% endhint %}

1. Open PowerShell or Windows Command Prompt in **administrator** mode by right-clicking and selecting "Run as administrator"
2. Run the command below

```bash
wsl --install
```

3. Restart your machine
4. Once you have installed WSL, you will need to create a user account and password for your newly installed Linux distribution.

{% hint style="info" %}
The above command only works if WSL is not installed at all, if you run `wsl --install` and see the WSL help text, please try running `wsl --list --online` to see a list of available distros and run `wsl --install -d <DistroName>` to install a distro. To uninstall WSL, see [Uninstall legacy version of WSL](https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#uninstall-legacy-version-of-wsl) or [unregister or uninstall a Linux distribution](https://learn.microsoft.com/en-us/windows/wsl/basic-commands#unregister-or-uninstall-a-linux-distribution).
{% endhint %}

{% hint style="info" %}
If you have installed WSL before, you can login using the command `wsl`
{% endhint %}

{% hint style="info" %}
For a complete WSL installation guide, refer to [this documentation](https://learn.microsoft.com/en-us/windows/wsl/install).
{% endhint %}

### Installing Node.js 18.17.0 via NVM

#### Installing NVM

`nvm` allows you to quickly install and use different versions of node via the command line.

1. Run the command below

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
```

2. Restart your terminal session

#### Installing Node 18.17.0 and NPM via NVM

```bash
nvm install 18.17.0
```

To check whether Node has been installed properly, run the commands below:

```
node -v
npm -v
```

{% hint style="info" %}
Complete NVM documentation can be found [here](https://github.com/nvm-sh/nvm).
{% endhint %}

### Installing Git

```bash
sudo apt update
sudo apt install git
```

To check whether Node has been installed properly, run the commands below:

```
git --version
```

{% hint style="info" %}
Complete Git documentation can be found [here](https://git-scm.com/doc).
{% endhint %}

***

## <mark style="color:blue;">Installing the SDK</mark>

{% hint style="info" %}
If you wish to explore our demo application, feel free to skip this installation step, as it has already been completed in the demo application.
{% endhint %}

If you want to use our **zkpass-client-ts** library on your own project / outside the demo application, you can follow this step

1. Set the npm registry configuration to gdp-labs registry.

```bash
npm config set @zkpass:registry=https://us-west1-npm.pkg.dev/gdp-labs/gdplabs-npm-public/
```

2. Install the zkpass-client library for typescript

```bash
npm install @zkpass/dvr-client-ts
```

{% hint style="info" %}
For NextJS projects with **App Routing**, several configurations have to be made in `next.config.js` file:
{% endhint %}

```javascript
next.config.js

const nextConfig = {
  ...,
  experimental: {
    ...,
    esmExternals: "loose", // Enable ESM imports
    serverComponentsExternalPackages: ["@zkpass/dvr-client-ts"], // Exclude SDK from bundling, to enable reading binary file
  },
};

module.exports = nextConfig;

```

{% hint style="info" %}
The `serverComponentsExternalPackages` configuration ensures that the package `@zkpass/dvr-client-ts` is excluded from NextJS' bundling and compilation process, allowing it to be imported directly from `node_modules`. As a result, remember to include the `node_modules` directory in your production build. See [NextJS Deployment Guide](https://nextjs.org/docs/pages/building-your-application/deploying).
{% endhint %}

## <mark style="color:blue;">Running CLI Demo</mark>

The demo application will run in a CLI and requires 2 parameters: DVR and user data. Please review [zkPass key concepts](https://docs.ssi.id/zkpass/v/zkpass-developers-guide/introduction/key-concepts) to have better understanding of the use case.

<figure><img src="/files/5dl7ZfiPIuiZicy4lV2l" alt=""><figcaption></figcaption></figure>

#### <mark style="color:orange;">Cloning Demo</mark>

To try our Typescript CLI demo, you can follow these steps

1. Clone demo repository

```bash
git clone https://github.com/gl-zkPass/zkpass-sdk.git
```

2. Go to Typescript CLI demo directory (Let's assume this is our root directory for steps below)

```bash
cd zkpass-sdk/typescript/
```

#### <mark style="color:orange;">Running Demo</mark>

1. Install packages

```bash
npm install
```

2. Run Dewi demo

It will run the demo using predefined user data and DVR for Dewi. The expected query result is "**false**".

```bash
npm run demo-dewi
```

Expected result :

```
...
...
#### starting zkpass proof verification...
#### verification completed [time=118ms]
the query result is false
```

3. Run Ramana demo

It will run the demo using predefined user data and DVR for Ramana. The expected query result is "**true**".

```bash
npm run demo-ramana
```

Expected result :

```
...
...
#### starting zkpass proof verification...
#### verification completed [time=60ms]
the query result is true
```

4. Run Jane demo

It will run the demo using predefined user data and DVR for Jane. The expected query result is "**true**".

```bash
npm run demo-jane
```

Expected result :

```
...
...
#### starting zkpass proof verification...
#### verification completed [time=46ms]
the query result is true
```

5. Run demo with custom data

You can run the demo using custom data. Examples for user data and DVR can be found in `rust/test/data`.

Example running demo using custom data :

```bash
npm run demo ../rust/test/data/basic-data.json ../rust/test/data/basic-dvr.json
```

Expected result :

```
...
...
#### starting zkpass proof verification...
#### verification completed [time=51ms]
the query result is true
```

6. Run demo with multiple user data

You can also run the demo using multiple user data. Examples for multiple user data and DVR can be found in `typescript/test/data/multiple`.

Example running demo using multiple data:

```bash
npm run demo-multi
```
