Connecting to Snaps from your dapp is now easier with EIP-6963 Multi Injected Provider Discovery #2001
Montoya
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Have you ever struggled with dapp connections? Have you ever noticed that
window.ethereumsometimes gets modified by browser extensions other than MetaMask? Well you can now use EIP-6963: Multi Injected Provider Discovery to simplify your dapp connect code and consistently get the MetaMask provider in your dapp.Here is an example of how this works: https://montoya.github.io/snap-connect-example/
The relevant code to get the
ProviderDetailis just a few lines:EIP-6963 prescribes an event-based model, where the dapp dispatches an event requesting wallet providers and the providers can each respond with an event to be discovered. Since EIP-6963 support was added to MetaMask / MMI / Flask after Snaps, you can just assume using EIP-6963 gives you Snap-enabled MetaMask regardless.
Benefits of this approach:
Try it in your dapps! If you have any questions, feel free to ask here.
Beta Was this translation helpful? Give feedback.
All reactions