@crossmint/wallets-sdk

中文文档
1.22.3发布于 2026/11/10Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 20.1万

Typescript SDK for creating and managing Crossmint Wallets on EVM, Solana, and Stellar chains.

原始使用文档
文档目录24 节
  1. Prerequisites
  2. Installation
  3. Quick Start
  4. Server-side (Node.js)
  5. Client-side (Headless)
  6. Creating a Wallet
  7. Server signer
  8. External wallet signer
  9. Device signer (browser / React Native)
  10. Retrieving an existing wallet
  11. Core Concepts
  12. Signers
  13. Usage
  14. Balances
  15. Send Tokens
  16. Transfers
  17. NFTs
  18. Chain-Specific Transactions
  19. Signer Management
  20. Transaction Approval (Prepare-Only Mode)
  21. Signer Types
  22. React / React Native
  23. Documentation
  24. License

@crossmint/wallets-sdk

Typescript SDK for creating and managing Crossmint Wallets on EVM, Solana, and Stellar chains.

Prerequisites

Get a Crossmint API key from the developer console. Ensure your key has the Wallet API scopes enabled, including wallets.fund for stagingFund.

  • Client-side (browser): Use a client API key
  • Server-side (Node.js): Use a server API key

Installation

npm install @crossmint/wallets-sdk
# or
pnpm add @crossmint/wallets-sdk
# or
yarn add @crossmint/wallets-sdk

Quick Start

Server-side (Node.js)

import { createCrossmint, CrossmintWallets } from "@crossmint/wallets-sdk";

const crossmint = createCrossmint({ apiKey: "<YOUR_SERVER_API_KEY>" });
const wallets = CrossmintWallets.from(crossmint);

// Create a wallet with a server signer
const wallet = await wallets.createWallet({
  chain: "base-sepolia",
  recoveryMethods: [{ type: "server", secret: "<RECOVERY_SECRET>" }],
});

console.log(wallet.address);

// Staging only: mint USDXM, Crossmint's test stablecoin, into the wallet
await wallet.stagingFund(10);

// Send tokens
const tx = await wallet.send("0xRecipientAddress", "usdxm", "10");
console.log(tx.explorerLink);

Client-side (Headless)

For client-side usage without React, you can use the SDK directly with a user JWT. In staging, get it from Crossmint Auth (@crossmint/client-sdk-auth); in production, or when your app already has an auth provider, use that provider's JWT:

import { createCrossmint, CrossmintWallets } from "@crossmint/wallets-sdk";

const crossmint = createCrossmint({ apiKey: "<YOUR_CLIENT_API_KEY>" });
crossmint.setJwt("<USER_JWT>");

const wallets = CrossmintWallets.from(crossmint);

const wallet = await wallets.getWallet({ chain: "base-sepolia" });
console.log(wallet.address);

For React apps, use @crossmint/client-sdk-react-ui which provides CrossmintWalletProvider, hooks, and built-in UI for OTP and passkey flows.

Creating a Wallet

Server signer

Create a wallet with a server key as a recovery method:

import { createCrossmint, CrossmintWallets } from "@crossmint/wallets-sdk";

const crossmint = createCrossmint({ apiKey: "<YOUR_SERVER_API_KEY>" });
const wallets = CrossmintWallets.from(crossmint);

const wallet = await wallets.createWallet({
  chain: "base-sepolia",
  recoveryMethods: [{ type: "server", secret: "<RECOVERY_SECRET>" }],
});

console.log(wallet.address);

External wallet signer

Bring your own key (MetaMask, KMS, etc.):

const wallet = await wallets.createWallet({
  chain: "base-sepolia",
  recoveryMethods: [
    {
      type: "external-wallet",
      address: "0xYourWalletAddress",
      onSign: async (message: string) => {
        // Sign the message with your wallet/KMS and return the signature
        return await yourWallet.signMessage({ message: { raw: message as `0x${string}` } });
      },
    },
  ],
});

Device signer (browser / React Native)

Device signers use hardware-backed P256 keys for frictionless client-side signing. They must be created on the client and can be passed to the server at wallet creation time:

// Client: generate a device signer descriptor
const { createDeviceSigner } = useWallet();
const deviceSigner = await createDeviceSigner();
// Send deviceSigner to your server
// Server: create the wallet with the device signer pre-registered
const wallet = await wallets.createWallet({
  chain: "base-sepolia",
  owner: "email:[email protected]",
  recoveryMethods: [{ type: "email", email: "[email protected]" }],
  signers: [deviceSigner],
});

Device signers are browser and React Native only — not available in Node.js. See the Server-Side Wallet with Device Signer guide for the full pattern.

Retrieving an existing wallet

// Client-side
const wallet = await wallets.getWallet({ chain: "base-sepolia" });
// Server-side — requires a wallet locator
const wallet = await wallets.getWallet("0xWalletAddress", {
  chain: "base-sepolia",
});

Core Concepts

Signers

Wallets SDK uses a two-tier signer model:

  • Recovery method — High-security, used for wallet recovery and adding new signers. Supports email OTP, phone OTP, external wallet, or server key.
  • Operational signer — Low-friction, used for day-to-day signing. Supports server key, external wallet, passkey, and device (browser/mobile only). For server-side (Node.js) usage, use a server or external-wallet signer.

