Connecting Directly to Magic Eden Wallet

Interested in individually adding support for the ME Wallet? We've got you covered

If your application does not use the Solana Wallet Adapter, you can integrate with magicEden directly by interacting with the injected magicEden provider object.

Detecting the Provider

Magic Eden's wallet browser extension will automatically inject a magicEden object into the window of any web application that the user visits, assuming that the user has the ME extension installed.

A code snippet to find the provider might look like the following:

const getProvider = () => {
  // check if the magicEden object is available
  if ('magicEden' in window) {
    const magicProvider = window.magicEden?.solana;
    if (magicProvider?.isMagicEden) {
      return magicProvider;
    }
  }
  window.location.href = 'https://wallet.magiceden.io/'
};

The above will return the provider if the user has the extension installed, otherwise it'll redirect the user to the magic eden wallet website to download it.

Connecting

Once the magicEden provider object has been found, a user is able to connect their wallet to the site. The connection request will prompt the user to approve the connection, so that their wallet can be used to make requests, such as sending transactions.

By default, the Magic Eden wallet saves your web3 connections so you don't have to constantly re-approve the connection. You can delete whitelisted sites in the profile -> web3 section of your wallet

Prompting the connection may look like the following:

const provider = getProvider();

const handleConnect = async () => {
  try {
    await provider.connect();
  } catch (error) {
    console.error(error);
  }
};

The provider saves information like a user's pubkey once a connection has been established.

More Info

A code demo for basic ME wallet connection can be found here. A demo video can be found in the readme.