Skip to content

How to get the installed plugins of a Modular Account

ERC-6900 Modular Accounts implements Plugin inspection interface IAccountLoupe.sol to support visibility in plugin configuration on-chain. This contract interface defines the method getInstalledPlugins() that clients can use to fetch the currently installed plugins on a Modular Account.

/// @notice Get an array of all installed plugins.
/// @return The addresses of all installed plugins.
function getInstalledPlugins() external view returns (address[] memory);

Account Kit provides a streamlined experience of interacting with Modular Account AccoutLoupe interface easily by providing accountLoupeActions defined in @account-kit/smart-contracts package. When you connect your Modular Account to SmartAccountClient you can extend the client with accountLoupeActions, which exposes a set of methods available to call the account AccountLoupe with the client connected to the account.

Get installed plugins of a Modular Account

You should first extend the SmartAcountClient connected to a Modular Account, which has AccountLoupe implemented, with accountLoupeActions for the client to include the AccountLoupe actions.

Then, you can use the getInstalledPlugins method of the accountLoupeActions extended smart account client to get the list of installed plugin addresses for the connected Modular Account.

example.ts
import { modularAccountClient } from "./client";
import { IPluginAbi } from "@account-kit/smart-contracts";
 
// returns addresses of all installed plugins
const installedPlugins = await modularAccountClient.getInstalledPlugins({});
 
if (installedPlugins.length === 0) {
  console.log("account has no plugins installed.");
  return;
}
 
const pluginAddress = installedPlugins[0];
// read plugin metadata of a plugin
const metadata = await modularAccountClient.readContract({
  address: pluginAddress,
  abi: IPluginAbi,
  functionName: "pluginMetadata",
});
 
console.log(JSON.stringify(metadata, null, 2));
// {
//   name: 'MultiOwnerPlugin',
//   version: '1.0.0',
// }

By checking if a certain plugin address exists in the list of installed plugin addresses of a Modular Account, you can check whether a particular plugin is installed or not on a Modular Account.