Detecting the Provider

To detect if a user has already installed Martian wallet, a web application should check for the existence of an aptos object. Martian wallet browser extension will inject an aptos object into the window of any web application the user visits.

const isMartianWalletInstalled = window.martian

If Martian wallet is not installed, we recommend you redirect your users to our website. Altogether, this may look like the following.

const getProvider = () => {
  if ("martian" in window) {
    return(window.martian);
  }
  window.open("https://www.martianwallet.xyz/", "_blank");
};

Last updated