Skip to main content

Create an account management companion dapp

Create a companion dapp to provide a user interface for your account management Snap. Call Keyring API methods from your companion dapp, enabling users to create and interact with custom EVM accounts.

Prerequisites

An account management Snap set up.

Steps

1. Install the Keyring API

Install the @metamask/keyring-api module in your project directory using Yarn or npm:

yarn add @metamask/keyring-api

or

npm install @metamask/keyring-api

2. Create a KeyringSnapRpcClient

Create a KeyringSnapRpcClient:

import { KeyringSnapRpcClient } from "@metamask/keyring-api";
import { defaultSnapOrigin as snapId } from "../config";

let client = new KeyringSnapRpcClient(snapId, window.ethereum);

3. Call Account Management API methods

You can now use the KeyringSnapRpcClient to invoke Account Management API methods on your Snap.

For example, to call keyring_listAccounts:

const accounts = await client.listAccounts();

Example

See the example companion dapp source code for more information.