Enterprise feature. Contact us for access.

Introduction

Before integrating a memecoin or token using Crossmint’s checkout, it’s important to verify that it’s supported by Crossmint. This guide will show you how to use the Crossmint API to check if a specific token is supported and what features are available for it.

Prerequisites

1

Create a server-side API key

Get your API keys from the Crossmint Console

Once you log in to the console, the next step is to create an .

Click the "Integrate" tab and click on the "API Keys" option on top.

More info on creating API keys here

2

Enable the orders.create scope

Make sure the orders.create scope is enabled for your API key.

Getting Started

The Supported Tokens API allows you to query the status of any token to determine if it’s supported by Crossmint and what features are available.

  • Endpoint: https://www.crossmint.com/api/v1-alpha2/tokens/:tokenLocator
  • Method: GET
  • Authentication: Requires either a server or client API key

Token Locator Format

Currently, memecoin checkout only supports the Solana network.

The token locator follows this format:

network:tokenAddress

Example:

  • TRUMP: solana:6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN

Checking Token Support

Using JavaScript

Here’s how to check if a token is supported using JavaScript:

// Example usage
const apiKey = "your-api-key"; // Replace with your actual API key
const tokenLocator = "solana:6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN"; // Example: TRUMP token

const checkTokenSupport = async (apiKey, tokenLocator) => {
    try {
        const response = await fetch(`https://www.crossmint.com/api/v1-alpha2/tokens/${tokenLocator}`, {
            method: "GET",
            headers: {
                "X-API-KEY": apiKey,
                "Content-Type": "application/json",
            },
        });

        const data = await response.json();
        return data;
    } catch (error) {
        console.error("Error checking token support:", error);
        throw error;
    }
};

checkTokenSupport(apiKey, tokenLocator)
    .then((result) => {
        console.log("Token support details:", result);

        if (result.available) {
            console.log("This token is supported by Crossmint!");
        } else {
            console.log("This token is not currently supported.");
        }

        console.log("Available features:", result.features);
    })
    .catch((err) => {
        console.error("Failed to check token support:", err);
    });

Sample Response

A successful response will look similar to this:

{
    "token": "solana:6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
    "available": true,
    "features": {
        "creditCardPayment": true
    }
}

Integrating with Your Checkout Flow

Once you’ve confirmed that a token is supported, you can use the information from the API response to customize your checkout experience.

Example: Pre-checkout Validation

Here’s an example of how to incorporate token support checking before initiating a checkout:

const initiateCheckout = async (apiKey, tokenLocator, amount, recipientWallet) => {
    // First, check if the token is supported
    const tokenSupport = await checkTokenSupport(apiKey, tokenLocator);

    if (!tokenSupport.available) {
        throw new Error("This token is not currently supported by Crossmint.");
    }

    if (!tokenSupport.features.creditCardPayment) {
        throw new Error("Credit card payment is not available for this token.");
    }

    // If we get here, the token is supported with credit card checkout
    // Proceed with creating an order
    const orderResponse = await fetch("https://www.crossmint.com/api/2022-06-09/orders", {
        method: "POST",
        headers: {
            "X-API-KEY": apiKey,
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            lineItems: {
                tokenLocator: tokenLocator,
                executionParameters: {
                    mode: "exact-in",
                    amount: amount,
                    maxSlippageBps: "500",
                },
            },
            payment: {
                method: "stripe-payment-element",
                receiptEmail: "user@example.com", // Replace with user's email
            },
            recipient: {
                walletAddress: recipientWallet,
            },
        }),
    });

    return await orderResponse.json();
};

Best Practices

  1. Cache Results (with caution): Token support status can change, but for frequently accessed tokens, consider caching results for a short period (e.g., 1 hour) to reduce API calls.

  2. Handle Errors Gracefully: Implement proper error handling to provide clear feedback to users when a token is not supported.

  3. Check Before Displaying Options: Only display payment methods that are actually available for the token.

Next Steps

FAQ