Skip to main content

@faremeter/wallet-crossmint

@faremeter/wallet-crossmint adapts Crossmint Wallets to the shape expected by @faremeter/payment-solana. It authenticates with Crossmint’s API, fetches a wallet, and exposes the minimal interface required to build/send transactions.

Quick start

import { createCrossmintWallet } from "@faremeter/wallet-crossmint";

const wallet = await createCrossmintWallet(
  "mainnet-beta",
  process.env.CROSSMINT_API_KEY!,
  "cmw1abc123...", // Crossmint wallet identifier
);

const handler = createPaymentHandler(
  wallet,
  usdcMint,
  connection,
);
The returned wallet implements:
  • network: string passed straight through ("devnet", "mainnet-beta", etc.).
  • publicKey: Solana PublicKey derived from the Crossmint wallet.
  • sendTransaction(tx): sends a VersionedTransaction via Crossmint’s API and resolves with the transaction hash.
Provide it directly to @faremeter/payment-solana/exact.createPaymentHandler.

API surface

createCrossmintWallet(network, crossmintApiKey, walletAddress)

  • network: arbitrary label used by your application (matches the facilitator’s expectations).
  • crossmintApiKey: Crossmint API key with the wallets scope.
  • walletAddress: Crossmint wallet identifier (obtained from their dashboard or API).
Implementation details:
  • Uses createCrossmint and CrossmintWallets.from under the hood.
  • Fetches the wallet with { chain: "solana", signer: { type: "api-key" } }.
  • Wraps the wallet in Crossmint’s SolanaWallet helper to get sendTransaction.
  • Converts the wallet’s base58 address into a PublicKey instance.
Errors from the Crossmint SDK bubble up. Handle them where you call the function to provide better user messaging (e.g., “invalid API key”).

Usage patterns

  • Separate facilitator wallet: This adapter is client-facing. Pair it with @faremeter/payment-solana for buyers, while the facilitator can use a different wallet (local keypair, ledger, etc.).
  • Multiple wallets: Call createCrossmintWallet once per wallet identifier. Cache the result if you’re reusing the same wallet across requests.
  • Edge runtimes: The Crossmint SDK relies on fetch; ensure the runtime you target supports it or polyfill accordingly.
  • @faremeter/payment-solana: consumes the wallet object to build transactions.
  • @faremeter/wallet-ledger / @faremeter/wallet-solana: alternative wallet adapters with similar interfaces.
  • Source: GitHub › packages/wallet-crossmint