new

Init msafe wallet

To connect and use MSafe wallet, you will need to first initialize an MSafeWallet object.

const msafe = await MSafeWallet.new();

You may also pass in a list of URLs as the allowed origins of the parent frame. For example, if you only want to connect to MSafe production (https://app.m-safe.io), the msafe instance can be initialized with:

const msafe = await MSafeWallet.new([
    "https://app.m-safe.io",
]);
Allowed origins

MSafe enforces an origin check to ensure that any transaction requests initiated by dApp is passed on to a pre-defined allowed origin URL. The origin check is to prevent the potential phishing attacks launched from any unauthorized third-party.

MSafe will maintain a default list of allowed endpoints deployed by MSafe in MSafe-wallet repository. If no additional arguments is provided, the default list will be used. The current default allowlist is:

Mainnet: 'https://app.m-safe.io',
Testnet: 'https://testnet.m-safe.io',
Partner: 'https://partner.m-safe.io',

The default allowlist shall meet most requirements for MSafe integration in production and development.

Example:

Initialization
import { MSafeWallet } from "msafe-wallet";

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

Last updated