DappCon 2023: Revolutionizing Web3 With Metamask Snaps - Hassan Malik

DappCon 2023 · September 2023 · 15:11

A talk from Hassan Malik at DappCon 2023 on building with MetaMask Snaps. Snaps is a system that lets developers extend MetaMask's functionality through community-built plugins, covering things like custom chain support and transaction insights, without changing MetaMask's core code.

Speakers

Topics

From DappCon 2023, hosted by Dappcon Berlin.

Transcript

hi how's everyone doing uh is everyone familiar with uh metam Mass snaps by a show of hands anyone cool okay so uh for those who aren't I'm I'm going to introduce you to snaps in a little bit but I'd like to walk you guys through uh the history of metamask and how we've been revolutionizing web 3 and making it easier for developers to make daps uh so this is the agenda uh we'll be walking through the history of metamask uh the problems with our current architecture um what we see as the next revolutionary step in met uh in in web 3 metam Mass snaps uh and then

I'll be talking about some standards uh and then some closing remarks so uh how have we made it easy for devs to develop daps uh we started with the injected web 3js Prov provider into the window object all you need to have is metamask installed and you're good to go no need to set up your uh node uh it can be it can be daunting to set up a node yourself maintain that and interact with it it seems like a lot of friction uh to get started as a Dap developer uh and and you know doing install injecting web 3js into the window object was a way to make it easier for uh developers to just start making daps what was the next step uh in

January 2021 we stopped injecting web3js and move to our current setup uh window. ethereum uh so we currently have two ways to to get started building a Dap uh we have our uh metamask detect provider package and we have our uh metamask SDK which is a bit more robust um and then moving forward uh we introduced uh wallet methods uh that made it more convenient for dap developers to create a seamless experience uh so here's the list of the the wallet methods that we have we have wallet request permissions that'll let you request permissions uh to to eth

accounts wallet get permissions it'll show you what permissions that you have wallet add ethereum chain uh you know it'll open up a prompt for you to add uh a new chain wallet switch ethereum chain it'll let you switch a chain uh register onboarding it'll let you register your dap uh to kick back to after the onboarding process uh wallet watch asset it'll let you register your nfts uh wallet scan QR code self-explanatory um so moving on forward uh what is the problem with our current architecture so to show you our current architecture we have the metamask extension we have metamask mobile and uh

we have the DAP that interacts with uh with both through Json RPC uh it relays requests to extension and then those get relayed over to our uh node provider so does anyone see uh bottlenecks in this architecture right now by a show of hands anyone so the the bottleneck exists at the at the node level and at act extension level so what this means is that if if if we're only dealing with infer and it makes it difficult to to to do transactions on non on non-m networks uh

so it it would it would you know we've been traditionally an ethereum wallet and and and now a evm wallet uh but we can't move past that if we have this architecture and and similarly with with extension uh you know we have a a set API that we're building uh that developers will re will will rely on and the thing is that they have to move at our pace uh and so that makes it difficult for the wallet to grow quickly with with people's uh needs and wants um moving forward we have you know we have too many features to build we have so many issues open uh that it makes it difficult from a Manpower perspective uh

to be able to address all the things that people want uh so what is our solution to this um we also have too many chains to support as a landscape grows larger it becomes more difficult to provide for a consistent and Rich experience most chains have different variables and it makes it difficult to reliably do things like gas estimation non-m chain support just like as I was mentioning so what is the what is the solution to this uh metamask snaps so what we have decided is to decentralize the wallet so what are metam mass snaps and why do we need them snaps is a

platform that allow allows anyone to extend uh functionality of metamask without asking for permission from metamask or from anyone other than the end user a snap is a JavaScript program that is ran in a sandbox execution environment it lets you interact in new ways with the wallet and essentially modularize it and how do snaps work uh snaps utilize our existing permission system to request a set of permissions from the user when in installing a a snap and so these permissions uh let the DAP developer do interesting things uh the set of permissions currently available for the platform are

are at this link provided uh and some of the uh so some of the so snaps Works using methods in Json RPC request similar to how daps interact with our ethereum provider now uh and so some of the snap methods that we have available are snap manage State SNAP get bip44 entropy uh you can see that their prefix would snap uh so this is our architecture currently uh with snaps uh it's it's a bit small uh but you can see uh you know we have uh we have the snap we have npm we have metamask uh we have our execution environment and so all of

these work in tandem uh to be able to execute the snap code and and get back the result uh to the extension itself uh this is an example of uh a sample snap um you know these are lightweight JavaScript programs uh similar to AWS lambdas they they have an ephemeral life cycle um and uh so if you see uh you know we we have exports uh so this is the most common one on RPC requests so whenever a snap gets uh an RPC request Quest it would it would render uh it through this code so we think that everything is good

