Skip to main content

RampsController Actions

69 actions registered.

NameDeprecated
abortRequest
addAutoramp
addOrder
addPrecreatedOrder
applyAutorampStatusFromPush
createAutoramp
executeRequest
getBuyWidgetData
getCountries
getFallbackBuyWidgetData
getOrder
getOrderFromCallback
getPaymentMethods
getPaymentMethodsForContext
getProviders
getQuotes
getQuoteWithFees
getRequestState
getState
getTokens
hydrateVbaOnboarding
init
markAutorampAsNotified
refreshAutoramp
refreshAutoramps
refreshAutorampTransactions
refreshCustomerAbilities
registerMoneyAccountWallet
removeAutoramp
removeOrder
selectProviderForAsset
setSelectedPaymentMethod
setSelectedProvider
setSelectedProviderForAsset
setSelectedToken
setUserRegion
startOrderPolling
stopOrderPolling
syncOrdersWithUserStorage
transakCancelAllActiveOrders
transakCancelOrder
transakClearAccessToken
transakConfirmPayment
transakCreateOrder
transakCreateWidgetUrl
transakGeneratePaymentWidgetUrl
transakGetActiveOrders
transakGetAdditionalRequirements
transakGetBuyQuote
transakGetIdProofStatus
transakGetKycRequirement
transakGetOrder
transakGetTranslation
transakGetUserDetails
transakGetUserLimits
transakLogout
transakPatchUser
transakRequestOtt
transakResetState
transakSendUserOtp
transakSetAccessToken
transakSetApiKey
transakSetAuthenticated
transakSubmitAdditionalDetailsNationality
transakSubmitMicaConsent
transakSubmitPurposeOfUsageForm
transakSubmitSourceOfIncome
transakSubmitSsnDetails
transakVerifyUserOtp

RampsController:abortRequest​

Package: @metamask/ramps-controller

Aborts a pending request if one exists.

Parameters:

NameDescription
cacheKeyThe 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:

NameDescription
accountOrInputFull 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:

NameDescription
orderThe 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:

NameDescription
paramsObject containing order identifiers and wallet info.
params.orderIdFull order ID (e.g. "/providers/paypal/orders/abc123") or order code.
params.providerCodeCanonical provider code (e.g. "paypal", "transak").
params.walletAddressWallet address for the order.
params.chainIdChain 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:

NameDescription
remoteRemote 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:

NameDescription
requestCreateAutoramp payload, including the source fiat.
optionsOptional idempotency key forwarded when the body does not identify a fiat route.
options.idempotencyKeyValue 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.

  1. Same cache key in flight – If a request with this cache key is already pending, returns that promise (deduplication; no second request).

  2. Cache hit – If valid, non-expired data exists in state.requests for this key and forceRefresh is not set, returns that data without fetching.

  3. 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:

NameDescription
cacheKeyUnique identifier for this request (e.g. from createCacheKey).
fetcherAsync function that performs the fetch. Receives an AbortSignal that is aborted when this request is superseded by another for the same resource.
optionsOptional 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:

NameDescription
quoteThe 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:

NameDescription
optionsOptions 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:

NameDescription
fallbackThe buy-widget fallback attached to the quote.
optionsOptional request options.
options.redirectUrlWhere 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:

NameDescription
providerCodeThe provider code (e.g., "transak", "transak-native", "moonpay").
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>

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:

NameDescription
providerCodeThe provider code (e.g., "transak", "moonpay").
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>

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:

NameDescription
regionUser's region code (e.g. "fr", "us-ny").
optionsQuery parameters for filtering payment methods.
options.assetIdCAIP-19 cryptocurrency identifier.
options.providerProvider 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 when restrictToKnownOrNativeProviders is set)
  • auto-select / restrict path, including moneyHeadlessAllProviders widening: 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 providers are omitted, uses only providers.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:

NameDescription
optionsContext for the payment-method fetch.
options.regionRegion code. Defaults to userRegion.
options.assetIdRequired CAIP-19 quoting asset.
options.providersExplicit provider ids.
options.autoSelectProviderResolve providers like getQuotes.
options.preferredProviderIdsPreferred ids for auto-selection.
options.restrictToKnownOrNativeProvidersHeadless gating.
options.updateStateWhen true, write paymentMethods state.
options.preferPaymentMethodIdPreserve this id when still present.
options.forceRefreshBypass request cache for provider fetches.
options.ttlCustom 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:

NameDescription
regionThe region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state.
optionsOptions for cache behavior and query filters.
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:

