> For the complete documentation index, see [llms.txt](https://docs.delegate.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.delegate.xyz/technical-documentation/javascript-sdk/setup.md).

# Setup

### Installation

Adding [@delegatexyz/sdk](https://github.com/delegatexyz/delegate-javascript-sdk) to your project is just a single command.

```bash
npm install @delegatexyz/sdk viem
```

### Importing

{% code title="ES6 or Typescript" %}

```javascript
import { http } from "viem"
import { DelegateV1, DelegateV2 } from "@delegatexyz/sdk";
```

{% endcode %}

{% code title="NodeJS require" %}

```javascript
const { http } = require("viem");
const { DelegateV1, DelegateV2 } = require("@delegatexyz/sdk");
```

{% endcode %}

### Setup

The v1 or v2 SDK require the same parameters:

* **transport**: a valid viem [Transport](https://viem.sh/docs/clients/intro.html#transports).
* **chain (optional)**: [chain](https://viem.sh/docs/glossary/terms.html#chain) from `viem/chains` (or [define your own](https://viem.sh/docs/clients/chains.html#custom-chains))
* **account (optional)**: A [wallet client](https://viem.sh/docs/clients/wallet.html)

*`account` is only required to use the write functions*.

```typescript
import { http } from "viem"
import { DelegateV1, DelegateV2 } from "@delegatexyz/sdk";

const RPC_URL = "";
const v1 = new DelegateV1(http(RPC_URL))
const v2 = new DelegateV2(http(RPC_URL))
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.delegate.xyz/technical-documentation/javascript-sdk/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.
