Examples

Overview

This page provides complete, working examples for common FastMint and Burn API workflows in multiple programming languages.

Table of Contents


Authentication

JavaScript/TypeScript

const ISSUANCE_REDEMPTION_API_URL = 'https://api.universal.xyz/issuance-redemption';
const AUTH_API_URL = 'https://api.universal.xyz/auth';
const API_KEY = process.env.API_KEY; // Format: keyId.secret

interface TokenResponse {
  token: string;
  expiresAt: number;
}

async function issueToken(walletAddress: string): Promise<string> {
  const response = await fetch(`${AUTH_API_URL}/token`, {
    method: 'POST',
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ walletAddress }),
  });

  if (!response.ok) {
    throw new Error(`Failed to issue token: ${response.statusText}`);
  }

  const data: TokenResponse = await response.json();
  return data.token;
}

async function refreshToken(walletAddress: string): Promise<string> {
  const response = await fetch(`${AUTH_API_URL}/token/refresh`, {
    method: 'POST',
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ walletAddress }),
  });

  if (!response.ok) {
    throw new Error(`Failed to refresh token: ${response.statusText}`);
  }

  const data: TokenResponse = await response.json();
  return data.token;
}

// Usage
const walletAddress = '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b1';
const token = await issueToken(walletAddress);
console.log('JWT Token:', token);

Python

cURL


Mint Workflow

JavaScript/TypeScript

Python


Burn Workflow

JavaScript/TypeScript

Python

XRP Burn Example (with Memo)


Order Tracking

JavaScript/TypeScript


Complete Integration

Full Mint and Burn Integration

Next Steps

Last updated