Detecting the Provider

To check if a user has Panda installed, a web application needs to verify the existence of a panda object. The Panda browser extension automatically injects a panda object into the window of any web application the user visits.

If the panda object is present, Bitcoin SV and 1Sat Ordinal applications can interface with Panda Wallet utilizing the API located at window.panda.

To determine if Panda is installed, an application should check for the panda object.

const isPandaInstalled = window.panda.isReady

If Panda is not installed, it is recommended to redirect users to the chrome extension. Below is an example of how this might be implemented.

const initProvider = () => {
  if ('panda' in window) {
    const provider = window.panda;

    if (provider?.isReady) {
      return provider;
    }
  }

  window.open('https://chromewebstore.google.com/detail/panda-wallet/mlbnicldlpdimbjdcncnklfempedeipj', '_blank');
};

From here you can simply create an instance of the provider and call its methods.

const wallet = initProvider();

wallet.isConnected(); // Returns a boolean indicating the connection status
wallet.connect(); // Will open a connect prompt
wallet.getAddresses(); // Get's the users public BSV and Ordinal addresses

// etc

Last updated