Skip to main content
This guide walks you through creating a Treasury Wallet — a company-owned wallet for managing stablecoins — and performing basic operations like funding and checking balances. For background on what Treasury Wallets are and when to use them, see the Treasury Wallets concept page.

Prerequisites

Before you start

Set up your project and get an API key.
Enterprise feature. Contact us for access.

Create a Treasury Wallet

1

Install the SDK

Run the following command to install the SDK:
npm i @crossmint/wallets-sdk
2

Create a treasury wallet

See all supported chains here.
import { CrossmintWallets, createCrossmint } from "@crossmint/wallets-sdk";

const crossmint = createCrossmint({
    apiKey: "<your-server-api-key>",
});

const crossmintWallets = CrossmintWallets.from(crossmint);

const wallet = await crossmintWallets.createWallet({
    chain: "base-sepolia",
    recovery: { type: "server", secret: "<your-recovery-secret>" },
    owner: "COMPANY",
    alias: "treasury",
});

console.log(wallet.address);
Key Points:
  • The owner field must be set to "COMPANY" for treasury wallets to ensure the wallet appears under Company in the console
  • The recovery signer must be a non-custodial type (external-wallet, passkey, or server)
  • The alias field is set to "treasury" to identify this as your treasury wallet
  • A server signer is suitable for low-risk use-cases. For higher-risk use-cases, use an external-wallet signer via Cloud KMS
3

Fund and check treasury wallet balance

Fund the wallet using the SDK, then check the balance:
import { CrossmintWallets, createCrossmint } from "@crossmint/wallets-sdk";

const crossmint = createCrossmint({
    apiKey: "<your-server-api-key>",
});

const crossmintWallets = CrossmintWallets.from(crossmint);

const treasuryWallet = await crossmintWallets.getWallet("<your-wallet-address>", {
    chain: "base-sepolia",
});
// Fund the wallet (staging only)
await treasuryWallet.stagingFund(10);

// Check balance
const balances = await treasuryWallet.balances(["usdc"]);
console.log(balances.usdc.amount);
4

Run the code

Execute your index.ts file using one of the following methods:Using ts-node:
npx ts-node index.ts
Or compile and run with Node.js:
npx tsc index.ts && node index.js
You should see the wallet address printed to the console after successful execution.
5

Verify in the console

After creating your treasury wallet, you can verify it was created correctly in the Crossmint Console:
  1. Navigate to Wallets in the left sidebar
  2. Click on the Company tab
  3. Your treasury wallet should appear in the list with the alias “treasury”

Launching in Production

Enterprise feature. Contact us for access.
For production, the steps are almost identical, but some changes are required:
  1. Create a developer account on the production console
  2. Create a production server API key on the API Keys page with the API scopes wallets.read, wallets.create, wallets:transactions.create, wallets:transactions.sign, wallets:balance.read, wallets.fund
  3. Replace your test API key with the production key
  4. Discuss with your Crossmint Customer Success Engineering (CSE) team the best signer configuration for your expected usage, and recovery mechanisms

Next Steps

Check Balances

Check the balance of a wallet.

Funding the Wallet

Learn how to fund your treasury wallet.

Withdrawals

Withdraw stablecoins to your bank account.

Payouts

Send stablecoins to your customers and vendors.