Magic Eden Wallet Developer Docs
  • 👋Welcome
    • Wallet Introduction
  • 📙Bitcoin
    • Diving into Bitcoin
    • Detecting the Provider
    • Connecting to the Wallet
    • Signing a Message
    • Signing a Transaction
    • Sending BTC
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📗Solana
    • Diving Into Solana
    • Solana Wallet Adapter
    • Connect Directly to the ME Solana Provider
    • Signing a Message
    • Sending a Transaction
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📘EVM
    • Diving into the EVM
    • Connect Directly to the ME EVM Provider
    • Signing a Message
    • Sending a Transaction
    • Library Integrations
      • Wallet Connect
      • Rainbow Kit
      • Wagmi
    • Provider API Methods
    • Provider Events
    • FAQs
  • ❓Resources
    • Demo Apps
    • Logos and Brand Assets
Powered by GitBook
On this page
  • Detecting the Provider
  • Connecting
  • More Info
  1. Solana

Connect Directly to the ME Solana Provider

Detecting the Provider

If you've built a custom wallet connection solution and want to add support for the Magic Eden Wallet, you can directly access the Solana Provider at magicEden.solana in the Window.

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.

The easiest way to connect to the ME wallet is by calling window.magicEden.solana.connect()

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

PreviousSolana Wallet AdapterNextSigning a Message

Last updated 11 months ago

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

📗
here