Onboarding new users to Web 3 has always remained a challenge. In order to provide an excellent user experience, you need to ensure that the Web 3 integration in your app remains invisible. A great way to do this would be to create custodial wallets for your users using their email address or any userId.
This guide will show you how to create custodial wallets for your users on Ethereum using Crossmint.
By the end, you will learn how to:
- Use Crossmint's APIs.
- Create custodial wallets for your users.
This guide will take you 10 mins to complete (approximately).
Let's get started!
Table of Contents:
Setup
In this section, you will learn how to create wallets at scale with Crossmint's API. There are two different environments, they are staging and production environments.
- Production - to operate on the blockchain’s mainnets. Operations may incur credit costs. Accessible from crossmint.com/console
- Staging - to build on blockchain’s testnets. Used for testing and free. Accessible from staging.crossmint.com/console
Note: We will be the Production environment for this guide. However, it is recommended that you use the Staging environment to familiarize yourself with the process, and then proceed to the Production environment.
Creating a Developer Account and API Key
To get started, make sure that you have a Crossmint developer account. If not, please sign up - Crossmint Console.
After that, follow these steps:
- Navigate to API Keys Section: Log into Crossmint's Console and navigate to "Developers" section and click on "API Keys".
- Choose the Type of API Key: Opt for a Server-side API Key (you can also create email wallets using a client side key).
- Select Scopes: Select scopes that determine the API key’s access level. Essential scopes include:
- "wallets.read"
- "wallets.create"
You need the scopes specified above to create wallets.
![](https://blog.crossmint.com/content/images/2024/05/image-29.png)
Create Custodial Wallets on Ethereum
Now that you have everything set up, let's look at how you can create a custodial wallet on Ethereum.
First create a Javascript code file on your computer and then paste the below boilerplate-code within that code file.
const options = {
method: "POST",
headers: { "X-API-KEY": "<your-api-key-here>", "Content-Type": "application/json" },
body: '{"email":"yourEmail@email.com","chain":"ethereum"}',
};
fetch("https://www.crossmint.com/api/v1-alpha1/wallets", options)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
createWallet.js
- Ensure that you replace "<your-api-key-here>" with the API key that you created earlier.
- Replace "yourEmail@email.com" with the actual email address of the user that you are trying to create the wallet for. This will create a wallet that will be associated to the email address used.
- You can also create wallets using a "userId" instead. Replace "anyUserId" with any value of userId that you want to assign to a user. This value is of String type.
const options = {
method: "POST",
headers: { "X-API-KEY": "<your-api-key-here>", "Content-Type": "application/json" },
body: '{"userId":"anyUserId","chain":"ethereum"}',
};
fetch("https://www.crossmint.com/api/v1-alpha1/wallets", options)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
createWallet.js
After that, you can run the code file on your terminal using Node.
💡 Hint: You can run "node fileName.js" to execute the code.
After you run the code, i.e., make the API call to Crossmint's endpoint, you will receive a response.
{
chain: 'ethereum',
publicKey: '0xyourAddress'
}
The "publicKey" is the wallet address of the wallet created for your user on Ethereum.
Conclusion
In this guide, we learned how to create wallets for your users on Ethereum, starting with creating an API key with the appropriate scopes to creating the wallet.
And that's it! You have now learned how to create wallets for your users on Ethereum using Crossmint.
What's Next?
If you are wondering how Crossmint has helped enterprises and brands by powering their NFT Drops, you can click on the link below to read all our Case Studies.
![](https://i.imgur.com/tsAYrpc.png)
If you want to learn how to use the Crossmint to create and mint NFTs on Ethereum, please read the step-by-step guide below.
![](https://blog.crossmint.com/content/images/2024/05/how-to-create-nfts-on-ethereum.png)
Need help?
For support, please join the official Crossmint Discord Server. You can also use Crossmint Help Page for the same.
![Sign up developer console](https://blog.crossmint.com/content/images/2024/03/Frame-427319761-1.png)