Skip to main content
The CrossmintWallets class is the main entry point for the Wallets SDK. It provides methods to create, retrieve, and manage wallets across different blockchain networks.

Initialization

from()

Initialize the Wallets SDK with Crossmint configuration.
public static from(crossmint: Crossmint): CrossmintWallets
crossmint
Crossmint
required
Crossmint instance created using createCrossmint() from @crossmint/common-sdk-base
CrossmintWallets
CrossmintWallets
A new CrossmintWallets instance

Example

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

const crossmint = createCrossmint({
  apiKey: "your-api-key"
});

const wallets = CrossmintWallets.from(crossmint);

Wallet Management

getOrCreateWallet()

Get an existing wallet or create a new one. This method can only be called on the client side.
public async getOrCreateWallet<C extends Chain>(
  options: WalletArgsFor<C>
): Promise<Wallet<C>>
options
WalletArgsFor<C>
required
Wallet configuration options
wallet
Wallet<C>
A wallet instance for the specified chain

Example

const wallet = await wallets.getOrCreateWallet({
  chain: "ethereum",
  signer: {
    type: "evm-keypair",
    privateKey: "0x..."
  }
});

console.log("Wallet address:", wallet.address);

getWallet()

Get an existing wallet by its locator. This method can only be called on the server side.
public async getWallet<C extends Chain>(
  walletLocator: string,
  options: WalletArgsFor<C>
): Promise<Wallet<C>>
walletLocator
string
required
The wallet locator (typically the wallet address)
options
WalletArgsFor<C>
required
Wallet configuration options (same as getOrCreateWallet)
wallet
Wallet<C>
The wallet instance if found
error
WalletNotAvailableError
Thrown if the wallet is not found

Example

const wallet = await wallets.getWallet(
  "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  {
    chain: "ethereum",
    signer: {
      type: "api-key"
    }
  }
);

createWallet()

Create a new wallet. This method can only be called on the server side.
public async createWallet<C extends Chain>(
  options: WalletArgsFor<C>
): Promise<Wallet<C>>
options
WalletArgsFor<C>
required
Wallet configuration options (same as getOrCreateWallet)
wallet
Wallet<C>
A new wallet instance

Example

const wallet = await wallets.createWallet({
  chain: "polygon",
  signer: {
    type: "api-key"
  },
  owner: "[email protected]"
});

console.log("New wallet created:", wallet.address);

Build docs developers (and LLMs) love