Builds on-ramp and off-ramp widget URLs for multiple fiat-to-crypto (and crypto-to-fiat) providers, and provides CEX deposit memo helpers.

Construct once with your API keys and reuse across the application. All URL-building methods are synchronous — no network call is made.

Supported providers: MoonPay, Transak, Ramp Network, Banxa.

import { OffRampIntegration } from '@stellar/c-address-onboarding-bridge-sdk';

const offramp = new OffRampIntegration({
moonpayApiKey: process.env.MOONPAY_KEY,
transakApiKey: process.env.TRANSAK_KEY,
testMode: process.env.NODE_ENV !== 'production',
});

// On-ramp: user pays $100 USD, receives XLM at their C-address
const url = offramp.getOnRampUrl({
provider: 'moonpay',
amount: '100',
fiatCurrency: 'USD',
asset: 'XLM',
cAddress: 'CC...',
});
window.open(url);

Constructors

Methods

  • Compare all providers for a given transaction and return fee/settlement data.

    Filters to providers that support both asset and fiatCurrency, then calculates the fee amount, net amount, and approximate settlement time for each. Useful for rendering a "best rate" comparison UI.

    Parameters

    • amount: string

      Gross fiat amount as a decimal string (e.g. '100').

    • asset: string

      Crypto asset code (e.g. 'XLM', 'USDC').

    • fiatCurrency: string = 'USD'

      ISO 4217 fiat currency code (default 'USD').

    Returns Partial<Record<OffRampProvider, ProviderComparison>>

    A partial record mapping each supported provider to a ProviderComparison object. Providers that do not support the asset or currency are omitted.

    const results = offramp.compareProviders('100', 'XLM', 'USD');
    // { moonpay: { feeAmount: '4.50', netAmount: '95.50', settlementTime: 2 }, ... }
  • Decode a CEX deposit memo to extract the target C-address.

    Use this on the bridge relayer side when a Stellar payment arrives with a memo to determine which C-address should receive the funds.

    Parameters

    • memo: string

      The raw memo string from the incoming Stellar payment.

    Returns null | string

    The extracted C-address string, or null if the memo is not a valid bridge memo (i.e. does not start with "bridge:").

    const target = offramp.decodeCEXDepositMemo('bridge:CC...');
    // → 'CC...'

    const invalid = offramp.decodeCEXDepositMemo('some-other-memo');
    // → null
  • Generate a Stellar memo that encodes a target C-address for CEX routing.

    When a user withdraws from a centralized exchange to the bridge's G-address, they must include this memo so the bridge can identify the intended destination C-address.

    Memo format: "bridge:<targetCAddress>"

    Parameters

    • targetCAddress: string

      The C-address that should receive the bridged funds.

    Returns string

    A memo string in the format "bridge:<targetCAddress>".

    const memo = offramp.generateCEXDepositMemo('CC...');
    // → 'bridge:CC...'
    // User pastes this into their CEX withdrawal memo field
  • Parameters

    • params: {
          amount: string;
          assetCode?: string;
          currency: string;
          targetCAddress: string;
      }
      • amount: string
      • OptionalassetCode?: string
      • currency: string
      • targetCAddress: string

    Returns string

    Use getOnRampUrl() instead Generate a Moonpay purchase URL to fund a C-address via credit card.

  • Build a widget URL for selling crypto for fiat (off-ramp).

    Redirects the user to the selected provider's sell page where they send params.asset from params.gAddress and receive fiat currency.

    Parameters

    • params: OffRampUrlParams

      Provider, crypto amount, crypto asset, fiat currency, and source G-address.

    Returns string

    A fully-formed URL string.

    If params.provider is not one of the supported values.

    const url = offramp.getOffRampUrl({
    provider: 'moonpay',
    amount: '10',
    asset: 'XLM',
    fiatCurrency: 'USD',
    gAddress: 'G...',
    });
  • Build a widget URL for purchasing crypto with fiat (on-ramp).

    Redirects the user to the selected provider's checkout page where they pay with a credit card or bank transfer and receive params.asset at params.cAddress on Stellar.

    Parameters

    • params: OnRampUrlParams

      Provider, fiat amount, fiat currency, crypto asset, and destination C-address.

    Returns string

    A fully-formed URL string ready for window.open() or a webview.

    If params.provider is not one of the supported values.

    const url = offramp.getOnRampUrl({
    provider: 'transak',
    amount: '50',
    fiatCurrency: 'EUR',
    asset: 'USDC',
    cAddress: 'CC...',
    });
  • Get the static capability configuration for a provider.

    Returns supported assets, fiat currencies, countries, amount limits, fee percentage, and test-mode availability. Useful for rendering provider selection UI or filtering by user's country and preferred currency.

    Parameters

    Returns ProviderConfig

    A ProviderConfig object with the provider's capabilities.

    const config = offramp.getProviderConfig('moonpay');
    console.log(config.supportedCountries); // ['US', 'GB', ...]
    console.log(config.feePercentage); // '4.5'
  • Parameters

    • params: {
          amount: string;
          currency: string;
          fiatCurrency?: string;
          targetCAddress: string;
      }
      • amount: string
      • currency: string
      • OptionalfiatCurrency?: string
      • targetCAddress: string

    Returns string

    Use getOnRampUrl() instead Generate a Transak purchase URL to fund a C-address via credit card.