Skip to main content

RampsService Actions

10 actions registered.

NameDeprecated
getBuyWidgetUrl
getCountries
getDefaultRedirectCallbackUrl
getGeolocation
getOrder
getOrderFromCallback
getPaymentMethods
getProviders
getQuotes
getTokens

RampsService:getBuyWidgetUrl​

Package: @metamask/ramps-controller

Fetches the buy widget data from a buy URL endpoint. Makes a request to the buyURL (as provided in a quote) to get the actual provider widget URL, browser type, and order ID.

The URL must be on the ramps API origin for this service's environment (for example https://on-ramp.api.cx.metamask.io in production). A URL from any other origin is rejected before the request is made, because the request carries the bearer token. baseUrlOverride does not change the origin a buy URL may use.

Parameters:

NameDescription
buyUrlThe full buy URL endpoint to fetch from.

Returns: The buy widget data containing the provider widget URL.

Handler signature:

(buyUrl: string) => Promise<BuyWidget>

RampsService:getCountries​

Package: @metamask/ramps-controller

Makes a request to the cached API to retrieve the list of supported countries. The API returns countries with support information for both buy and sell actions. Filters countries based on aggregator support (preserves OnRampSDK logic).

Returns: An array of countries filtered by aggregator support.

Handler signature:

() => Promise<Country[]>

RampsService:getDefaultRedirectCallbackUrl​

Package: @metamask/ramps-controller

Returns the default redirect ("fake callback") URL for this service's environment.

The quotes API only embeds a buyURL/buyWidget (the WebView page a non-native provider needs) when a redirectUrl is present, so callers that omit one (MM Pay's widened Headless Buy fetch) use this value. Exposing it here makes the service's environment the single runtime source of truth, so the callback can never point at a different environment than the one the quotes themselves came from.

baseUrlOverride deliberately does not apply. That option overrides the ramps API base URL for local development. In production and staging the callback lives on a different host (on-ramp-content versus on-ramp{-cache}), so an API override says nothing about where /regions/fake-callback lives. In development the callback already shares the API host family (on-ramp.dev-api). The redirect URL is also handed to the provider and matched by client UI to detect flow completion, so returning an unrelated local API origin here would break completion detection rather than help it. Point environment at RampsEnvironment.Local for a localhost callback, noting that URL is pinned to http://localhost:3000 and does not follow a non-3000 baseUrlOverride.

Returns: The default redirect callback URL for the configured environment.

Handler signature:

() => string

RampsService:getGeolocation​

Package: @metamask/ramps-controller

Makes a request to the API in order to retrieve the user's geolocation based on their IP address.

Returns: The user's country/region code (e.g., "US-UT" for Utah, USA).

Handler signature:

() => Promise<string>

RampsService:getOrder​

Package: @metamask/ramps-controller

Fetches an order from the unified V2 API endpoint. This endpoint returns a normalized RampsOrder (DepositOrder shape) for all provider types, including both aggregator and native providers.

Parameters:

NameDescription
providerCodeThe provider code (e.g., "transak", "transak-native", "moonpay"), with or without the /providers/ prefix.
orderCodeThe order identifier.
walletThe wallet address associated with the order.

Returns: The unified order data.

Handler signature:

(providerCode: string, orderCode: string, wallet: string) => Promise<RampsOrder>

RampsService:getOrderFromCallback​

Package: @metamask/ramps-controller

Extracts an order from a provider callback URL. Sends the callback URL to the V2 API backend, which knows how to parse each provider's callback format and extract the order ID. Then fetches the full order using that ID.

This is the V2 equivalent of the aggregator SDK's getOrderFromCallback.

Parameters:

NameDescription
providerCodeThe provider code (e.g., "transak", "moonpay"), with or without the /providers/ prefix.
callbackUrlThe full callback URL the provider redirected to.
walletThe wallet address associated with the order.

Returns: The unified order data.

Handler signature:

(providerCode: string, callbackUrl: string, wallet: string) => Promise<RampsOrder>

RampsService:getPaymentMethods​

Package: @metamask/ramps-controller

Fetches the list of payment methods for a given region, asset, and provider.

Region local fiat filtering is applied server-side when fiat is omitted.

Parameters:

NameDescription
optionsQuery parameters for filtering payment methods.
options.regionUser's region code (e.g., "us-al").
options.assetIdCAIP-19 cryptocurrency identifier. Kept on the caller contract for local cache/staleness; not sent — /payments is scoped to provider + region (the API ignores crypto).
options.providerProvider ID path.

Returns: The payment methods response containing payments array.

Handler signature:

(options: {
region: string;
assetId: string;
provider: string;
}) => Promise<PaymentMethodsResponse>

RampsService:getProviders​

Package: @metamask/ramps-controller

Fetches the list of providers for a given region. Supports optional query filters: provider, crypto, payments. Region local fiat filtering is applied server-side when fiat is omitted.

Parameters:

NameDescription
regionCodeThe region code (e.g., "us", "fr", "us-ny").
optionsOptional query parameters for filtering providers.
options.providerProvider ID(s) to filter by.
options.cryptoCrypto currency ID(s) to filter by.
options.paymentsPayment method ID(s) to filter by.

Returns: The providers response containing providers array.

Handler signature:

(regionCode: string, options?: {
provider?: string | string[];
crypto?: string | string[];
payments?: string | string[];
}) => Promise<ProvidersResponse>

RampsService:getQuotes​

Package: @metamask/ramps-controller

Fetches quotes from all providers for a given set of parameters. Uses the V2 orders API to get quotes for multiple payment methods at once.

Parameters:

NameDescription
paramsThe parameters for fetching quotes.
params.regionUser's region code (e.g., "us", "us-ca").
params.paymentMethodsArray of payment method IDs.
params.assetIdCAIP-19 cryptocurrency identifier.
params.fiatFiat currency code (e.g., "usd").
params.amountThe amount (in fiat for buy, crypto for sell).
params.walletAddressThe destination wallet address.
params.redirectUrlOptional redirect URL after order completion.
params.providersOptional provider IDs to filter quotes.
params.actionThe ramp action type. Defaults to 'buy'.

Returns: The quotes response containing success, sorted, error, and customActions.

Handler signature:

(params: GetQuotesParams) => Promise<QuotesResponse>

RampsService:getTokens​

Package: @metamask/ramps-controller

Fetches the list of available tokens for a given region and action. Supports optional provider filter.

Parameters:

NameDescription
regionThe region code (e.g., "us", "fr", "us-ny").
actionThe ramp action type ('buy' or 'sell').
optionsOptional query parameters for filtering tokens.
options.providerProvider ID(s) to filter by.

Returns: The tokens response containing topTokens and allTokens.

Handler signature:

(region: string, action?: RampAction, options?: {
provider?: string | string[];
}) => Promise<TokensResponse>