# Setup

## Requirements

* node.js >= 18
* ethers >= 6
* snarkjs >= 0.7.1

## Add the client package

To add the client package as a dependency to your application:

<pre class="language-sh"><code class="lang-sh"><strong>yarn add @nebrazkp/upa ethers
</strong></code></pre>

## UPA instance

After adding the client package, you will need a file `upa.instance` containing the details of a particular deployment of the UPA contracts.&#x20;

Get the JSON file for the instance you wish to use from the [Deployments](/developer-guide/deployments.md) section.

## Initialize the UPA Client

The UPA client is the main way your app will interact with the UPA. It allows you to easily submit proofs among other things. To initialize it, first load the contents of `upa.instance` as json into a variable `upaInstanceDescriptor`, and then pass this to the constructor with an `ethers.Provider`or `ethers.Signer.`

> **NOTE**: The examples below are simplified for illustration purposes

### In nodejs:

```typescript
import { UpaClient } from "@nebrazkp/upa/sdk";
import { config } from "@nebrazkp/upa/tool";
import * as ethers from "ethers";
import * as fs from "fs";

...

const upaInstanceDescriptor = config.loadInstance("upa.instance");

const provider = new ethers.JsonRpcProvider(endpoint);
const keystoreStr = fs.readFileSync(keyfile, "ascii");
const signer = await ethers.Wallet.fromEncryptedJson(keystoreStr, password);

const upaClient = new UpaClient(signer, upaInstanceDescriptor);
```

### In the browser:

```typescript
import { UpaClient } from "@nebrazkp/upa/sdk";
import * as ethers from "ethers";

...

const upaInstanceDescriptor = { }; // embed or read from server
const provider = new ethers.BrowserProvider((window as any).ethereum);
const signer = await provider.getSigner();
const upaClient = new UpaClient(signer, upaInstanceDescriptor);
```

where `signer` is the account which will execute the transactions underlying the client methods.

## Add the UPA command line tool

Another way to interact with the UPA is through the command line tool. To set it up, run&#x20;

<pre class="language-bash"><code class="lang-bash"><strong>export PATH=$PATH:$(pwd)/node_modules/.bin
</strong></code></pre>

to enable the `upa` command in your current shell. If successful, running the `upa` command will give output like:

<figure><img src="/files/fOjhXFFKX6w9Dz60dx8w" alt=""><figcaption></figcaption></figure>

> **NOTE**: the `upa` tool is intended to be self documenting.  See `upa --help` for the full list of available commands.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nebra.one/developer-guide/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
