Check MSafe environment

Detecting the Msafe Wallet environment

To use MSafe wallet, the app website must be running in an iframe under the msafe website. To detect if the application is running in MSafe website:

  • Check if the MSafeWallet.inMSafeWallet() return true.

If the msafe wallet environment is detected, you may connect to the MSafe wallet at initialization.

Example:

Detecting Msafe Wallet
import { MSafeWallet } from "msafe-wallet";

// check if the dapp is running in msafe
if (!MSafeWallet.inMSafeWallet()){ 
    const url = MSafeWallet.getAppUrl(); // get dapp url for msafe
    window.location.href.replace(url); // redirect to msafe dapp
}

Last updated