Skip to content

APTOS

Integrating

Detecting the Provider

MathWallet will inject an object called aptos on the window object of any web application the user visits.

To detect if a browser extension using this API is installed, you can check for the existence of the aptos object.

To make it easy to detect MathWallet specifically, the extension adds an additional isMathWallet flag.

const isMathWalletInstalled = window.aptos && window.aptos.isMathWallet

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

const getProvider = () => {
  if ("aptos" in window) {
    const provider = window.aptos;
    if (provider.isMathWallet) {
      return provider;
    }
  }
  window.open("https://mathwallet.org/", "_blank");
};

More Resources

Aptos Dapp Developer Guide

https://aptos.dev/tutorials/your-first-dapp