@crossmint/client-sdk-smart-wallet

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

[!WARNING] > Smart Wallet SDK is no longer maintained, use Wallets SDK instead.

原始使用文档
文档目录13 节
  1. Installation
  2. Authentication
  3. Quick Start
  4. Examples
  5. Wallet Creation
  6. Sending Transactions
  7. Signing Messages
  8. Migrating from 0.1.x
  9. API Reference
  10. SmartWalletSDK
  11. Types
  12. EVMSmartWallet
  13. SmartWalletClient

Smart Wallet SDK

[!WARNING] Smart Wallet SDK is no longer maintained, use Wallets SDK instead.

A client-side SDK for interacting with Crossmint Smart Wallets. This SDK enables developers to create and manage smart contract wallets that support both traditional keypair-based signing and passkey authentication.

Installation

npm install @crossmint/client-sdk-smart-wallet
# or
pnpm add @crossmint/client-sdk-smart-wallet

Authentication

This SDK uses JSON Web Tokens (JWT) to authenticate your users. JWT is generated by the auth server and used to authorize users to deploy and operate their wallets.

For detailed instructions on how to obtain a JWT token, please refer to User Auth.

Quick Start

import { SmartWalletSDK } from "@crossmint/client-sdk-smart-wallet";
import { privateKeyToAccount } from "viem";

const sdk = SmartWalletSDK.init({ clientApiKey: "<YOUR_API_KEY>" });
const account = privateKeyToAccount(privateKey);

const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>",
  },
  "base-sepolia",
  {
    signer: {
      type: "VIEM_ACCOUNT",
      account,
    },
  }
);

const address = wallet.address;

Examples

Wallet Creation

Passkey Wallets

const signer = await sdk.createPasskeySigner("My Wallet")
const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>",
  },
  "base-sepolia",
  {
    signer,
  }
);
const address = walletClient.getAddress();

Private Key Wallets

import { privateKeyToAccount } from "viem";

const account = privateKeyToAccount(privateKey);
const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>",
  },
  "base-sepolia",
  {
    signer: {
      type: "VIEM_ACCOUNT",
      account,
    },
  }
);
const address = walletClient.getAddress();

Browser Wallets

import type { EIP1193Provider } from "viem";

const providerSigner = window.ethereum as EIP1193Provider;
const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>",
  },
  "base-sepolia",
  {
    signer: providerSigner,
  }
);

Sending Transactions

import { encodeFunctionData, erc20Abi } from "viem";

const walletClient = wallet.client.wallet;
const txHash = await walletClient.sendTransaction({
  to: "<TOKEN_ADDRESS>",
  data: encodeFunctionData({
    abi: erc20Abi,
    functionName: "transfer",
    args: ["<RECEIVER_ADDRESS>", "<TRANSFER_AMOUNT>"],
  })
})

Signing Messages

const walletClient = wallet.client.wallet;
const signature = await walletClient.signMessage({
  message: "Hello, Crossmint!"
})

Migrating from 0.1.x

0.2.x SDK strives to be backwards-compatible with 0.1.x as much as possible.

However, since the wallets are now powered by Crossmint API, some functionality is not available anymore.

Specifically, some functions from the SmartWalletClient object are not available anymore:

  • request
  • writeContract
  • deployContract
  • account
  • sendUserOperation
  • prepareUserOperationRequest

Additionally, the passkey creation flow is changed. To create a passkey-powered wallet, you first create a passkey signer:

const signer = await sdk.createPasskeySigner("My Wallet")

Then use that signer during wallet creation:

const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>",
  },
  "<NETWORK>",
  {
    signer,
  }
);

API Reference

SmartWalletSDK

The main entry point for interacting with smart wallets.

Static Methods

init(params: SmartWalletSDKInitParams): SmartWalletSDK

Initializes the SDK with your client-side API key.

const sdk = SmartWalletSDK.init({ clientApiKey: "<YOUR_API_KEY>" });

