Detecting the Provider
Last updated
Last updated
The ME wallet injects a magicEden
object into the window of most any web page that a user may visit. To interact with the Bitcoin provider directly, you can access at the unique namespace window.magicEden.bitcoin.
Simultaneously, the Bitcoin provider is injected into window.BitcoinProvider
. There are a few different reasons for this, but occasionally the BitcoinProvider
can be overwritten by other wallets who occupy the same namespace. Therefore, we make use of the to successfully identify the correct provider in this case.
We recommend interacting via our unique window.magicEden.bitcoin
namespace whenever possible to avoid the above conflicts.
To properly detect if the ME wallet is installed, you can look for an additional isMagicEden
flag. All together it will look something like this:
Alternatively, you can utilize the to identify a list of all wallets that comply with the standard, and select Magic Eden from there. This requires a bit more leg work up front, but allows app developers to easily discover all compatible BTC wallets.
Caution:
The BTC development community is still rather young, and there isn't an "agreed upon" standard like you might find in Solana. Due to this, not all wallets comply to the above standard, and therefore you will not be able to locate all wallets with one blanket solution for now.
To start:
The WalletStandardProvider is a React context provider from @wallet-standard/react
, designed to interface with cryptocurrency wallets, specifically focusing on Bitcoin transactions in this context. It abstracts wallet interactions, providing a standardized way to connect to, manage, and perform transactions with BTC wallets.
After setting up the above helper functions, you can display a list of all compliant Wallet Standard wallets and have a user select which they would like to connect to.
Reference our for a full code breakdown of this implementation style.