Refer to the Quickstart for an example of setting this up.

Prerequisites:

  1. Create a Crossmint account if you haven’t yet.
  2. Go to the API key section of the developer console and create a new client-side API key with the following scopes: wallets.read, wallets.create, and wallets:nfts.read.
  3. Whitelist your project domain by adding it to the ‘Authorized Origins’ section when creating an API key. If testing locally, whitelist localhost and your port (e.g. localhost:3000) for development.
  4. Make a note of your API key, as you will need this to create wallets.

Creating a Wallet

To create a wallet, you will use the getOrCreateWallet function of the SmartWalletSDK, which takes the following parameters:

userParams
object
required

An object identifying the user and containing the following properties:

  • jwt - JSON web token from your auth provider
chain
string
required

The blockchain you intend to create the smart contract wallet on. Available options:

  • polygon
  • polygon-amoy
  • base
  • base-sepolia
  • arbitrum
  • arbitrum-sepolia
  • optimism
  • optimism-sepolia

If you are looking for a different chain, reach out to sales.

walletParams
object

An object containing a signer property. Read on to learn what is a signer and the different types available.

The way that you call the getOrCreateWallet function will depend on the type of signer your application is utilizing.

import { SmartWalletChain, SmartWalletSDK } from "@crossmint/client-sdk-smart-wallet";
import { getJWTFromAuth } from "./FirebaseAuthManager";

export const createSmartWalletPasskey = async () => {
    const xm = SmartWalletSDK.init({
        clientApiKey: process.env.REACT_APP_CROSSMINT_API_KEY_STG,
    });
    const jwt = await getJWTFromAuth();

    return await xm.getOrCreateWallet({ jwt }, SmartWalletChain.POLYGON_AMOY);
}

The getOrCreateWallet function returns a EVMSmartWallet object, which contains the following properties:

  • address - The address of the created wallet
  • chain - The chain the wallet was created on
  • client - A Viem client for interacting with the wallet

As well as some helper functions to interact with the wallet such as:

  • nfts - A function to get the NFTs owned by the wallet
  • executeContract - A function to execute a contract on the wallet
  • transferToken - A function to transfer tokens owned by the wallet