Instance Methods

getOrCreateWallet(user: UserParams, chain: SmartWalletChain, walletParams: WalletParams): Promise<EVMSmartWallet>

Creates or retrieves a smart wallet for the specified user.

const wallet = await sdk.getOrCreateWallet(
  {
    jwt: "<USER_TOKEN>" 
  },
  "<NETWORK>",
  {
    signer: /* PasskeySigner or ExternalSigner */
  }
);
createPasskeySigner(name: string): Promise<PasskeySigner>

Creates a new passkey signer with the given name.

const signer = await sdk.createPasskeySigner("My Wallet");

Types

SmartWalletChain

Supported blockchain networks.

WalletParams

Configuration for wallet creation:

interface WalletParams {
  signer: ExternalSigner | PasskeySigner;
}

// Use existing Web3 wallet or private key
type ExternalSigner = EIP1193Provider | ViemAccount;

// Use private key authentication
interface ViemAccount {
  type: "VIEM_ACCOUNT";
  account: LocalAccount & { source: "custom" };
};

// Use passkey authentication
interface PasskeySigner {
  type: "PASSKEY";
  credential: WebAuthnP256.P256Credential;
}

EVMSmartWallet

The wallet instance returned by getOrCreateWallet(). Provides methods for interacting with the smart wallet:

interface EVMSmartWallet {
  // viem clients that provide an interface for core wallet functionality.
  client: {
      public: PublicClient<HttpTransport>;
      wallet: SmartWalletClient;
  };

  // The EVM chain of the smart wallet.
  chain: SmartWalletChain;

  // The address of the smart wallet.
  address(): Address;

  // Transfers tokens from the smart wallet to a specified address.
  transferToken(toAddress: Address, config: TransferType): Promise<string>;

  // A list of NFTs owned by the wallet.
  nfts(): Promise<NftResponse>;

  // Sends a contract call transaction and returns the hash of a confirmed transaction.
  executeContract(params: {
    address: Address;
    abi: Abi;
    functionName: string;
    args: unknown;
  }): Promise<Hex>;
}

SmartWalletClient

The client instance available via wallet.client.wallet. Provides methods for interacting with the wallet:

interface SmartWalletClient {
  // Get the wallet's address
  getAddress(): Address;
  
  // Sign a message
  signMessage(message: string): Promise<Hex>;
  
  // Sign typed data (EIP-712)
  signTypedData<T extends TypedData>(params: TypedDataDefinition<T>): Promise<Hex>;
  
  // Send a transaction
  sendTransaction(params: {
    to: Address;
    data?: Hex;
    value?: bigint;
  }): Promise<Hex>;
}

Full reference is available in the docs.

版本与发布记录

@crossmint/client-sdk-smart-wallet 共发布 127 个版本,首次发布于 2024/07/30;过去 12 个月发布了 49 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.88latest2026/11/10今天
0.3.872026/11/064 天前
0.3.862026/11/065 天前
0.3.852026/11/056 天前
0.3.842026/11/056 天前
0.3.832026/10/3012 天前

其他发布通道:beta → 0.3.54-beta.1。

关于 @crossmint/client-sdk-smart-wallet 的常见问题

@crossmint/client-sdk-smart-wallet 是什么?

[!WARNING] > Smart Wallet SDK is no longer maintained, use Wallets SDK instead.

如何安装 @crossmint/client-sdk-smart-wallet?

在项目目录运行 npm install @crossmint/client-sdk-smart-wallet,或使用 pnpm add / yarn add / bun add。

@crossmint/client-sdk-smart-wallet 支持 TypeScript 吗?

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

@crossmint/client-sdk-smart-wallet 支持 ESM 还是 CommonJS?

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

@crossmint/client-sdk-smart-wallet 可以商用吗?

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

@crossmint/client-sdk-smart-wallet 的下载量有多少?

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

@crossmint/client-sdk-smart-wallet 还在维护吗?

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