Create Wallets
Generate wallets on-demand for your users by passing an email (or any user identifier) to our create wallet API. Get started in 5 minutes by following the next steps:
Prerequisites:
- Create an account on our developer console if you haven't yet.
- Go to the API key section of the developer console and create a new API key with the following scopes:
wallets.read
,wallets.create
, andwallets:nfts.read
- 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
: User email address. Contact us if you wish to pass an arbitrary string as a UUID instead of an email.chain
: Blockchain in which you'd like to create the wallet:
arbitrum
,arbitrumnova
,base
,bsc
,cardano
,ethereum
,optimism
,polygon
,solana
andzora
.
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:
Code | User visible message | Example of successful response |
---|---|---|
201 | The wallet was created successfully. The response body contains the public key and chain of the new wallet. | { publicKey: “123”, chain: “solana” } |
400 | The 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.__'"} |
401 | The request was unauthorized. The response body contains a user-visible error message. |
Fetching your User's Wallets
Retrieve a user's wallet address at any time with the Fetch wallet 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
- Users can interact with the wallet from your website or (optional) from Crossmint.com by logging in with the same email.
- If you had already created a wallet for the same user on the same chain, no new wallet will be created. Instead, the API will return the existing wallet address.
- The API currently does not perform any email/user validation on the passed email parameter.
Updated 21 days ago