> For the complete documentation index, see [llms.txt](https://docs.caishen.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caishen.tech/installation.md).

# Installation

## Caishen SDK – Plug & Play SDK JS&#x20;

The Caishen SDK provides developers with seamless access to multichain wallets and gasless payment tools. With built-in support for **Ethereum**, **Solana**, **Bitcoin**, **Sui**, and **XRP**, you can integrate wallets, automate agents, and send cash instantly using only a few lines of code.

Caishen supports **Typescript** (for browser and Node.js) and [**Python** ](/installation.md)(for backend automation and bots). You can build wallet-aware apps, agent-based bots, or embedded finance experiences with no seed phrases or infrastructure costs.

***

### Requirements

#### For Typescript (Node.js / Browser)

* Node.js v16+
* Basic understanding of Promises and async/await
* Supports React, Next.js, Vite, Vanilla JS, etc.

***

### Resources

* [**Example Applications**](/build-spotlight.md): View working wallet + cash agent integrations.
* [**Troubleshooting**](/support/faq.md): Common setup issues and sandbox tips.
* [**Source Code**](https://github.com/CaishenTech/caishen-sdk): Full SDK code and dev toolkits.
* [**Support Portal**:](https://discord.gg/tybyS3xSDz) Get help directly from the Caishen team or join the community.

### 📦 Installation

```
npm install @caishen/sdk
# or
yarn add @caishen/sdk
# or
pnpm add @caishen/sdk
```

> ⚠️ Requires Node.js ≥ 14.x and TypeScript ≥ 4.x

***

### 🚀 Quick Start

```
import { CaishenSDK, createAgentTools } from "@caishen/sdk";

const sdk = new CaishenSDK({ projectKey: "your-project-key" });
const tools = createAgentTools(sdk);
```

***

### 🔑 Authentication

You can authenticate as either a **user** or an **agent**.

#### Connect as User

```
await sdk.connectAsUser({
  token: 'USER TOKEN',
  provider: 'USER PROVIDER',
});
```

**✅ Supported Providers**

* `google`, `facebook`, `twitter`, `discord`, `github`, `linkedin`
* `reddit`, `line`, `kakao`, `weibo`, `farcaster`, `custom`

***

#### 🔐 Custom Authentication

If you want to authenticate users **from your own backend**, you can use the `custom` provider.

In this case:

* You must **encrypt a JWT** on your backend using your `projectSecret` (found in your Caishen developer dashboard).
* That encrypted token must contain an object like `{ id: string }`, where `id` is the user identifier in your system.
* You then pass this encrypted token into `connectAsUser`.

**💡 Example**

**Backend-side (Node.js):**

```
import jwt from 'jsonwebtoken';

const payload = { id: 'user-123' };
const token = jwt.sign(payload, projectSecret);
```

**Frontend-side:**

```
await sdk.connectAsUser({
  provider: 'custom',
  token: 'ENCRYPTED_JWT_TOKEN',
});
```

On the Caishen backend, this token is decrypted with your `projectSecret` using:

```
jwt.verify(token, projectSecret); // -> { id: string }
```

> ⚠️ Never share your `projectSecret` publicly. Only your server should have access to it.

***

#### Connect as Agent

```
await sdk.connectAsAgent({
  agentId: 'AGENT ID',
  userId: 'USER ID',
});
```

> Different values for `agentId` and `userId` will generate different wallet scopes.
