Create Smart Wallets
Generate wallets for your users
Prerequisites:
- Create a Crossmint account if you haven’t yet.
- 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
, andwallets:nfts.read
. - 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. - 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:
An object identifying the user and containing the following properties: - jwt
- JSON web token from your auth
provider
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.
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.
The getOrCreateWallet
function returns a EVMSmartWallet
object, which contains the following properties:
address
- The address of the created walletchain
- The chain the wallet was created onclient
- 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 walletexecuteContract
- A function to execute a contract on the wallettransferToken
- A function to transfer tokens owned by the wallet