AssetsController Actions
17 actions registered.
AssetsController:addCustomAsset
Package: @metamask/assets-controller
Add a custom asset for an account. Custom assets are included in subscription and fetch operations. Adding a custom asset also unhides it if it was previously hidden, and force-fetches that asset's chain (including every visible pin).
When pendingMetadata is provided (e.g. from the extension's pending-tokens
flow), the token metadata is persisted immediately into assetsInfo so the
UI can render it without waiting for the next pipeline fetch.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID to add the custom asset for. |
assetId | The CAIP-19 asset ID to add. |
pendingMetadata | Optional token metadata from the UI (pendingTokens format). |
bypassServerCache | Also bypass server-side HTTP caches (e.g. the Accounts API's 60s cache) on the force-fetch, e.g. right after a transaction that changed this asset's balance. Only applies when accountId belongs to the selected account group. |
Handler signature:
(accountId: AccountId, assetId: Caip19AssetId, pendingMetadata?: PendingTokenMetadata, bypassServerCache?: boolean) => Promise<void>
AssetsController:getAccountAssetByID
Package: @metamask/assets-controller
Get a single combined asset (balance + metadata + price + computed
fiatValue) for an account directly from controller state.
Reuses the same state-composition and filtering logic as getAssets
(balance and metadata are required, a missing price falls back to a
fungible price of 0 with fiatValue: 0, and hidden or
otherwise filtered assets are excluded) so the returned shape never
drifts from getAssets. Reads from current state only and does not
trigger a data-source refresh.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID (InternalAccount.id, not an address). |
assetId | The CAIP-19 asset ID including chain scope (e.g. eip155:1/erc20:0x...). |
Returns: The combined Asset, or undefined when no complete renderable asset (balance + metadata) exists for the account/asset pair.
Handler signature:
(accountId: AccountId, assetId: Caip19AssetId) => Asset | undefined
AssetsController:getAccountAssetsByIDs
Package: @metamask/assets-controller
Get multiple combined assets (balance + metadata + price + computed
fiatValue) for an account directly from controller state.
Applies the same state-composition and filtering rules as
getAccountAssetByID to each requested asset ID. Asset IDs that do not
resolve to a complete renderable asset (missing balance/metadata, hidden,
or otherwise filtered out) are omitted from the result. Reads from
current state only and does not trigger a data-source refresh.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID (InternalAccount.id, not an address). |
assetIds | The CAIP-19 asset IDs including chain scope (e.g. eip155:1/erc20:0x...). |
Returns: A record of combined Assets keyed by normalized CAIP-19 asset ID, containing only the requested assets that resolved.
Handler signature:
(accountId: AccountId, assetIds: Caip19AssetId[]) => Record<Caip19AssetId, Asset>
AssetsController:getAccountAssetsByScope
Package: @metamask/assets-controller
Get all combined assets (balance + metadata + price + computed
fiatValue) an account holds on a given chain scope, directly from
controller state.
Applies the same state-composition and filtering rules as
getAccountAssetByID (hidden or otherwise filtered assets are excluded).
Reads from current state only and does not trigger a data-source refresh.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID (InternalAccount.id, not an address). |
scope | The CAIP-2 chain ID to filter by (e.g. eip155:1). |
Returns: A record of combined Assets keyed by CAIP-19 asset ID, containing only the account's assets on the given scope.
Handler signature:
(accountId: AccountId, scope: ChainId) => Record<Caip19AssetId, Asset>
AssetsController:getAssetMetadata
Package: @metamask/assets-controller
Handler signature:
(assetId: Caip19AssetId) => AssetMetadata | undefined
AssetsController:getAssets
Package: @metamask/assets-controller
Handler signature:
(accounts: InternalAccount[], options?: {
chainIds?: ChainId[];
assetTypes?: AssetType[];
forceUpdate?: boolean;
/**
* Also bypass server-side HTTP caches (e.g. the Accounts API's 60s
* cache, via a random `bypassServerCache` query param). Only meaningful
* together with `forceUpdate`. Use sparingly — e.g. right after a
* transaction confirms, when the API's cached snapshot is known stale.
*/
bypassServerCache?: boolean;
dataTypes?: DataType[];
}) => Promise<Record<AccountId, Record<Caip19AssetId, Asset>>>
AssetsController:getAssetsBalance
Package: @metamask/assets-controller
Handler signature:
(accounts: InternalAccount[], options?: {
chainIds?: ChainId[];
assetTypes?: AssetType[];
forceUpdate?: boolean;
}) => Promise<Record<AccountId, Record<Caip19AssetId, AssetBalance>>>
AssetsController:getAssetsPrice
Package: @metamask/assets-controller
Handler signature:
(accounts: InternalAccount[], options?: {
chainIds?: ChainId[];
assetTypes?: AssetType[];
forceUpdate?: boolean;
}) => Promise<Record<Caip19AssetId, AssetPrice>>
AssetsController:getCustomAssets
Package: @metamask/assets-controller
Get all custom assets for an account.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID to get custom assets for. |
Returns: Array of CAIP-19 asset IDs for the account's custom assets.
Handler signature:
(accountId: AccountId) => Caip19AssetId[]
AssetsController:getExchangeRatesForBridge
Package: @metamask/assets-controller
Returns exchange rates in the format expected by the bridge controller (conversionRates, currencyRates, marketData, currentCurrency) so that when useAssetsControllerForRates is true the bridge can use a single action instead of MultichainAssetsRatesController, TokenRatesController, and CurrencyRateController.
Returns: Bridge-compatible exchange rate state derived from assetsPrice and selectedCurrency.
Handler signature:
() => BridgeExchangeRatesFormat
AssetsController:getState
Package: @metamask/assets-controller
Handler signature:
() => AssetsControllerState
AssetsController:getStateForTransactionPay
Package: @metamask/assets-controller
Returns state in the legacy format expected by transaction-pay-controller (TokenBalancesController, AccountTrackerController, TokensController, TokenRatesController, CurrencyRateController shapes) so that when useAssetsController is true the transaction-pay-controller can use a single action instead of five separate getState calls.
Returns: Legacy-compatible state for transaction-pay-controller.
Handler signature:
() => TransactionPayLegacyFormat
AssetsController:hideAsset
Package: @metamask/assets-controller
Hide an asset globally. Hidden assets are excluded from the asset list returned by getAssets. The hidden state is stored in assetPreferences.
Parameters:
| Name | Description |
|---|---|
assetId | The CAIP-19 asset ID to hide. |
Handler signature:
(assetId: Caip19AssetId) => void
AssetsController:removeCustomAsset
Package: @metamask/assets-controller
Remove a custom asset from an account.
Parameters:
| Name | Description |
|---|---|
accountId | The account ID to remove the custom asset from. |
assetId | The CAIP-19 asset ID to remove. |
Handler signature:
(accountId: AccountId, assetId: Caip19AssetId) => void
AssetsController:setSelectedCurrency
Package: @metamask/assets-controller
Set the current currency.
Parameters:
| Name | Description |
|---|---|
selectedCurrency | The ISO 4217 currency code to set. |
Handler signature:
(selectedCurrency: SupportedCurrency) => void
AssetsController:syncAssetsPrices
Package: @metamask/assets-controller
Force-fetch spot prices for an explicit asset list.
Calls PriceDataSource directly and merges the result into assetsPrice.
Prices are shared across accounts, so this does not take an account or
chain scope and does not run the balance pipeline.
Returns without calling the Price API when basic functionality is off.
That matches the asset pipeline, which drops the price source in RPC-only
mode, and setSelectedCurrency, which skips its price refresh.
Parameters:
| Name | Description |
|---|---|
assetIds | CAIP-19 asset IDs to sync. |
Handler signature:
(assetIds: Caip19AssetId[]) => Promise<void>
AssetsController:unhideAsset
Package: @metamask/assets-controller
Unhide an asset globally.
Force-fetches that asset's chain (including every visible pin) so a
full snapshot can restore the balance immediately, then re-evaluates
subscriptions so later polls stop excluding it.
Parameters:
| Name | Description |
|---|---|
assetId | The CAIP-19 asset ID to unhide. |
Handler signature:
(assetId: Caip19AssetId) => Promise<void>