(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:

NameDescription
optionsThe parameters for fetching quotes.
options.regionUser's region code. If not provided, uses userRegion from state.
options.fiatFiat currency code. If not provided, uses userRegion currency.
options.assetIdCAIP-19 cryptocurrency identifier.
options.amountThe amount (in fiat for buy, crypto for sell).
options.walletAddressThe destination wallet address.
options.paymentMethodsArray of payment method IDs. If not provided, uses paymentMethods from state.
options.providersOptional provider IDs to filter quotes.
options.autoSelectProviderWhen true and providers is omitted, resolves a provider that supports assetId for this request only (no state mutation). Ignored when providers is passed.
options.preferredProviderIdsOptional 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.restrictToKnownOrNativeProvidersHeadless-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.redirectUrlOptional redirect URL after order completion.
options.actionThe ramp action type. Defaults to 'buy'.
options.forceRefreshWhether to bypass cache.
options.ttlCustom 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:

NameDescription
optionsQuote options; see getQuotes, plus the fee mode.
options.amountFiat amount for the quote.
options.assetIdCAIP-19 asset id being bought.
options.fiatOptional fiat currency; defaults like getQuotes.
options.paymentMethodsOptional payment method ids.
options.walletAddressWallet address receiving the on-ramped asset.
options.isFeeExcludedFromFiatWhether 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.providersSee getQuotes.
options.autoSelectProviderSee getQuotes.
options.restrictToKnownOrNativeProvidersSee getQuotes.
options.preferredProviderIdsSee getQuotes.
options.regionSee getQuotes.
options.redirectUrlSee getQuotes.
options.actionSee getQuotes.
options.forceRefreshSee getQuotes.
options.ttlSee 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:

NameDescription
cacheKeyThe 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:

NameDescription
regionThe region code (e.g., "us", "fr", "us-ny"). If not provided, uses the user's region from controller state.
actionThe ramp action type ('buy' or 'sell').
optionsOptions for cache behavior and query filters.
options.providerProvider 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:

NameDescription
paramsVBA onboarding parameters.
params.walletAddressMonad Money Account wallet address.
params.refreshKycWhen true, fetch session status once for a non-terminal persisted session. A failed GET keeps that session. Defaults to false.
params.refreshAutorampsWhen 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:

NameDescription
optionsOptions 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:

NameDescription
autorampIdMoonPay 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:

NameDescription
autorampIdMoonPay 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:

NameDescription
autorampIdMoonPay 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:

NameDescription
paramsMoney Account wallet registration parameters.
params.addressMonad 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:

NameDescription
autorampIdMoonPay 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:

NameDescription
providerOrderIdThe 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:

  1. The user's own pick (RampsControllerState.userSelectedProviderId).
  2. The first provider in aheadOfHistory.
  3. The provider of the most recent completed buy, across all accounts, from controller orders plus extraHistory.
  4. 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:

NameDescription
assetIdCAIP-19 asset id the user is buying, or null.
optionsOptional inputs.
options.aheadOfHistoryProvider ids that win over history.
options.extraHistoryCompleted buys from outside controller state.
options.excludeProviderIdsProvider 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:

NameDescription
paymentMethodOrIdA 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:

NameDescription
providerOrIdA Provider object, a provider ID string (e.g., "/providers/moonpay"), or null to clear.
optionsOptional settings for the selection.
options.autoSelectedWhen 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.userSelectedWhen 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:

  1. 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.
  2. Otherwise the first provider in providers.data (API ranking order).

No-op when:

  • providers.data is 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:

NameDescription
assetIdCAIP-19 asset id of the deposit asset.
optionsOptional settings forwarded to setSelectedProvider.
options.autoSelectedWhen 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:

NameDescription
assetIdThe 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:

NameDescription
regionThe region code to set (e.g., "US-CA").
optionsOptions 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:

NameDescription
depositOrderIdThe 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:

NameDescription
orderIdThe order ID to confirm payment for.
paymentMethodIdThe 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:

NameDescription
quoteIdThe quote ID to create an order from.
walletAddressThe destination wallet address.
paymentMethodIdThe 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:

NameDescription
quoteThe buy quote to pre-fill in the widget.
walletAddressThe destination wallet address.
extraParamsOptional 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:

NameDescription
ottTokenThe one-time token for widget authentication.
quoteThe buy quote to pre-fill in the widget.
walletAddressThe destination wallet address.
extraParamsOptional 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:

NameDescription
quoteIdThe 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:

NameDescription
fiatCurrencyThe fiat currency code (e.g., "USD").
cryptoCurrencyThe cryptocurrency identifier.
networkThe blockchain network identifier.
paymentMethodThe payment method identifier.
fiatAmountThe fiat amount as a string.
isFeeExcludedFromFiatWhether 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:

NameDescription
workFlowRunIdThe 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:

NameDescription
quoteIdThe 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:

NameDescription
orderIdThe order ID (deposit format or raw Transak format).
walletThe wallet address associated with the order.
paymentDetailsOptional 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:

NameDescription
requestThe 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:

NameDescription
fiatCurrencyThe fiat currency code.
paymentMethodThe payment method identifier.
kycTypeThe 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:

NameDescription
dataThe 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:

NameDescription
emailThe 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:

NameDescription
tokenThe 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:

NameDescription
apiKeyThe Transak API key.

Handler signature:

(apiKey: string) => void

RampsController:transakSetAuthenticated​

Package: @metamask/ramps-controller

Updates the Transak authentication flag in controller state.

Parameters:

NameDescription
isAuthenticatedWhether 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:

NameDescription
employmentStatusEmployment status (e.g., "employed", "self_employed").
countryOfCitizenshipISO 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:

NameDescription
consentedAtISO 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:

NameDescription
purposeArray 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:

NameDescription
monthlyVolumeExpected monthly transaction volume.
sourceOfFundsTypeSource 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:

NameDescription
ssnThe Social Security Number.
quoteIdThe 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:

NameDescription
emailThe user's email address.
verificationCodeThe OTP code entered by the user.
stateTokenThe state token from the sendUserOtp response.

Returns: The access token for subsequent authenticated requests.

Handler signature:

(email: string, verificationCode: string, stateToken: string) => Promise<TransakAccessToken>