RampsService Actions
10 actions registered.
| Name | Deprecated |
|---|---|
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:
| Name | Description |
|---|---|
buyUrl | The 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:
| Name | Description |
|---|---|
providerCode | The provider code (e.g., "transak", "transak-native", "moonpay"), with or without the /providers/ prefix. |
orderCode | The order identifier. |
wallet | The 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:
| Name | Description |
|---|---|
providerCode | The provider code (e.g., "transak", "moonpay"), with or without the /providers/ prefix. |
callbackUrl | The full callback URL the provider redirected to. |
wallet | The 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:
| Name | Description |
|---|---|
options | Query parameters for filtering payment methods. |
options.region | User's region code (e.g., "us-al"). |
options.assetId | CAIP-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.provider | Provider 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:
| Name | Description |
|---|---|
regionCode | The region code (e.g., "us", "fr", "us-ny"). |
options | Optional query parameters for filtering providers. |
options.provider | Provider ID(s) to filter by. |
options.crypto | Crypto currency ID(s) to filter by. |
options.payments | Payment 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:
| Name | Description |
|---|---|
params | The parameters for fetching quotes. |
params.region | User's region code (e.g., "us", "us-ca"). |
params.paymentMethods | Array of payment method IDs. |
params.assetId | CAIP-19 cryptocurrency identifier. |
params.fiat | Fiat currency code (e.g., "usd"). |
params.amount | The amount (in fiat for buy, crypto for sell). |
params.walletAddress | The destination wallet address. |
params.redirectUrl | Optional redirect URL after order completion. |
params.providers | Optional provider IDs to filter quotes. |
params.action | The 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:
| Name | Description |
|---|---|
region | The region code (e.g., "us", "fr", "us-ny"). |
action | The ramp action type ('buy' or 'sell'). |
options | Optional query parameters for filtering tokens. |
options.provider | Provider 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>