PolkadotJS App

Integration For PolkadotJs

Follow these steps to integrate your application with Mimir:

1. Inject SDK into Your Application

Substrate-based wallets inject an object into window.injectedWeb3 for interaction. Mimir follows this approach but uses an iframe, so direct injection into the window object isn't possible. Instead, use the provided npm package for injection.

Check if Opened in an Iframe

First, determine if the application is opened within an iframe:

const openInIframe = window !== window.parent;

Check if Opened in Mimir's Iframe

Use the following function to check if the application is opened within Mimir's iframe:

import { inject, isMimirReady, MIMIR_REGEXP } from '@mimirdev/apps-inject';

const origin = await isMimirReady();

if (!origin) {
  // Not opened in Mimir
  return;
}

// Verify if the URL matches Mimir's pattern
if (MIMIR_REGEXP.test(origin)) {
  // Inject Mimir into window.injectedWeb3
  inject();
  // Now you can use polkadot extension functions
}

2. Retrieve the Multisig Account

Mimir implements the same interface as polkadot-js/extension, allowing you to obtain multisig accounts similarly to other plugin wallets.

Example Code

Use the following code snippet to obtain the multisig account:

3. Sign and Send Transactions

To send a transferKeepAlive transaction using Mimir's multisig account, follow these steps:

Example Code (for @polkadot/api >= v15.0.1)

Example Code (for @polkadot/api < v15.0.1)

Last updated