> For the complete documentation index, see [llms.txt](/llms.txt).

# Custom EVM accounts

caution

MetaMask is not currently accepting allowlisting requests for Custom EVM Account Snaps.

The Keyring API integrates custom EVM accounts inside MetaMask. You can use the Keyring API to display custom accounts, such as multi-party computation (MPC) accounts and [ERC-4337 accounts](#account-abstraction-erc-4337), alongside regular MetaMask accounts in the user interface:

![Account management Snap accounts in MetaMask UI](/assets/images/accounts-ui-6200682f7b2f25a2753108a83abad199.png)

To use the Keyring API, you first [implement the API in an account management Snap](/snaps/features/custom-evm-accounts/create-account-snap/)(also known as an "account Snap"). You can then [call Keyring API methods from a companion dapp](/snaps/features/custom-evm-accounts/create-companion-dapp/)to enable users to create and interact with the custom accounts.

see also

- [Create an account management Snap](/snaps/features/custom-evm-accounts/create-account-snap/)
- [Create an account management companion dapp](/snaps/features/custom-evm-accounts/create-companion-dapp/)
- [Account management Snap security guidelines](/snaps/features/custom-evm-accounts/security/)
- [Keyring API reference](/snaps/reference/keyring-api/)

## System context diagram[​](#system-context-diagram "Direct link to System context diagram")

The following diagram shows the system context when interacting with accounts managed by an account management Snap:

The diagram contains the following components:

- **User** - The user interacting with the dapp, the Snap companion dapp, and MetaMask.
- **Dapp** - The dapp requesting an action to be performed on an account.
- **MetaMask** - The wallet the dapp connects to. MetaMask routes requests to the account management Snap and lets the user perform some level of account management.
- **Snap** - The account management Snap that implements the Keyring API to manage the user's accounts and handle requests that use these accounts.
- **Snap companion dapp** - The Snap's user interface component that allows the user to interact with the Snap to manage accounts and requests.

## Account management Snap installation flow[​](#account-management-snap-installation-flow "Direct link to Account management Snap installation flow")

The first process a user encounters when using an account management Snap is the Snap installation flow. This process can be initiated through MetaMask's or the Snap companion dapp. The flow looks like the following:

The MetaMask account selection modal has an option called **Add account Snap**. This option shows a list of account management Snaps. Each Snap redirects the user to the companion dapp that contains the user interface to configure and manage the Snap.

## Custom account creation flow[​](#custom-account-creation-flow "Direct link to Custom account creation flow")

Once the account management Snap is installed, the user can use the Snap companion dapp to create or import custom accounts. The flow looks like the following:

The companion dapp presents a user interface allowing the user to configure their custom account. The dapp creates an account using [keyring_createAccount](/snaps/reference/keyring-api/account-management/#keyring%5Fcreateaccount).

The Snap keeps track of the accounts that it creates using [snap_manageState](/snaps/reference/snaps-api/snap%5Fmanagestate/). Once the Snap has created an account, it notifies MetaMask using [snap_manageAccounts](/snaps/reference/snaps-api/snap%5Fmanageaccounts/).

Once the Snap has created an account, that account can be used to sign messages and transactions.

## Transaction flows[​](#transaction-flows "Direct link to Transaction flows")

The Keyring API supports two flows for handling requests: [synchronous](#synchronous-transaction-flow)and [asynchronous](#asynchronous-transaction-flow).

In general, you should use the asynchronous flow when the request requires user interaction (for example, using a hardware key or a threshold signature scheme) or when the request takes a long time to complete. You should use the synchronous flow for any other use case.

### Synchronous transaction flow[​](#synchronous-transaction-flow "Direct link to Synchronous transaction flow")

The synchronous flow looks like the following:

The flow starts when a user or dapp initiates a sign request. At that point, MetaMask detects that this interaction is requested for an account controlled by the account management Snap.

After the user approves the transaction in MetaMask, MetaMask calls [keyring_submitRequest](/snaps/reference/keyring-api/account-management/#keyring%5Fsubmitrequest), which receives the original RPC request and returns a response with `pending` set to `false`, and `result` set to the requested signature.

### Asynchronous transaction flow[​](#asynchronous-transaction-flow "Direct link to Asynchronous transaction flow")

The asynchronous flow looks like the following:

The flow starts the same way as the [synchronous flow](#synchronous-transaction-flow): a user or dapp initiates a sign request. After approval, MetaMask calls [keyring_submitRequest](/snaps/reference/keyring-api/account-management/#keyring%5Fsubmitrequest).

Since the Snap doesn't answer the request directly, it stores the pending request in its internal state using [snap_manageState](/snaps/reference/snaps-api/snap%5Fmanagestate/). The Snap sends a `{ pending: true, redirect? }` response to indicate that the request will be handled asynchronously. This response can optionally contain a redirect URL that MetaMask will open in a new tab to allow the user to interact with the Snap companion dapp.

The companion dapp gets the Snap's pending request using [keyring_getRequest](/snaps/reference/keyring-api/account-management/#keyring%5Fgetrequest). It resolves the request using [keyring_approveRequest](/snaps/reference/keyring-api/account-management/#keyring%5Fapproverequest), and the Snap resolves the request using [snap_manageAccounts](/snaps/reference/snaps-api/snap%5Fmanageaccounts/), notifying MetaMask of the result.

## EOA methods[​](#eoa-methods "Direct link to EOA methods")

An account management Snap can implement the following methods to support dapp requests from externally owned accounts (EOAs):

- [personal_sign](/snaps/reference/keyring-api/chain-methods/#personal%5Fsign)
- [eth_signTypedData_v4](/snaps/reference/keyring-api/chain-methods/#eth%5Fsigntypeddata%5Fv4)
- [eth_signTransaction](/snaps/reference/keyring-api/chain-methods/#eth%5Fsigntransaction)

## Account abstraction (ERC-4337)[​](#account-abstraction-erc-4337 "Direct link to Account abstraction (ERC-4337)")

Flask Only

This feature is experimental and only available in [MetaMask Flask](https://metamask-docs-f8nytczy3-consensys-ddffed67.vercel.app/snaps/get-started/install-flask/), the canary distribution of MetaMask.

Account abstraction, specified by [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337), introduces _user operations_ and enables users to manage smart contract accounts containing arbitrary verification logic. Users can use these ERC-4337 accounts instead of externally owned accounts as primary accounts.

An account management Snap can implement the following methods to support dapp requests from ERC-4337 accounts:

- [eth_prepareUserOperation](/snaps/reference/keyring-api/chain-methods/#eth%5Fprepareuseroperation)
- [eth_patchUserOperation](/snaps/reference/keyring-api/chain-methods/#eth%5Fpatchuseroperation)
- [eth_signUserOperation](/snaps/reference/keyring-api/chain-methods/#eth%5Fsignuseroperation)

The user operation signing flow in an ERC-4337 compatible account Snap looks like the following:

See the [ERC-4337 methods](/snaps/reference/keyring-api/chain-methods/#erc-4337-methods) for more information about their parameters and response details.

## Examples[​](#examples "Direct link to Examples")

See the following example account management Snap implementations:

- [Simple Account Snap](https://github.com/MetaMask/snap-simple-keyring)
- [Simple Account Abstraction Snap](https://github.com/MetaMask/snap-account-abstraction-keyring/tree/main) (ERC-4337)
- [Biconomy Smart Account Snap](https://github.com/bcnmy/smart-account-keyring-template) (ERC-4337)
- [Silent Shard Snap](https://github.com/silence-laboratories/silent-shard-snap)
- [Safeheron MPC Snap](https://github.com/Safeheron/multi-mpc-snap-monorepo)
- [Capsule Keyring Snap](https://github.com/capsule-org/mm-snap-keyring)
