Welcome! In this guide, we will be diving into USDC wallet creation. By the end, you will be able to create embedded USDC wallets for your users using the Crossmint Wallet API.
There are many ways to integrate embedded USDC wallets into your app: client side, server side, or with dual key architectures. For this example, you will learn how to deploy your first embedded USDC wallet server side. These embedded USDC wallets are enterprise-grade and work seamlessly with Crossmint’s all-in-one stablecoin platform - complete with onramp, compliance and tokenization tools.
For any assistance, reach out to us here.
Prerequisites
- Create a developer account in the Crossmint Staging Console.
- Navigate to project Settings > General and change the wallet type to “Smart Wallets”.
- Select "Smart Wallets" in your Crossmint dashboard
- You can get an API Key by going to Integrate > API Keys and selecting “Create new key” in the “Server-side keys” section.
- Under the Wallets API category, select the following scopes:
- wallets.create
- wallets.read
- wallets:signatures.create
- wallets:transactions.create
- wallets:transactions.read
- wallets:transactions.sign
- Click “Create server key” to save the key for the next step.
Create Your First USDC Wallet
Create a file (e.g., createWallet.ts) and enter this code:
const apiKey = "YOUR_API_KEY";
const walletType = "solana-smart-wallet";
const adminSigner = {
// In production, you may want to use an MPC solution, like
// crossmint-managed MPC keys
type: "solana-keypair",
};
async function createWallet() {
const response = await fetch("https://staging.crossmint.com/api/2022-06-09/wallets", {
method: "POST",
headers: {
"X-API-KEY": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
type: walletType,
config: {
adminSigner,
},
}),
});
return await response.json();
}
createWallet()
.then((json) => console.log(json))
.catch((err) => console.error(`error: ${err}`));
Before running it, fill in YOUR_API_KEY with the key obtained in the previous step.
Now, run the script:
npx tsx createWallet.ts
The API will return a response with your new wallet details.
Save the wallet address, as you’ll use it in the next step.
Interact with your USDC Wallet
Now that we have wallets set up on your server, let’s interact with them.
Start by visiting Crossmint Testnet USDXM Faucet and paste your wallet address from the step above to receive test USDXM on Solana.
- USDXM is a testnet stablecoin used to make sure USDC wallets are working properly within your staging app.
Now that you have some tokens, let’s check the wallet’s balance (checkBalance.ts):
const apiKey = "YOUR_API_KEY";
const walletAddress = "YOUR_WALLET_ADDRESS"; // From previous step
const tokens = ["sol", "usdc", "usdxm"]; // Tokens to fetch balances for
const chains = ["solana"]; // Chains to query balances from
async function getWalletBalance() {
const url = new URL(`https://staging.crossmint.com/api/v1-alpha2/wallets/${walletAddress}/balances`);
url.search = new URLSearchParams({
tokens: tokens.join(','),
chains: chains.join(',')
}).toString();
const response = await fetch(url, {
method: "GET",
headers: {
"X-API-KEY": apiKey,
"Content-Type": "application/json",
},
});
return await response.json();
}
getWalletBalance()
.then((json) => console.log(json))
.catch((err) => console.error(`error: ${err}`));
Congrats - you now have smart wallets deployed on your server!
Next Steps
You can explore the documentation from here to learn how to make your first transaction, add delegated signers, and more.
Need Support?
- Contact our Sales Team
- Join the Crossmint Discord Server
- Visit the Crossmint Help Page