now right we've we've uh you know uh we have this great permissionless platform we we have an API uh where we expose certain methods that developers can use but this is not good enough uh how do we know what people want how can we get feedback from the public how do we handle what we call protocol snaps uh which are essentially pushing us into a non-m world what are the rules of engagement instead of s siloing the the work within metamask uh we want to get people involved with what we do and how we move forward as a whole in the space so this leads me to

uh sipping on a cold one in Mikasa so water sips and what is gasa sips stand for snaps Improvement proposals akin to eips these proposals help shape the platform and allow for anyone outside of our organization to get involved we've already had a few people uh write sips and and these sips definitely help us uh set the vision for where we want to move forward in the snaps platform what is CA uh Casa stands for chain agnostic standards Alliance it's a collection of working groups that create blockchain agnostic standards uh so some of the work that we're doing there uh currently it it has to do uh you know

with with multi-chain so uh current current work is Cape 25 um it outlines the request for adapt to multiple chains uh and and this is ongoing work this is work that's open to the public uh and and and you know these are things that we would like input from from the Greater Community from dap developers uh and so some closing remarks um we have some links here uh that'll show you how to get started with snaps um currently uh Snaps are allow listed uh and um you know snap developers would have to get their snap audited uh to get added to our allow list but in the future we're we're hoping to move towards a

permissionless distribution uh um scheme um so here you can see the link for our uh GitHub repo for the sips and also the the repo uh for Casa um yeah this is pretty much it uh if you if anyone has questions uh feel [Applause] free thank you so much Malik [Music] yeah thanks uh thanks Snaps are cool um Can snaps talk to each other they can cool okay short and sweet hey thank you so it basically

opens up the app store problem of of curation right could you expand a little bit how you think about what gets a snap approved is it just having an audit or are this there going to be any other criteria of what you are going to allow to interact with metam right so a currently the way it works is that we'll we'll work closely with SNAP developers right to to help them to even get started with a snap and create the snap uh you know if they so need uh you know we have great documentation right now uh but the process of getting into uh our allow list would be yeah to uh get audited uh by uh by some firm you know we have firms that we can suggest as well uh and then the idea we would be reviewing the

audit report ourselves and then we get add you to our allow list uh but in the future uh we're hoping to move towards a scheme where we're not you know The Gatekeepers to this and and anyone can create a snap and and you know have it installed within the extension um now that that can seem daunting right anyone can create a snap and and and anyone's uh snap can be executed in extension that's why we're moving uh iteratively in a in a manner where we can make sure that in the future uh you know dap develop like malicious dap U malicious nap Developers wouldn't be able to get their code into the extension so that's

why you know we're starting off with allow lless and then uh we're currently exploring Solutions how to get this into a a per permission list distribution thanks all right yeah thanks um do snaps have access to uh signer accounts for example to support smart contract wallets uh yes yes we're working on uh we're working on account exraction as well uh there's a question on the back ah there you go yes I was wondering how your how

you're managing that balance with security um since it's you know the the browser extension is such a right um you know potentially dangerous place it um where do you draw the line and how do you plan to do that in the future when you get to that point when you're you know potentially allowing any kind of right so uh to to explain that a little bit to talk about the security aspect of snaps so the Snaps are ran in a sandbox expire uh uh execution environment using secure ecmascript uh so uh if if you remember I was talking about permissions uh and how snaps work with permissions on top of our permission system what those permissions do is they afford certain globals uh to this execution environment

so uh if you guys aren't familiar with secure OS script they have a compartment module that lets you uh run code inside of it uh and so uh these permissions they would afford certain globals to it so you know if a snap doesn't have permissions it can't do anything outside of that got it so you have an interface between the core metamask logic and the environment that is running in cool thanks uh the App Store was mentioned before what guarantees do we have today

building on top of snaps that you will not at some point say you create Revenue within your snap we want some part of that Revenue oh no we're not I we're we're not looking to make Revenue off of snaps the idea is to uh increasingly let users modify the wallet how they see I mean um metamask has other other other revenue streams and and uh snaps is not necessarily something that we're looking to like make money off of uh um you know snap developers they can certainly create models around their snaps uh uh uh to do so um and you know we we have a few uh partner snaps uh transaction

Insight snaps that you know have certain models as to like how many free insights you get and then based on that you know you might have to pay more money but we're not looking to make any money off of snaps but no guarantees what's that there's no guarantees as of now uh I mean I I can't say for sure but yeah like that's not in our in our strategy yeah yeah I don't want to say you know yes or no but yeah it's not in our strategy okay thank you any other questions for Malik all right in that case thank you once more thank you