Create Wallets

You can create a wallet on demand using the Crossmint's NFT Wallet API simply by passing an email (or any user identifier) to our create wallet API. Here are the steps you need to follow:

Prerequisites:

  1. Ensure that you have a Crossmint developer account. If you haven't yet, start by creating an account on our developer console.
  2. Go to the API key section of the developer console and create a new API key with the following scopes: wallets.read, wallets.create, and wallets:nfts.read
  3. Make a note of your project ID and API key secret, as you will need them to create wallets.

Creating a Wallet

To create a wallet, you can pass the following parameters to our API:

  • email: Email address that should be used to create Crossmint user and wallets (contact us if you'd like a unique identifier other than email to be used for wallet creation)
  • chain: Chain for which wallet should be created on. Options are ethereum, polygon, bsc, solana, and cardano
import fetch from 'node-fetch';

const body = {
  email: "<YOUR_USERS_EMAIL>", 
  chain: "<TARGET_CHAIN>",  
}

const response = await fetch(
  `https://staging.crossmint.com/api/v1-alpha1/wallets`,
  {
    method: 'POST',
    headers: {
      'X-PROJECT-ID': '<YOUR_PROJECT_ID>',
      'X-CLIENT-SECRET': '<YOUR_CLIENT_SECRET>',
      'content-type': 'application/json'
    },
    body: JSON.stringify(body),
  }
);

const wallet = await response.json();

Possible Responses

The API may return the following response codes:

CodeUser visible messageExample of successful response
201The wallet was created successfully. The response body contains the public key and chain of the new wallet.{ publicKey: “123”, chain: “solana” }
400The request was invalid. The response body contains a user-visible error message.{
"message": "Email is not included or is not in the correct format 'xxx@xxx.__'"
}
401The request was unauthorized. The response body contains a user-visible error message.

You can either store wallets on your end or fetch wallets via API on demand. To fetch wallets, simply pass the email you used to create the wallet to the following endpoint

curl --request GET \
     --url 'https://staging.crossmint.com/api/v1-alpha1/wallets?email=youremailhere%40gmail.com' \
     --header 'X-CLIENT-SECRET: <YOUR_PROJECT_ID>' \
     --header 'X-PROJECT-ID: <YOUR_CLIENT_SECRET>' \
     --header 'accept: application/json'

Implementation Notes

  • In order for your users to interact with the newly created wallet, you'll need to create a UI for them. Alternatively, you can direct them to Crossmint.com, where they can manage their assets.
  • If the user already had a wallet with the same email and chain, no new wallet will be created. The existing wallet will be returned instead. The POST endpoint will POST or GET (if user wallet exists)
  • We currently do not perform any email/user validation on the passed email parameter. If you'd like to add authentication, we are integrated with leading providers like Stytch.
  • Want a different user identifier than email? Contact us - we can enable any arbitrary string to be used as a map to a wallet address. The API follows the same approach as above, so implementation is simple