Welcome! In this guide, we will be diving into USDC wallet creation using the Crossmint Wallet API. Crossmint’s wallet infrastructure allows you to create USDC wallets for users, companies or agents in a few lines of code, client or server-side. Key benefits for using Crossmint wallets include:
- Web2 UX: Gasless. For you and your users. No transaction approval prompts or other blockchain gimmicks.
- Flexible custody: Choose between non-custodial, custodial, or hybrid architectures, and change any time with minimal user disruption.
- Flexible auth: Compatible with virtually any authentication solution. And if you don’t have one, use Crossmint Auth.
- Programmable accounts: Native gas sponsorship, single balance across chains, granular policies enforced cryptographically, embedded compliance modules, and more.
- Bank-grade security: Trusted by major financial institutions. SOC2 T-II compliance. Crossmint holds a VASP license and is under MiCA review.
- Integrated as a platform with the rest of tools, including onramps, auth, checkout and minting for generating wallets on-the-fly, and unified dashboards to manage users, wallets, tokens, and onchain analytics.
- No vendor lock-in: Migrate wallet providers at any time with limited impact to users - no change in wallet address, no need to export keys.
For this example, you will learn how to deploy your first embedded USDC wallet server side. If you need 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