Installation

Caishen SDK – Plug & Play SDK JS

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 (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

πŸ“¦ 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.

Last updated