Skip to content



Detecting the Provider

MathWallet will inject an object calledsolana 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 solana object.

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


const isMathWalletInstalled = window.solana && window.solana.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 ("solana" in window) {
    const provider = window.solana;
    if (provider.isMathWallet) {
      return provider;
  }"", "_blank");

Establishing a Connection

In order to start interacting with MathWallet you must first establish a connection. This connection request will prompt the user for permission to share their public key, and indicate that they are willing to interact further.


When the user has accepted the request to connect, the provider will emit a connect event.

      .then((account: any) => {
        this._publicKey = new PublicKey(account);
        this._connected = true;
        this.emit('connect', this._publicKey);
      .catch(() => {
      .finally(() => {
        this._onProcess = false;

Once the web application is connected, it will be able to read the connected account info

// 2TE8zHirQSQ44ojJvnw9qBs5rjWFa5YJEF1EYyyutjbS 
// true
// true or false


Disconnecting is similar to connecting, however, it is possible for the disconnection to originate from the wallet.


Sending a Transaction

Once the web application is connected to MathWallet, it can send transactions on behalf of the user, with the user's permission.

In order to send a transaction, the web application must:

  • Create an unsigned transaction or transactions.
  • Have it be signed by the user's MathWallet.
  • Send it to a Solana node for processing.

For more information about the nature of transactions on Solana, it is recommended to review the solana-web3.js docs as well as the official Solana docs.

const network = "<NETWORK_URL>";
const connection = new Connection(network);
const transaction = new Transaction();
const signedTransaction = await window.solana.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());

Signing Multiple Transactions

It is also possible to sign and send multiple transactions at once. This is exposed through the signAllTransactions method on the provider.

const signedTransactions = await window.solana.signAllTransactions(transactions);

Signing a Message

When the web application is connected to MathWallet, it can also request that the user signs a given message.

In order to send a message for the user to sign, the web application must:

  • Provide a hex or UTF-8 encoded string as a Uint8Array.
  • Have it be signed by the user's MathWallet.
const message = `Owner of punk #8888`;
const encodedMessage = new TextEncoder().encode(message);
const signedMessage = await window.solana.signMessage(encodedMessage, "utf8");

SOL Wallet Adapter Samples (Multi-wallets Support)

You can reference serum dex or serum swap code which using the sol-wallet-adapter connects to multiple wallets

Such as:

SOL Wallet Adapter provided unified methods based on user's wallet selection

Front-end code can reference:

If you are using the sol-wallet-adapter which allows your dapp connects to multiple wallets, here are the changes need for MathWallet:

Sample 1

Sample 2

Common errors in wallet.tsx config (which will cause the wallet cannot inject to the dapp site)


More Resources


RPC document

Fungible Tokens

SPL Token Registry

Submit to MathWallet

Non-Fungible Tokens (NFT)

Metaplex NFT Stardard