When no operational signer is available, the recovery method automatically serves as a fallback for signing.

Usage

Balances

const balances = await wallet.balances();

console.log(balances.nativeToken.amount);
console.log(balances.usdc.amount);

For wallets with a card, each token also reports how its balance splits:

  • available: what can be spent now
  • locked: pending card charges
  • inTransit: funds moving between the wallet and the card that the card provider has not reflected yet
  • accounts: the same split for the wallet and for each card. Only card accounts have inTransit. Each card also reports creditLimit: the most it can spend, as set by the card provider

available + inTransit is the total the user holds while funds move.

const { usdc } = await wallet.balances();
console.log(usdc.available?.amount, usdc.inTransit?.amount);

Send Tokens

const tx = await wallet.send("0xRecipient", "usdc", "100");
console.log(tx.explorerLink);

Transfers

const transfers = await wallet.transfers({
  tokens: "usdc",
  status: "successful",
});

NFTs

const nfts = await wallet.nfts({ perPage: 10, page: 1 });

Chain-Specific Transactions

import { EVMWallet, SolanaWallet, StellarWallet } from "@crossmint/wallets-sdk";

// EVM — smart contract interaction
const evmWallet = EVMWallet.from(wallet);
const tx = await evmWallet.sendTransaction({
  to: "0xContractAddress",
  abi: contractAbi,
  functionName: "mint",
  args: [1],
  value: 0n,
});

// EVM — sign a message
const sig = await evmWallet.signMessage({ message: "Hello" });

// EVM — viem public client
const client = evmWallet.getViemClient();

// Solana
const solWallet = SolanaWallet.from(wallet);
const solTx = await solWallet.sendTransaction({
  serializedTransaction: "<base64-encoded-transaction>",
});

// Stellar
const stellarWallet = StellarWallet.from(wallet);
const stellarTx = await stellarWallet.sendTransaction({
  contractId: "C...",
  method: "transfer",
  args: { to: "G...", amount: "1000000" },
});

Signer Management

// Add a new signer
await wallet.addSigner({ type: "server", secret: "<SECRET>" });

// List signers
const signers = await wallet.signers();
console.log(signers); // [{ type: "server", locator: "server:...", status: "success" }, ...]

// Set the active signer (required after getWallet server-side)
await wallet.useSigner({ type: "server", secret: "<SECRET>" });

Transaction Approval (Prepare-Only Mode)

For flows that require multi-step approval:

// Create a transaction without auto-approving
const pendingTx = await wallet.send("0xRecipient", "usdc", "10", {
  prepareOnly: true,
});
console.log(pendingTx.transactionId);

// Approve later
const result = await wallet.approve({
  transactionId: pendingTx.transactionId,
});

Signer Types

TypeUse CasePlatforms
deviceHardware-backed, no OTP. Browser and React Native only — not available in Node.js.Browser, React Native
serverServer-side automated operations (AI agents, backends).Node.js
emailOTP-based recovery method.All
phoneOTP-based recovery method.All
passkeyWebAuthn/FIDO2 biometric signer on EVM, Solana and Stellar. On Solana it can be a signer but not a recovery method.Browser, React Native (set the passkeys prop on CrossmintWalletProvider)
external-walletBring-your-own key (MetaMask, KMS, etc).All

React / React Native

For React applications, use @crossmint/client-sdk-react-ui which provides wallet providers, hooks (useWallet, useWalletOtpSigner), and built-in UI for OTP and passkey flows.

For React Native, see @crossmint/client-sdk-react-native-ui.

Documentation

License

Apache-2.0

版本与发布记录

@crossmint/wallets-sdk 共发布 165 个版本,首次发布于 2025/03/03;过去 12 个月发布了 81 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.22.3latest2026/11/10今天
1.22.22026/11/074 天前
1.22.12026/11/064 天前
1.22.02026/11/065 天前
1.21.22026/11/056 天前
1.21.12026/11/056 天前

其他发布通道:beta → 1.0.0-beta.7,legacy → 0.20.5。

关于 @crossmint/wallets-sdk 的常见问题

@crossmint/wallets-sdk 是什么?

Typescript SDK for creating and managing Crossmint Wallets on EVM, Solana, and Stellar chains.

如何安装 @crossmint/wallets-sdk?

在项目目录运行 npm install @crossmint/wallets-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@solana/web3.js(^1.98.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@crossmint/wallets-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crossmint/wallets-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@crossmint/wallets-sdk 可以商用吗?

@crossmint/wallets-sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@crossmint/wallets-sdk 的下载量有多少?

根据 npm 官方下载统计,@crossmint/wallets-sdk 在 2026/10/11 – 2026/11/09 这 30 天内被下载 200,503 次,日均约 6,683 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crossmint/wallets-sdk 还在维护吗?

最新版本 1.22.3 发布于 2026/11/10(今天);至今共发布 165 个版本,其中过去 12 个月发布了 81 个;首次发布于 2025/03/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。