SnapAccountService Actions
10 actions registered.
| Name | Deprecated |
|---|---|
ensureMigrated | |
ensureReady | |
getAccountAssets | |
getAccountBalances | |
getAccountTransactions | |
getCapabilities | |
getSnaps | |
handleKeyringSnapMessage | |
resolveAccountAddress | |
setSelectedAccounts |
SnapAccountService:ensureMigrated
Package: @metamask/snap-account-service
Migrate the legacy Snap keyring to the new (per-snap) Snap keyring v2.
Expected to be triggered at KeyringController:unlock time.
Safe to call concurrently — the migration runs only once; all callers
await the same promise.
Returns: A promise that resolves when the migration is complete.
Handler signature:
() => Promise<void>
SnapAccountService:ensureReady
Package: @metamask/snap-account-service
Ensures everything is ready to use Snap accounts for the given Snap.
- Validates that
snapIdis a tracked account-management Snap. - Asserts that the legacy -> v2 migration has been triggered (expected to
happen at
KeyringController:unlocktime). - Atomically creates the v2 keyring for this Snap if it doesn't exist yet.
- Waits for the Snap platform to be fully started.
Safe to call concurrently — each step is idempotent or mutex-protected.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap to ensure readiness for. |
Handler signature:
(snapId: SnapId) => Promise<void>
SnapAccountService:getAccountAssets
Package: @metamask/snap-account-service
Returns the CAIP-19 asset type/ID list supported by an account.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
id | ID of the account. |
Returns: A promise resolving to the list of supported CAIP-19 asset type/IDs.
Handler signature:
(snapId: SnapId, id: AccountId) => Promise<CaipAssetTypeOrId[]>
SnapAccountService:getAccountBalances
Package: @metamask/snap-account-service
Returns the balances for an account for the requested asset types.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
id | ID of the account. |
assets | List of CAIP-19 fungible asset types to fetch balances for. |
Returns: A promise resolving to a map of asset type to balance.
Handler signature:
(snapId: SnapId, id: AccountId, assets: CaipAssetType[]) => Promise<Record<CaipAssetType, Balance>>
SnapAccountService:getAccountTransactions
Package: @metamask/snap-account-service
Returns a page of transactions for an account.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
id | ID of the account. |
pagination | Pagination options. |
Returns: A promise resolving to a page of transactions.
Handler signature:
(snapId: SnapId, id: AccountId, pagination: Pagination) => Promise<TransactionsPage>
SnapAccountService:getCapabilities
Package: @metamask/snap-account-service
Returns the keyring capabilities declared by the given Snap. These are populated by the bridge keyring from the Snap's manifest, and describe which keyring features the Snap supports (scopes, BIP-44 options, etc.).
Consumers use this to decide whether to drive the Snap through the v1 or v2 keyring path. Reading capabilities does not mutate state, so the lock-free keyring access is used.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
Returns: The Snap's keyring capabilities.
Handler signature:
(snapId: SnapId) => Promise<KeyringCapabilities>
SnapAccountService:getSnaps
Package: @metamask/snap-account-service
Returns the IDs of all currently tracked account-management Snaps —
Snaps that are installed, enabled, not blocked, and have the
endowment:keyring permission.
Returns: The IDs of tracked account-management Snaps.
Handler signature:
() => SnapId[]
SnapAccountService:handleKeyringSnapMessage
Package: @metamask/snap-account-service
Handle a message from a Snap.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
message | Message sent by the Snap. |
Returns: The execution result.
Handler signature:
(snapId: SnapId, message: SnapMessage) => Promise<Json>
SnapAccountService:resolveAccountAddress
Package: @metamask/snap-account-service
Resolves the account address to use for routing a signing request.
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
scope | CAIP-2 chain ID of the signing request. |
request | The signing JSON-RPC request. |
Returns: A promise resolving to the resolved address, or null if the Snap cannot determine an address for this request.
Handler signature:
(snapId: SnapId, scope: CaipChainId, request: JsonRpcRequest) => Promise<ResolvedAccountAddress | null>
SnapAccountService:setSelectedAccounts
Package: @metamask/snap-account-service
Notifies a Snap of the currently selected accounts.
For v1 Snaps the call goes through the keyring (signing interface); for v2 Snaps it is routed via the RPC client because the keyring only covers keyring-only operations (signing, account lifecycle).
Parameters:
| Name | Description |
|---|---|
snapId | ID of the Snap. |
accounts | IDs of the accounts to mark as selected. |
Handler signature:
(snapId: SnapId, accounts: AccountId[]) => Promise<void>