A Typescript SDK to interact with Crossmint Wallets. This SDK enables developers to easily create and manage wallets on Solana and EVM chains.
npm install @crossmint/wallets-sdkA Typescript SDK to interact with Crossmint Wallets. This SDK enables developers to easily create and manage wallets on Solana and EVM chains.
Get a Crossmint client API key from here and add it to your .env file. Make sure your API key has all scopes for Wallet API, and Users.
``bash`
pnpm install @crossmint/wallets-sdk
`ts
import { CrossmintWallets, createCrossmint } from "@crossmint/wallets-sdk";
const crossmint = createCrossmint({
apiKey: "
experimental_customAuth: {
jwt: "
},
});
const crossmintWallets = CrossmintWallets.from(crossmint);
const wallet = await crossmintWallets.getOrCreateWallet({
chain: "
signer: {
type: "email",
email: "
onAuthRequired: async (needsAuth, sendEmailWithOtp, verifyOtp, reject) => {
if (needsAuth) {
await sendEmailWithOtp();
// Prompt the user to check their email for the OTP code.
// Once the user provides the OTP, pass it to verifyOtp(otp).
// NOTE: If using our React/React Native SDK, this is handled automatically by the provider.
}
},
},
});
console.log(wallet.address);
`
`ts
const balances = await wallet.balances();
console.log(balances.nativeToken.amount);
console.log(balances.usdc.amount);
`
`ts
const transaction = await wallet.send(recipient, "usdc", "100");
console.log(transaction.explorerLink);
`
`ts
const activity = await wallet.experimental_activity();
console.log(activity.events);
`
`ts
// Add a delegated signer
await wallet.addDelegatedSigner({ signer: "
const signers = await wallet.delegatedSigners();
console.log(signers);
`
`ts
import { SolanaWallet, EVMWallet } from "@crossmint/wallets-sdk";
// Solana
const solanaWallet = SolanaWallet.from(wallet);
const solTx = await solanaWallet.sendTransaction({ transaction: "
console.log(solTx.explorerLink);
// EVM
const evmWallet = EVMWallet.from(wallet);
const evmTx = await evmWallet.sendTransaction({ transaction: "
console.log(evmTx.explorerLink);
``