In this quickstart you will learn how to create and manage wallets using a REST API from a server environment.

Integration Steps

1

Create a Developer Account and Project

To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.

Crossmint offers two consoles: staging, for development and testing, and www, for production.

Then, navigate to project Settings > General:

  • For EVM chains: Set the wallet type to “Smart Wallets”
  • For all other chains: Set the wallet type to “Custodial Wallets”

2

Get an API Key

Create a server-side API key with these scopes:

Navigate to the "Integrate" section on the left navigation bar, and ensure you're on the "API Keys" tab.

Within the Server-side keys section, click the "Create new key" button in the top right.

Next, check the scopes labeled wallets.create, wallets.read, wallets.fund, wallets:balance.read, wallets:transactions.create, wallets:transactions.read, wallets:transactions.sign.

Finally, create your key and save it for subsequent steps.

This allows your API key to perform any kind of wallet action.

3

Choose a Wallet Type

Below is a summary of available wallet types and their characteristics:

ChainCustodialTypeAdmin Signer
EVMTrueevm-smart-walletevm-fireblocks-custodial
EVMFalseevm-smart-walletevm-keypair
EVMTrueevm-mpc-walletNone
SolanaTruesolana-smart-walletsolana-fireblocks-custodial
SolanaFalsesolana-smart-walletsolana-keypair
SolanaTruesolana-mpc-walletNone
AptosTrueaptos-mpc-walletNone
AptosFalseContact SupportContact Support
CardanoTruecardano-mpc-walletNone
CardanoFalseContact SupportContact Support
SuiTruesui-mpc-walletNone
SuiFalseContact SupportContact Support
4

Create Your First Wallet

Create a file (e.g. createWallet.ts) and enter this code:

const apiKey = "YOUR_API_KEY";
const walletType = "evm-smart-wallet"; // Enter the Type from the table above
const adminSigner = {
    // Enter admin signer from table above, or leave undefined
    type: "evm-fireblocks-custodial",
};

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, be sure to fill in:

  • YOUR_API_KEY with the key obtained in step 2
  • Choose your desired wallet type and admin signer from the table above

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.

5

Interact with Your Wallet

First, let’s get some test USDC to work with. Visit Crossmint Testnet USDXM Faucet and paste your wallet address from step 4 to receive test USDC tokens in your chain of choice.

Now that you have some tokens, let’s check the wallet’s balance:

const apiKey = "YOUR_API_KEY";
const walletAddress = "YOUR_WALLET_ADDRESS"; // From step 4
const tokens = ["eth", "usdc", "usdxm"]; // Tokens to fetch balances for
const chains = ["base-sepolia", "polygon-amoy"]; // 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}`));

More info

Launching in Production

For production, the steps are almost identical, but some changes are required:

  1. Create a developer account on the production console
  2. Add credits to your account from Billing & Usage
  3. Create a production key on the API Keys page with the same API scopes
  4. Modify all code snippets to use https://www.crossmint.com instead of https://staging.crossmint.com

Learn More

Dive into Advanced Topics