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
Example Applications: View working wallet + cash agent integrations.
Troubleshooting: Common setup issues and sandbox tips.
Source Code: Full SDK code and dev toolkits.
Support Portal: 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 }
, whereid
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
anduserId
will generate different wallet scopes.
Last updated