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.
Detecting Msafe Wallet
1
import { MSafeWallet } from "msafe-wallet";
2
3
// check if the dapp is running in msafe
4
if (!MSafeWallet.inMSafeWallet()){
5
const url = MSafeWallet.getAppUrl(); // get dapp url for msafe
6
window.location.href.replace(url); // redirect to msafe dapp
7
}
Last modified 6mo ago