RampsController Actions
69 actions registered.
RampsController:abortRequest
Package: @metamask/ramps-controller
Aborts a pending request if one exists.
Parameters:
| Name | Description |
|---|---|
cacheKey | The cache key of the request to abort. |
Returns: True if a request was aborted.
Handler signature:
(cacheKey: string) => boolean
RampsController:addAutoramp
Package: @metamask/ramps-controller
Adds or updates a local autoramp last-seen cursor (e.g. after create).
Parameters:
| Name | Description |
|---|---|
accountOrInput | Full account or create fields. |
Returns: The upserted AutorampAccount.
Handler signature:
(accountOrInput: AutorampAccount | {
id: string;
customerId: string;
walletAddress: string;
status?: AutorampAccount['status'] | string;
}) => AutorampAccount
RampsController:addOrder
Package: @metamask/ramps-controller
Adds or updates a V2 order in controller state.
If an order with the same internal order code already exists, the incoming
fields are merged on top of the existing order so that fields not present
in the update (e.g. paymentDetails from the Transak API) are preserved.
Unchanged syncable payloads (including unchanged poll results) are ignored
so lastUpdatedAt is not bumped and User Storage is not rewritten.
When network access is denied, the order is still written locally and the remote push is deferred to the next full sync.
Parameters:
| Name | Description |
|---|---|
order | The RampsOrder to add or update. |
Handler signature:
(order: RampsOrder) => void
RampsController:addPrecreatedOrder
Package: @metamask/ramps-controller
Registers an order ID for polling until the order is created or resolved. Adds a minimal stub order to controller state; the existing order polling will fetch the full order when the provider has created it.
When network access is denied, the stub is still written locally and its remote push is deferred to the next full sync.
Parameters:
| Name | Description |
|---|---|
params | Object containing order identifiers and wallet info. |
params.orderId | Full order ID (e.g. "/providers/paypal/orders/abc123") or order code. |
params.providerCode | Canonical provider code (e.g. "paypal", "transak"). |
params.walletAddress | Wallet address for the order. |
params.chainId | Chain ID for the order (decimal, hex, or CAIP-2). Must be non-empty. |
Handler signature:
(params: {
orderId: string;
providerCode: string;
walletAddress: string;
chainId: string;
}) => void
RampsController:applyAutorampStatusFromPush
Package: @metamask/ramps-controller
Applies a remote autoramp snapshot from a websocket / webhook push.
Parameters:
| Name | Description |
|---|---|
remote | Remote autoramp snapshot. |
Returns: The updated local account.
Handler signature:
(remote: AutorampRemoteSnapshot) => AutorampAccount
RampsController:createAutoramp
Package: @metamask/ramps-controller
Creates an autoramp via the neo-bank proxy and applies the returned snapshot as the local last-seen cursor.
The vendor customer_id is resolved via
RampsController.resolveAutorampCustomerId and injected into the
request (any caller-supplied customer_id is overwritten). The caller
supplies the fiat body. When that body names a source fiat and a
recipient wallet, the idempotency key is derived from that fiat
(brl-musd-monad or usd-musd-monad), the customer, the wallet, and
rejected or cancelled autoramp ids. A caller-supplied key is used only
when the body has no source fiat or recipient address.
Parameters:
| Name | Description |
|---|---|
request | CreateAutoramp payload, including the source fiat. |
options | Optional idempotency key forwarded when the body does not identify a fiat route. |
options.idempotencyKey | Value sent as Idempotency-Key. |
Returns: The created/updated local AutorampAccount.
Handler signature:
(request: CreateAutorampRequest, options?: {
idempotencyKey?: string;
}) => Promise<AutorampAccount>
RampsController:executeRequest
Package: @metamask/ramps-controller
Executes a request with caching, deduplication, and at most one in-flight request per resource type.
-
Same cache key in flight – If a request with this cache key is already pending, returns that promise (deduplication; no second request).
-
Cache hit – If valid, non-expired data exists in state.requests for this key and forceRefresh is not set, returns that data without fetching.
-
New request – Creates an AbortController and fires the fetcher. If options.resourceType is set, tags the pending request with that resource type (so #abortDependentRequests can cancel it on region change or cleanup) and ref-counts resource-level loading state. On success or error, updates request state and resource error; in finally, clears resource loading only if this request was not aborted.
Parameters:
| Name | Description |
|---|---|
cacheKey | Unique identifier for this request (e.g. from createCacheKey). |
fetcher | Async function that performs the fetch. Receives an AbortSignal that is aborted when this request is superseded by another for the same resource. |
options | Optional forceRefresh, ttl, and resourceType for loading/error state. |
Returns: The result of the request (from cache, joined promise, or fetcher).
Handler signature:
(cacheKey: string, fetcher: (signal: AbortSignal) => Promise<TResult>, options?: ExecuteRequestOptions) => Promise<TResult>
RampsController:getBuyWidgetData
Package: @metamask/ramps-controller
Fetches the widget data from a quote for redirect providers. Makes a request to the buyURL endpoint via the RampsService to get the actual provider widget URL and optional order ID for polling.
Parameters:
| Name | Description |
|---|---|
quote | The quote to fetch the widget URL from. |
Returns: Promise resolving to the full BuyWidget (url, browser, orderId), or null if not available (missing buyURL or empty url in response).
Handler signature:
(quote: Quote) => Promise<BuyWidget | null>
RampsController:getCountries
Package: @metamask/ramps-controller
Fetches the list of supported countries. The API returns countries with support information for both buy and sell actions. The countries are saved in the controller state once fetched.
Parameters:
| Name | Description |
|---|---|
options | Options for cache behavior. |
Returns: An array of countries.
Handler signature:
(options?: ExecuteRequestOptions) => Promise<Country[]>
RampsController:getFallbackBuyWidgetData
Package: @metamask/ramps-controller
Fetches the widget data for a quote's hosted-flow fallback (see
getBuyWidgetFallback), used when an embedded checkout turns the user away.
Parameters:
| Name | Description |
|---|---|
fallback | The buy-widget fallback attached to the quote. |
options | Optional request options. |
options.redirectUrl | Where the hosted flow returns to; set as the redirectUrl query parameter, replacing any existing value. |
Returns: Promise resolving to the hosted BuyWidget, or null if the fallback has no URL or the response has an empty url.
Handler signature:
(fallback: BuyWidgetFallback, options?: {
redirectUrl?: string;
}) => Promise<BuyWidget | null>
RampsController:getOrder
Package: @metamask/ramps-controller
Fetches an order from the unified V2 API endpoint. Returns a normalized RampsOrder for all provider types (aggregator and native).
Parameters:
| Name | Description |
|---|---|
providerCode | The provider code (e.g., "transak", "transak-native", "moonpay"). |
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>
RampsController:getOrderFromCallback
Package: @metamask/ramps-controller
Extracts an order from a provider callback URL.
Sends the callback URL to the V2 backend for provider-specific parsing,
then fetches the full order. This is the V2 equivalent of the aggregator
SDK's getOrderFromCallback.
Parameters:
| Name | Description |
|---|---|
providerCode | The provider code (e.g., "transak", "moonpay"). |
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>
RampsController:getPaymentMethods
Package: @metamask/ramps-controller
Fetches the list of payment methods for a given context. The payment methods are saved in the controller state once fetched.
Parameters:
| Name | Description |
|---|---|
region | User's region code (e.g. "fr", "us-ny"). |
options | Query parameters for filtering payment methods. |
options.assetId | CAIP-19 cryptocurrency identifier. |
options.provider | Provider ID path. |
Returns: The payment methods response containing payments array.
Handler signature:
(region?: string, options?: ExecuteRequestOptions & {
assetId?: string;
provider?: string;
}) => Promise<PaymentMethodsResponse>
RampsController:getPaymentMethodsForContext
Package: @metamask/ramps-controller
Fetches payment methods for a quoting context without coupling callers to the Buy flow's globally selected provider/token catalog.
Provider contribution mirrors getQuotes:
- explicit
providers(optionally filtered whenrestrictToKnownOrNativeProvidersis set) - auto-select / restrict path, including
moneyHeadlessAllProviderswidening: flag off uses the restricted/native resolver; flag on uses supporting providers, intersected with the flag allowlist when that allowlist is non-empty (pick-survivor set for picker methods) - when those resolution flags and
providersare omitted, uses onlyproviders.selected(UB2 selected-provider context)
By default this is request-only: it does not mutate
paymentMethods.data or paymentMethods.selected. Pass updateState: true only when the caller explicitly wants Buy-catalog write semantics
(UB2). Headless / MM Pay selection stays TPC-owned. updateState: true
throws when the resolved provider set holds more than one provider, because
the write guards cannot tell two such requests apart.
Methods are request-eligible for the resolved provider set; they are not guaranteed to produce a quote for every amount (provider fiat limits still apply at quote time).
Parameters:
| Name | Description |
|---|---|
options | Context for the payment-method fetch. |
options.region | Region code. Defaults to userRegion. |
options.assetId | Required CAIP-19 quoting asset. |
options.providers | Explicit provider ids. |
options.autoSelectProvider | Resolve providers like getQuotes. |
options.preferredProviderIds | Preferred ids for auto-selection. |
options.restrictToKnownOrNativeProviders | Headless gating. |
options.updateState | When true, write paymentMethods state. |
options.preferPaymentMethodId | Preserve this id when still present. |
options.forceRefresh | Bypass request cache for provider fetches. |
options.ttl | Custom TTL for provider payment-method fetches. |
Returns: Deduped methods, a request-only suggested selection, and the provider ids that contributed.
Handler signature:
(options: {
region?: string;
assetId: string;
providers?: string[];
autoSelectProvider?: boolean;
preferredProviderIds?: string[];
restrictToKnownOrNativeProviders?: boolean;
updateState?: boolean;
preferPaymentMethodId?: string;
forceRefresh?: boolean;
ttl?: number;
}) => Promise<PaymentMethodsForContextResponse>
RampsController:getProviders
Package: @metamask/ramps-controller
Fetches the list of providers for a given region. The providers are saved in the controller state once fetched.
Parameters:
| Name | Description |
|---|---|
region | The region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state. |
options | Options for cache behavior and query filters. |
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:
(region?: string, options?: ExecuteRequestOptions & {
provider?: string | string[];
crypto?: string | string[];
payments?: string | string[];
}) => Promise<ProvidersResponse>
RampsController:getQuotes
Package: @metamask/ramps-controller
Fetches quotes from all providers for a given set of parameters. Uses the controller's request cache; callers manage the response in local state.
Parameters:
| Name | Description |
|---|---|
options | The parameters for fetching quotes. |
options.region | User's region code. If not provided, uses userRegion from state. |
options.fiat | Fiat currency code. If not provided, uses userRegion currency. |
options.assetId | CAIP-19 cryptocurrency identifier. |
options.amount | The amount (in fiat for buy, crypto for sell). |
options.walletAddress | The destination wallet address. |
options.paymentMethods | Array of payment method IDs. If not provided, uses paymentMethods from state. |
options.providers | Optional provider IDs to filter quotes. |
options.autoSelectProvider | When true and providers is omitted, resolves a provider that supports assetId for this request only (no state mutation). Ignored when providers is passed. |
options.preferredProviderIds | Optional provider IDs to prefer during auto-selection, in priority order (e.g. derived by the caller from completed-order history). Only used when autoSelectProvider is true and providers is omitted. |
options.restrictToKnownOrNativeProviders | Headless-buy v0 gating. When true, auto-selection resolves only a native provider, and an explicitly passed providers list is filtered to those supporting the region and asset. If nothing qualifies, getQuotes returns an empty response instead of quoting other providers. |
options.redirectUrl | Optional redirect URL after order completion. |
options.action | The ramp action type. Defaults to 'buy'. |
options.forceRefresh | Whether to bypass cache. |
options.ttl | Custom TTL for this request. |
Returns: The quotes response containing success, sorted, error, and customActions.
Handler signature:
(options: {
region?: string;
fiat?: string;
assetId?: string;
amount: number;
walletAddress: string;
paymentMethods?: string[];
providers?: string[];
autoSelectProvider?: boolean;
preferredProviderIds?: string[];
restrictToKnownOrNativeProviders?: boolean;
redirectUrl?: string;
action?: RampAction;
forceRefresh?: boolean;
ttl?: number;
}) => Promise<QuotesResponse>
RampsController:getQuoteWithFees
Package: @metamask/ramps-controller
Fetches the best on-ramp quote for a request and, when the resolved provider is Transak Native, reconciles its fees to match what Transak Native actually charges.
The aggregator /quotes estimate of Transak's fee does not match the
native integration. When the resolved provider is Transak Native this
fetches the native buy quote (an unauthenticated, API-key-only lookup, so
it is safe at estimate time) and rewrites the returned quote's fee fields
to its totalFee, keeping the aggregator's networkFee on the network
line and placing the remainder in the provider fee so the breakdown
survives and providerFee + networkFee still equals the native total. A
non-native provider, a failed lookup, or an unusable native fee returns the
aggregator quote unchanged.
Consumers (e.g. TransactionPayController) call this instead of owning the
provider check, asset-id parsing, and second native quote themselves.
Parameters:
| Name | Description |
|---|---|
options | Quote options; see getQuotes, plus the fee mode. |
options.amount | Fiat amount for the quote. |
options.assetId | CAIP-19 asset id being bought. |
options.fiat | Optional fiat currency; defaults like getQuotes. |
options.paymentMethods | Optional payment method ids. |
options.walletAddress | Wallet address receiving the on-ramped asset. |
options.isFeeExcludedFromFiat | Whether Transak adds its fee on top of the fiat amount (true, fee-on-top) or carves it out (false). Must mirror the eventual checkout mode so the estimate equals the charge. Defaults to true. |
options.providers | See getQuotes. |
options.autoSelectProvider | See getQuotes. |
options.restrictToKnownOrNativeProviders | See getQuotes. |
options.preferredProviderIds | See getQuotes. |
options.region | See getQuotes. |
options.redirectUrl | See getQuotes. |
options.action | See getQuotes. |
options.forceRefresh | See getQuotes. |
options.ttl | See getQuotes. |
Returns: The best quote with native-reconciled fees, or undefined when no quote is available.
Handler signature:
(options: {
amount: number;
assetId: string;
fiat?: string;
paymentMethods?: string[];
walletAddress: string;
isFeeExcludedFromFiat?: boolean;
providers?: string[];
autoSelectProvider?: boolean;
restrictToKnownOrNativeProviders?: boolean;
preferredProviderIds?: string[];
region?: string;
redirectUrl?: string;
action?: RampAction;
forceRefresh?: boolean;
ttl?: number;
}) => Promise<Quote | undefined>
RampsController:getRequestState
Package: @metamask/ramps-controller
Gets the state of a specific cached request.
Parameters:
| Name | Description |
|---|---|
cacheKey | The cache key to look up. |
Returns: The request state, or undefined if not cached.
Handler signature:
(cacheKey: string) => RequestState | undefined
RampsController:getState
Package: @metamask/ramps-controller
Retrieves the state of the RampsController.
Handler signature:
() => RampsControllerState
RampsController:getTokens
Package: @metamask/ramps-controller
Fetches the list of available tokens for a given region and action. The tokens are saved in the controller state once fetched.
Parameters:
| Name | Description |
|---|---|
region | The region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state. |
action | The ramp action type ('buy' or 'sell'). |
options | Options for cache behavior and query filters. |
options.provider | Provider ID(s) to filter by. |
Returns: The tokens response containing topTokens and allTokens.
Handler signature:
(region?: string, action?: RampAction, options?: ExecuteRequestOptions & {
provider?: string | string[];
}) => Promise<TokensResponse>
RampsController:hydrateVbaOnboarding
Package: @metamask/ramps-controller
Reads VBA onboarding facts. Hosts map the returned
VbaOnboardingSnapshot onto their own funnel; this method does not
name screens.
The read uses the persisted KYC session. refreshKyc performs one
session-status GET when a session id is already stored and finalStatus
is not terminal. refreshAutoramps lists autoramps when KYC is approved,
unless this wallet already has a usable route. An approved session with no
usable autoramp returns needs_wallet_registration or
needs_source_currency only when
GET /neobank/customers/{external_id}/external reports
status: 'Active'. Any other customer status returns not_ready.
It does not sign, post a self-hosted address, create an autoramp, or start
KYC polling.
Overlapping calls share one run.
Parameters:
| Name | Description |
|---|---|
params | VBA onboarding parameters. |
params.walletAddress | Monad Money Account wallet address. |
params.refreshKyc | When true, fetch session status once for a non-terminal persisted session. A failed GET keeps that session. Defaults to false. |
params.refreshAutoramps | When true, replace the autoramp cursor from GET /neobank/autoramps unless a usable route is already stored. Defaults to false. |
Returns: Independent KYC and autoramp facts for the current customer.
Handler signature:
({ walletAddress, refreshKyc, refreshAutoramps, }: {
walletAddress: string;
refreshKyc?: boolean;
refreshAutoramps?: boolean;
}) => Promise<VbaOnboardingSnapshot>
RampsController:init
Package: @metamask/ramps-controller
Initializes the controller by fetching the user's region from geolocation. This should be called once at app startup to set up the initial region.
Idempotent: subsequent calls return the same promise unless forceRefresh is set. Force-refetches the countries catalog on startup (bypassing the in-session request cache) so region preset amounts stay current. The catalog is not persisted, so a cold start always re-fetches it regardless. Skips geolocation when userRegion already exists.
Parameters:
| Name | Description |
|---|---|
options | Options for cache behavior. forceRefresh bypasses idempotency and re-runs the full flow. |
Returns: Promise that resolves when initialization is complete.
Handler signature:
(options?: ExecuteRequestOptions) => Promise<void>
RampsController:markAutorampAsNotified
Package: @metamask/ramps-controller
Marks that the UI has already notified for the autoramp's current status.
Parameters:
| Name | Description |
|---|---|
autorampId | MoonPay autoramp id. |
Handler signature:
(autorampId: string) => void
RampsController:refreshAutoramp
Package: @metamask/ramps-controller
Fetches one autoramp from the neo-bank proxy and applies it to the last-seen cursor. Does not recreate a cursor that was removed while the request was in flight.
Parameters:
| Name | Description |
|---|---|
autorampId | MoonPay autoramp id. |
Returns: The updated local account, or an unpersisted snapshot if the cursor was removed during the fetch.
Handler signature:
(autorampId: string) => Promise<AutorampAccount>
RampsController:refreshAutoramps
Package: @metamask/ramps-controller
Refreshes all known local autoramps from MoonPay. Intended for app resume / unlock catch-up when webhooks were missed.
Returns: Updated autoramp accounts (failed fetches are skipped).
Handler signature:
() => Promise<AutorampAccount[]>
RampsController:refreshAutorampTransactions
Package: @metamask/ramps-controller
Fetches the newest page of transactions for one autoramp and calls
trackAutorampTransactionStatusChanged for each new id or status change.
The updated record is written before the callback runs. A failed fetch
leaves the record untouched. Concurrent calls for the same autoramp share
one request. The first successful fetch seeds the record and calls
nothing. When this autoramp was on the cursor at the start of the fetch
and was removed before the response is applied (removeAutoramp, a cursor
replace that drops the id, or a foreign VBA session discard), the record
is not restored and the callback is not called. A callback that throws
is ignored, so one failing change does not drop the rest of the batch.
Parameters:
| Name | Description |
|---|---|
autorampId | MoonPay autoramp id. |
Returns: Transaction summaries from the newest page.
Handler signature:
(autorampId: string) => Promise<AutorampTransactionSummary[]>
RampsController:refreshCustomerAbilities
Package: @metamask/ramps-controller
Fetches the MoonPay customer's rail abilities from the neo-bank proxy and
stores them in vbaCustomerAbilities. A failed fetch throws and leaves the
stored value unchanged.
Returns: The fetched abilities.
Handler signature:
() => Promise<NeoBankCustomerAbilities>
RampsController:registerMoneyAccountWallet
Package: @metamask/ramps-controller
Registers a Money Account wallet with MoonPay Iron via neobank-proxy.
Parameters:
| Name | Description |
|---|---|
params | Money Account wallet registration parameters. |
params.address | Monad Money Account address. |
Returns: The registration state, or { type: 'lookupUnavailable' } when the address-list lookup fails (never treated as unregistered).
Handler signature:
({ address, }: {
address: string;
}) => Promise<MoneyAccountWalletRegistrationResult>
RampsController:removeAutoramp
Package: @metamask/ramps-controller
Removes a local autoramp last-seen cursor by id.
Parameters:
| Name | Description |
|---|---|
autorampId | MoonPay autoramp id. |
Handler signature:
(autorampId: string) => void
RampsController:removeOrder
Package: @metamask/ramps-controller
Removes a V2 order from controller state by providerOrderId.
When network access is denied, the order is still removed locally and the remote tombstone is deferred to the next full sync.
Parameters:
| Name | Description |
|---|---|
providerOrderId | The provider order ID to remove. |
Handler signature:
(providerOrderId: string) => void
RampsController:selectProviderForAsset
Package: @metamask/ramps-controller
Selects the provider for the given asset and returns its id.
Among the providers in providers.data that offer the asset (minus
excludeProviderIds), the first match wins:
- The user's own pick (
RampsControllerState.userSelectedProviderId). - The first provider in
aheadOfHistory. - The provider of the most recent completed buy, across all accounts,
from controller orders plus
extraHistory. - The first provider in API ranking order.
With a null asset (no token chosen yet) every provider is a candidate
and step 2 is skipped, since that list only applies to assets its
providers offer.
The selection is marked auto-selected unless it is the user's own pick. The user's pick is kept when another provider is chosen, so it comes back on the next asset it offers.
Parameters:
| Name | Description |
|---|---|
assetId | CAIP-19 asset id the user is buying, or null. |
options | Optional inputs. |
options.aheadOfHistory | Provider ids that win over history. |
options.extraHistory | Completed buys from outside controller state. |
options.excludeProviderIds | Provider ids to leave out. |
Returns: The selected provider id, or null when providers are not loaded or none offers the asset (the selection is left unchanged).
Handler signature:
(assetId: string | null, options?: SelectProviderForAssetOptions) => string | null
RampsController:setSelectedPaymentMethod
Package: @metamask/ramps-controller
Sets the user's selected payment method.
Accepts either a payment method ID (looked up from state) or a full PaymentMethod object (stored directly). The object form is preferred when the caller already has the full data (e.g. from React Query cache), as it avoids depending on controller state being populated.
Parameters:
| Name | Description |
|---|---|
paymentMethodOrId | A PaymentMethod object, a payment method ID string, or undefined/null to clear. |
Handler signature:
(paymentMethodOrId?: string | PaymentMethod | null) => void
RampsController:setSelectedProvider
Package: @metamask/ramps-controller
Sets the user's selected provider.
Accepts either a Provider object (stored directly) or a provider ID string (looked up from state). The object form is preferred when the caller already has the full data (e.g. from React Query cache).
Parameters:
| Name | Description |
|---|---|
providerOrId | A Provider object, a provider ID string (e.g., "/providers/moonpay"), or null to clear. |
options | Optional settings for the selection. |
options.autoSelected | When true, marks the provider as system-guessed (soft selection). The UI will silently auto-switch on token conflict instead of showing the "Token Not Available" modal. Defaults to false. |
options.userSelected | When true, also records the provider as the user's own pick (RampsControllerState.userSelectedProviderId). Defaults to false. Passing null as the provider always clears the pick. |
Handler signature:
(providerOrId: string | Provider | null, options?: {
autoSelected?: boolean;
userSelected?: boolean;
}) => void
RampsController:setSelectedProviderForAsset
Package: @metamask/ramps-controller
Switches to the preferred provider in state that serves the given asset, when the currently selected provider does not.
This is the controller-level equivalent of UB2's BuildQuote tier-1
silent-switch effect and MMPay's useEnsureCompatibleProvider hook: it
keeps provider-asset compatibility logic in one place rather than
duplicating providerServesAsset + find-and-switch across multiple UI
layers.
The compatibility check prefers the current provider's entry in
providers.data over the providers.selected copy, which can be stale
once a fresh providers list arrives.
Among the providers that serve the asset, the new selection is:
- The first provider the user has completed an order with before (most recent first). This keeps an existing KYC relationship instead of moving the user to a new provider.
- Otherwise the first provider in
providers.data(API ranking order).
No-op when:
providers.datais empty (providers not yet loaded)- the currently selected provider already serves the asset
- no provider in the list serves the asset (no safe fallback)
Parameters:
| Name | Description |
|---|---|
assetId | CAIP-19 asset id of the deposit asset. |
options | Optional settings forwarded to setSelectedProvider. |
options.autoSelected | When true, marks the new selection as system-guessed (soft selection). Defaults to true. |
Returns: true if the selected provider was changed, false otherwise.
Handler signature:
(assetId: string, options?: {
autoSelected?: boolean;
}) => boolean
RampsController:setSelectedToken
Package: @metamask/ramps-controller
Sets the user's selected token by asset ID. Looks up the token from the current tokens in state and automatically fetches payment methods for that token.
Parameters:
| Name | Description |
|---|---|
assetId | The asset identifier in CAIP-19 format (e.g., "eip155:1/erc20:0x..."), or undefined to clear. |
Handler signature:
(assetId?: string) => void
RampsController:setUserRegion
Package: @metamask/ramps-controller
Sets the user's region manually (without fetching geolocation). This allows users to override the detected region.
Parameters:
| Name | Description |
|---|---|
region | The region code to set (e.g., "US-CA"). |
options | Options for cache behavior. |
Returns: The user region object.
Handler signature:
(region: string, options?: ExecuteRequestOptions) => Promise<UserRegion>
RampsController:startOrderPolling
Package: @metamask/ramps-controller
Starts polling all pending V2 orders at a fixed interval. Each poll cycle iterates orders with non-terminal statuses, respects pollingSecondsMinimum and backoff from error count.
Handler signature:
() => void
RampsController:stopOrderPolling
Package: @metamask/ramps-controller
Stops order polling and clears the interval.
Handler signature:
() => void
RampsController:syncOrdersWithUserStorage
Package: @metamask/ramps-controller
Bidirectionally syncs V2 ramps orders with User Storage. Hosts should call this on unlock / when ramps syncing is enabled.
Overlapping calls are coalesced into the in-flight worker. After the worker
settles, this method loops when #orderSyncQueued is still set so a
request that arrived between the worker's last loop check and promise
resolution is not dropped.
Handler signature:
() => Promise<void>
RampsController:transakCancelAllActiveOrders
Package: @metamask/ramps-controller
Cancels all active Transak orders. Individual cancellation failures are collected and returned rather than thrown.
Returns: An array of errors from any failed cancellations (empty if all succeeded).
Handler signature:
() => Promise<Error[]>
RampsController:transakCancelOrder
Package: @metamask/ramps-controller
Cancels a specific Transak order.
Parameters:
| Name | Description |
|---|---|
depositOrderId | The deposit order ID to cancel. |
Returns: A promise that resolves when the order is cancelled.
Handler signature:
(depositOrderId: string) => Promise<void>
RampsController:transakClearAccessToken
Package: @metamask/ramps-controller
Clears the Transak access token and marks the user as unauthenticated.
Handler signature:
() => void
RampsController:transakConfirmPayment
Package: @metamask/ramps-controller
Confirms payment for an order after the user has completed payment.
Parameters:
| Name | Description |
|---|---|
orderId | The order ID to confirm payment for. |
paymentMethodId | The payment method used. |
Returns: Whether the payment confirmation was successful.
Handler signature:
(orderId: string, paymentMethodId: string) => Promise<{
success: boolean;
}>
RampsController:transakCreateOrder
Package: @metamask/ramps-controller
Creates a new order on Transak. If an existing order conflicts (HTTP 409), active orders are cancelled and the creation is retried.
Parameters:
| Name | Description |
|---|---|
quoteId | The quote ID to create an order from. |
walletAddress | The destination wallet address. |
paymentMethodId | The payment method to use. |
Returns: The created deposit order.
Handler signature:
(quoteId: string, walletAddress: string, paymentMethodId: string) => Promise<TransakDepositOrder>
RampsController:transakCreateWidgetUrl
Package: @metamask/ramps-controller
Creates a Transak payment widget URL via the ramps API proxy, which
injects the partner API key server-side. Replaces the OTT flow
(transakRequestOtt + transakGeneratePaymentWidgetUrl).
Parameters:
| Name | Description |
|---|---|
quote | The buy quote to pre-fill in the widget. |
walletAddress | The destination wallet address. |
extraParams | Optional additional widget parameters (e.g. theming). |
Returns: The single-use widget URL.
Handler signature:
(quote: TransakBuyQuote, walletAddress: string, extraParams?: Record<string, string>) => Promise<string>
RampsController:transakGeneratePaymentWidgetUrl
Package: @metamask/ramps-controller
Generates a URL for the Transak payment widget with pre-filled parameters.
Parameters:
| Name | Description |
|---|---|
ottToken | The one-time token for widget authentication. |
quote | The buy quote to pre-fill in the widget. |
walletAddress | The destination wallet address. |
extraParams | Optional additional URL parameters. |
Returns: The fully constructed widget URL string.
Handler signature:
(ottToken: string, quote: TransakBuyQuote, walletAddress: string, extraParams?: Record<string, string>) => string
RampsController:transakGetActiveOrders
Package: @metamask/ramps-controller
Fetches all active Transak orders for the authenticated user.
Returns: The list of active orders.
Handler signature:
() => Promise<TransakOrder[]>
RampsController:transakGetAdditionalRequirements
Package: @metamask/ramps-controller
Fetches additional KYC requirements (e.g., ID proof, address proof) for a quote.
Parameters:
| Name | Description |
|---|---|
quoteId | The quote ID to check additional requirements for. |
Returns: The list of additional forms required.
Handler signature:
(quoteId: string) => Promise<TransakAdditionalRequirementsResponse>
RampsController:transakGetBuyQuote
Package: @metamask/ramps-controller
Fetches a buy quote from Transak for the given parameters. Updates the buyQuote resource state with loading/success/error states.
Parameters:
| Name | Description |
|---|---|
fiatCurrency | The fiat currency code (e.g., "USD"). |
cryptoCurrency | The cryptocurrency identifier. |
network | The blockchain network identifier. |
paymentMethod | The payment method identifier. |
fiatAmount | The fiat amount as a string. |
isFeeExcludedFromFiat | Whether fees are added to the fiat amount. Defaults to true to preserve Unified Buy's native Transak behavior. |
Returns: The buy quote with pricing and fee details.
Handler signature:
(fiatCurrency: string, cryptoCurrency: string, network: string, paymentMethod: string, fiatAmount: string, isFeeExcludedFromFiat?: boolean) => Promise<TransakBuyQuote>
RampsController:transakGetIdProofStatus
Package: @metamask/ramps-controller
Checks the status of an ID proof submission for KYC.
Parameters:
| Name | Description |
|---|---|
workFlowRunId | The workflow run ID to check status for. |
Returns: The current ID proof status.
Handler signature:
(workFlowRunId: string) => Promise<TransakIdProofStatus>
RampsController:transakGetKycRequirement
Package: @metamask/ramps-controller
Fetches the KYC requirement for a given quote. Updates the kycRequirement resource state with loading/success/error states.
Parameters:
| Name | Description |
|---|---|
quoteId | The quote ID to check KYC requirements for. |
Returns: The KYC requirement status and whether the user can place an order.
Handler signature:
(quoteId: string) => Promise<TransakKycRequirement>
RampsController:transakGetOrder
Package: @metamask/ramps-controller
Fetches an existing order from Transak by order ID.
Parameters:
| Name | Description |
|---|---|
orderId | The order ID (deposit format or raw Transak format). |
wallet | The wallet address associated with the order. |
paymentDetails | Optional payment details to attach to the order. |
Returns: The deposit order details.
Handler signature:
(orderId: string, wallet: string, paymentDetails?: TransakOrderPaymentMethod[]) => Promise<TransakDepositOrder>
RampsController:transakGetTranslation
Package: @metamask/ramps-controller
Translates generic ramps identifiers to Transak-specific identifiers.
Parameters:
| Name | Description |
|---|---|
request | The translation request with optional identifiers to translate. |
Returns: The translated Transak-specific identifiers.
Handler signature:
(request: TransakTranslationRequest) => Promise<TransakQuoteTranslation>
RampsController:transakGetUserDetails
Package: @metamask/ramps-controller
Fetches the authenticated user's details from Transak. Updates the userDetails resource state with loading/success/error states.
Returns: The user's profile and KYC details.
Handler signature:
() => Promise<TransakUserDetails>
RampsController:transakGetUserLimits
Package: @metamask/ramps-controller
Fetches the user's spending limits for a given currency and payment method.
Parameters:
| Name | Description |
|---|---|
fiatCurrency | The fiat currency code. |
paymentMethod | The payment method identifier. |
kycType | The KYC level type. |
Returns: The user's limits, spending, and remaining amounts.
Handler signature:
(fiatCurrency: string, paymentMethod: string, kycType: string) => Promise<TransakUserLimits>
RampsController:transakLogout
Package: @metamask/ramps-controller
Logs the user out of Transak. Clears authentication state and user details regardless of whether the API call succeeds or fails.
When network access is denied, the local session is cleared and a message is returned without calling the Transak service.
Returns: A message indicating the logout result.
Handler signature:
() => Promise<string>
RampsController:transakPatchUser
Package: @metamask/ramps-controller
Updates the user's personal or address details on Transak.
Parameters:
| Name | Description |
|---|---|
data | The user data fields to update. |
Returns: The API response data.
Handler signature:
(data: PatchUserRequestBody) => Promise<unknown>
RampsController:transakRequestOtt
Package: @metamask/ramps-controller
Requests a one-time token (OTT) for the Transak payment widget.
Returns: The OTT response containing the token.
Handler signature:
() => Promise<TransakOttResponse>
RampsController:transakResetState
Package: @metamask/ramps-controller
Resets all Transak state back to defaults (unauthenticated, no data).
Handler signature:
() => void
RampsController:transakSendUserOtp
Package: @metamask/ramps-controller
Sends a one-time password to the user's email for Transak authentication.
Parameters:
| Name | Description |
|---|---|
email | The user's email address. |
Returns: The OTP response containing a state token for verification.
Handler signature:
(email: string) => Promise<{
isTncAccepted: boolean;
stateToken: string;
email: string;
expiresIn: number;
}>
RampsController:transakSetAccessToken
Package: @metamask/ramps-controller
Sets the Transak access token and marks the user as authenticated.
Parameters:
| Name | Description |
|---|---|
token | The access token received from Transak auth. |
Handler signature:
(token: TransakAccessToken) => void
RampsController:transakSetApiKey
Package: @metamask/ramps-controller
Sets the Transak API key used for all Transak API requests.
Parameters:
| Name | Description |
|---|---|
apiKey | The Transak API key. |
Handler signature:
(apiKey: string) => void
RampsController:transakSetAuthenticated
Package: @metamask/ramps-controller
Updates the Transak authentication flag in controller state.
Parameters:
| Name | Description |
|---|---|
isAuthenticated | Whether the user is authenticated with Transak. |
Handler signature:
(isAuthenticated: boolean) => void
RampsController:transakSubmitAdditionalDetailsNationality
Package: @metamask/ramps-controller
Submits additional nationality details for the authenticated user.
Parameters:
| Name | Description |
|---|---|
employmentStatus | Employment status (e.g., "employed", "self_employed"). |
countryOfCitizenship | ISO 3166-1 alpha-2 country code. |
Returns: The submission response containing the status.
Handler signature:
(employmentStatus: string, countryOfCitizenship: string) => Promise<SubmitAdditionalDetailsNationalityResponse>
RampsController:transakSubmitMicaConsent
Package: @metamask/ramps-controller
Submits MiCA consent for the authenticated user.
Parameters:
| Name | Description |
|---|---|
consentedAt | ISO 8601 timestamp of consent. |
Returns: The submission response containing the status.
Handler signature:
(consentedAt: string) => Promise<SubmitMicaConsentResponse>
RampsController:transakSubmitPurposeOfUsageForm
Package: @metamask/ramps-controller
Submits the user's purpose of usage form for KYC compliance.
Parameters:
| Name | Description |
|---|---|
purpose | Array of purpose strings selected by the user. |
Returns: A promise that resolves when the form is submitted.
Handler signature:
(purpose: string[]) => Promise<void>
RampsController:transakSubmitSourceOfIncome
Package: @metamask/ramps-controller
Submits source of income details for the authenticated user.
Parameters:
| Name | Description |
|---|---|
monthlyVolume | Expected monthly transaction volume. |
sourceOfFundsType | Source of funds (e.g., "salary", "business_income"). |
Returns: The submission response containing the status.
Handler signature:
(monthlyVolume: string, sourceOfFundsType: string) => Promise<SubmitSourceOfIncomeResponse>
RampsController:transakSubmitSsnDetails
Package: @metamask/ramps-controller
Submits the user's SSN for identity verification.
Parameters:
| Name | Description |
|---|---|
ssn | The Social Security Number. |
quoteId | The quote ID associated with the order requiring SSN. |
Returns: The API response data.
Handler signature:
(ssn: string, quoteId: string) => Promise<unknown>
RampsController:transakVerifyUserOtp
Package: @metamask/ramps-controller
Verifies a one-time password and authenticates the user with Transak. Updates the controller's authentication state on success.
Parameters:
| Name | Description |
|---|---|
email | The user's email address. |
verificationCode | The OTP code entered by the user. |
stateToken | The state token from the sendUserOtp response. |
Returns: The access token for subsequent authenticated requests.
Handler signature:
(email: string, verificationCode: string, stateToken: string) => Promise<TransakAccessToken>