Building Onchain with Based UX

Urbe Campus ETHCC Edition 2024 · August 2024 · 22:14

Carl Fluke of Coinbase explains account abstraction in the Ethereum Foundation's terms and untangles what ERC-4337 and its infrastructure pieces do, then presents Coinbase Smart Wallet, a passkey-based smart contract wallet in the version 4 SDK that replaces the externally owned account. He closes with a Base hard fork from the day before that improved the smart wallet.

Speakers

Topics

From Urbe Campus ETHCC Edition 2024, hosted by Urbe.eth.

Transcript

[Music] all right hey everyone um today I'm going to talk mostly about coinbase smart wallet uh I should just start with what the what the agenda is so I'm going to talk about what is account abstraction so I think the the biggest part I I see in the field is people being confused by what is 4337 and the pieces that make it up so I'm going to do some kind of like 101 level background of what that is and what that means hopefully it gives you some clarity on kind of what different infrastructure pieces are and how they work together uh then I'm going to talk about coinbase smart wallet which is actually coinbase's um V4 of our SDK which switches from being just a externally owned account to using Pas

keys and um a smart contract wallet which we branded as smart wallet uh then I'm going to end with updates to Bas so Bas actually had a hard Fork upgrade yesterday um and it had an improvement for smart wallet um so felt like that was a good spot to end all right so first like when I'm talking about account extraction today I am purposefully using the ethereum foundation's definition which is um to solve the problems of an eoa when they specify these problems here they they talk about like seed phrases are hard private Keys hard what they're talking about is an EA um by allowing users to flexibly program more security which you can do through a smart contract and then also allow better user experiences which in 4337 World means you can have additional types of signing Keys um and

specifically for today pass keys so like if you've gone to like xbox.com you can now log in with Pass Key normal users are starting to get very used to that uh and now we can start to take care or take advantage of that in the ethereum world all right so what this means very tangibly for users is that today when they want to go to a Dap they get redirected to do some kind of uh wallet so that could be metamask it could be a Chrome extension it could be a mobile app could be your Ledger they then find the app store they find the right wallet they then have to go fund that wallet with so they have some gas and they can do the first transaction and then they go back to DAP and they start doing something um so with the smart wallet

Vision we very much so want a connect Wallet create wallet button that is in the DAP it's a pass key so it's native to the web you're not downloading no extension no mobile app no uh anything else that's a pop up and you're back in the dab so that's kind of the the high level vision of where we want the user experienced end up so technical background 4337 um has any actually used a bundler done a user op what's like the we got a couple all right cool so this will be good um so 4337 is decently complicated you don't need to know all of these in great detail I just would um three of these I would definitely know exist and like kind of what are the limitations of

them so first off you have user operations so it's not technically a transaction it's a user op and I'll break out what the difference is um there's like three additional fields in user op uh next you have a bundler so the bundler is a piece of infrastructure out there that takes a series of user operations and it batches them together uh and that's what um switches it and gives some advantages uh which I'll talk about in a minute so I have a a list user Ops I put them in a bundle I put all of those um transactions to the entry point contact uh entry point contract uh that then will go to each contract account that's involved and it'll actually execute the user Ops uh the other important part here is

you have a pay master so if the user op has a pay Master signature on it um the pay Master will pay for the gas or pay for like the entire transaction and I'll give examples why are we actually adding all of this complexity because that's like three additional pieces of infrastructure um the first part is we can do a simpler user experience um to actually do that there is a thing called multi call so as I said a list of user Ops instead of doing one transaction with me signing that signature I can do three so in like a normal D5 position I have to approve usdc of a certain amount I have to approve my meme token of a certain amount and then I enter the liquidity position so with an EA you

have three signatures um with 4337 you have three user Ops that have one signature um so that's like a significant Improvement to doing that um you simplify gas so you can make it so that the pay Master accepts an erc20 for gas gas so you don't need the native token um you can also pay with offchain payment methods for gas um so lots of things you can do there um smart contract upgrades so I mentioned you can do additional security so when I have a smart contract wallet it can be a proxy and you can upgrade it for your users to make it easier for them um and lastly there's Block Level Security checks so you can actually program a bit more uh security at the actual user OP level

so I mentioned before kind of what those pieces are here is a good user flow of it of I have user operations it goes to a bundler into a m poool it collects those it's 10 of them get gathered it goes to the entry point it validates that the user op is valid um so there is a validity check and that validity check can also be a security check and then actually executes what you asked it to do and then optional you can aggregate things but more importantly you can also have a pay master that pays for the gas of the bundler forward um and that that opens up a lot of doors user operation versus transaction they're mostly the same um this is a transaction um that's been around since uh 1559 um so the big difference is that you have the max priority

fee uh but then in user op world you have a few new ones so you have a nit code which you only use um when you want to deploy the smart contract wallet so you can actually know the address of your smart contract wallet before you deploy it um and it actually generates the smart contract wallet on your first transaction so like the wallet cannot exist and I can mint an nft to it and it makes the wallet at the time that I meant it um the other two big ones are three big ones you have verification gas liit and pre verification guess so this is compensating the bundler for doing the the batching and it makes it so that the bundler has a reason to to do this rather than just do it for free um and

then verification gas so the signature is is when you submit the transaction it's actually coming from the bundler and the bundler EA is getting validated but then you also have a verification gas for the pass key signer or the EA of the smart contract wallet to get verified so there is some gas overhead and that got significantly better recently uh lastly you have pay master and data so what pay Master is paying for the gas or for the entire transaction um and then there's some additional data you can put in there that people can use so that's the difference in them um I'll show documentation and showing you kind of a library difference uh if you're using smart wallet there actually isn't one we hide all of this complexity behind the scenes and you don't actually have to

add these fields okay so what do the bundler does it collects user Ops validates them validates them actually as many steps um it does a simulation it it checks gas um so just know it does more than just collects them and does a bundle uh when it has a bundle it also does a whole bunch of do user Ops conflict with each other so like if I am in a bundle um calling a factory I have to deploy that factory before I can call something in that factory so it does separate that into two separate bundles so it has some intelligence of um separating out deployments and making sure there are not collisions uh most importantly it also has like reputation

system built in so a bundler you could poison the entire bundler menol by giving it invalid um invalid user Ops um so it does have a reputation system that if you keep sending it bad um user Ops it'll block list your um e eoa account or IP or other ways um so pay Master this is where like the biggest ux Improvement is um is that you can specify individual rules so like you can make it so that hey the first time a user interacts with my contract I want their first five interactions to be free and I am in my pay master I'm putting a buet of eth to pay for it and like as a business you know that's reasonable um you don't want people to have the

friction of having to fund a wallet before doing something and it's a good way to onboard people to say hey I have a new game I can do five steps in the game now you need to pay to keep playing uh and there's a whole bunch of policies here uh you can make it er c20s um this uh policy engine has started to get much more advanced um and I actually have an example I can show where you can like fully program your own uh so it can be literally anything you want um one of the ones I'm most interested in seeing is payoff chain so like the whole concept of if I'm a subscriber of a magazine or something then I could get like five transactions on my website for free um so for coinbase specifically we have coinbase one which is a subscription um and like make it so 30

transactions on base a day are free or things like that are possible so actual smart wallet let's go into it has anybody actually used or seen the smart wallet yet yeah okay all right that's good so on a website I have my traditional connect it's going to pop up in a it should be a popup but since on full screen it's showing it as a new tab um or actually let's just switch that so that we see it so going back here I'm hitting my connect button I get a popup it's asking me to connect so I'm currently with a current account so let me just sign out real quick so this will be me as a brand new new

user and it says okay hey I already have a wallet or I want to create a smart wallet um so in this example this is my setup I a new user um so I have choices of where I want to create a pass key um so this is where if you um if you fully trust apple with your pass Keys you can do that if you want to use like a UB key or a security like that you can do that if you trust Google you have your Chrome profile um you can also use a phone or tablet and save it there um I'll just do ch Chrome profile today um and so that'll save it I use my biometric so I got my fingerprint and now I have a pass key but that is our Pass Key um so I am I'm am signing with this

smart account I'm getting this free nft I'm using a pay master so it's sponsored by Bas um all of those are configurable um so let's just go and mint this first uh I'm using my fingerprint to use that pass key I just set up and that's my signature um there was no wallet extension involved there was no Ledger mobile app any of that stuff and so I can view that transaction okay I'm just pulling up that wallet so here's that brand new wallet um make this bigger again so in it you can see it has a one token of that smart wallet adopter nft um we do verify the contract now so you can see that it's coinbase smart wallet um you can view what methods it

has most of the time you'll never have to to to mess with this directly um but the next big feature that I do want to show while I'm in here is there's a feature called Magic spend um so when I mint this again the same thing but I can switch it from paying from that account to paying with my coinbase account actually I'm not going to show this because I don't want to sign in um but what this is doing is it is actually going to use a Smart contract that is a piggy bank and it keeps that eth in that piggy bank and when I go to pay for this it pulls it from the piggy bank rather than this account so if I'm a newer user to crypto and I have 100

bucks of eth in coinbase I don't I can skip the step of going from exchange to wallet to transact and I can just go from this payment method to transact transacting so for a bunch of users this is super convenient they don't have to go copy a paste back and copy and paste an address back and forth hit and wait for completion then do the thing um they can just do the transaction um and there's a whole bunch of tools that are being built out on top of this like instant nft buy and like instant nft or D Bor things of that nature um okay so high level that is smart wallet okay so as you saw there was a pass key so the big difference here is that there is no pin um there was no password it was your Biometrics

so especially if you're on things like iPhone um iPad uh it's face ID and so it's very normal user they're not doing something extra um they're not uh going through like a wallet flow they're doing what is like the native off on that device and the other big part that is super helpful is the cross device availability so that is becoming more and more popular you saw with um Apple keychain and Chrome profile those are very cross device by default um but also if you want to use um a phone tablet or security key um those make it so there's actual like QR flows that you can make it so like this laptop and this phone has it without trusting any third party so that's that's my favorite part of pass Keys is they have a true non-custodial version um okay so the main reason uh we

put smart wallet so smart wallet is in the V4 SDK of coinbase wallet so coinbase wallet is already in thousands of daps and it just takes an upgrade to V4 and you now have Smart wallet as an option so we're really happy with that distribution uh we already did Integrations with things like wagm rainbow kit VM um to make it very easy to where you just add a experimental module into it and you're now smart wallet complexity wise when you are doing transactions with smart wallet you as a Dap developer don't actually have to change from transactions to user Ops we do that for you um if you want to go down to the protocol level and do that you can I can show that at the end if if people want to see it um there's a couple eips that we've been working with

the community on that make that more of a standard um the other thing I totally didn't mention is coinbase wallet is cross chain so I think it's on eight chains today um so it's not just base it's on base mayet polygon arbitrum um BNB a couple others uh and I talked about magic spend um so I think you guys can uh kind of have some imagination of how useful that is it's starting with coinbase balances but like the real goal of it is to actually use like your traditional web2 payment methods like a credit card debit card bank account um those already exist inside a coinbase so it would just be part of the flow that you're using your existing coinbase methods and you can do stuff directly on chain um but starting with just eth uh on your coinbase account as our starting

point um okay so actually to get started with this um I have a few different quick starts we can run through um most importantly if you have uh any existing um like projects out there and you have coinbase wallet in it all you have to do is upgrade to V4 um I would recommend 04 just because there was some fixes we did uh and truly that's all you have to do to have coinbase Smart wallet as an option um if you're building net new um pretty sure most of the like quick starts that we have out there already start with smart wallet by default um but if not all you need to do is upgrade to 4.04 uh and it should work uh and it's very much so Standalone um I know you guys saw scaffold eth 2 earlier

there's a scaffold based version that also has smart wallet in it by default so this this quick start is much more complicated it's called build onchain apps. XYZ and it has a few different experiences here if you're trying to do new new projects but it's just a a coin base um version uh that helps you walk through various quick starts so in this one it's specifically talking about uh coinbase clouds or coinbase developer platforms pay master and how easy it is to log in and create that um set up your policy uh which is saying like either a frequency of how many transactions you want to do or an amount or a certain contract on a certain method um so just giving some like permission of you can only do these certain actions with my

pay master um this walks through kind of like a hey should we sponsor this transaction uh and we don't need to worry about the proxy so that's on chain apps that's definitely more complicated if you're intermediate to advance this is a good starting point um just because it'll focus on the infrastructure a little more um if you are new to doing front-end or um count abstraction in general I would recommend this wag me smart contract wallet for mson um essentially all it does is set up the whole um coinbase wallet button which directly sets up that smart account only um and then it has a a mint nft um so very much so like the demo I gave is

just a very paired down version Oh and then uh special I mentioned I like scaffold e 2 a lot that's very easy if you're trying to get started um and then the only difference is instead of using that embedded um burner wallet that they use by default you can switch it to the coinbase smart wallet and that'll give you the the same experience as that mint demo site um okay so this a little more advanced um so some of the things that we're trying to do for uh smart wallet is not just make it so that we're making a smart contract wallet on an island um we want others to uh start to standardize some of these things um so it started with our get capabilities here which is when that wallet starts um a list of

capabilities that can support um so the concept of atomic batch which is multi call the pay Master service and auxiliary funds which is that magic spend um we want other people to do this like we want um other exchanges we want metamask we want other wallet providers to support these um so this is our EIP that we've been working on um wallet connect and a couple other big um providers have also been uh working with us on it so just know that like we didn't make um smart wallet just so that it's a standalone vendor locked product um it's very much meant that we are making these e eips and hopefully it becomes an ERC shortly once we Hammer a couple things out uh and then lastly like the next thing that is coming to coinbase Smart wallet is session keys so

this is the concept of when I go to a website I can assign a session key specifically to that website um and it could stay in client side or it could stay server side um and it'll have a list of permissions here so it'll have a signer and that signer could be an eoa multisig Pass key so an EA could be on server side um it could be a multisig so it could be like you and your three friends are all part of this multisig or it could just be another Local Pass Key that just limits the permission of what I can do um so if you're playing a game or something and you want to set a spend limit then like you can you can make that a local Pass Key and limit yourself so some of the permissions that are currently in the spec

um essentially transfers of either the native currency rc20 721 1155 tokens so like if I'm an nft Marketplace and I want to create a session I can make it so I could just transfer nfts back and forth um and then likewise there's a gas a call which is like a frequency um a rate um in a spend limit so maybe it's a max amount of a token or a max amount of eth uh and then lastly expiry so how long does a session key last for is it a week is it a day is it an hour um is it a month and with session keys I think it it unlocks a couple things and that you can say hey I have my smart wallet I want this thirdparty app to buy an nft for me once a day um and I can set up a

permission policy to do that and I now trust that that bot can um perform that action for me and then lastly if if you grant something you have to revoke it um okay so that's what I wanted to get through about smart wallets um lastly is just what what the base updates were so base actually had a hard Fork yesterday so what this did is it um it finally released um rip 7212 which is what makes a pre-compile for Pas keys go into the train itself so before it was like a smart contract had to do that um verification of a pasy signature and now it's put down into like the node level um and what this did is that the overhead of gas went from it went down like 65 to 75% depending on the

transaction um so it made it so the whole like why would I use Smart contract while it's from a gas overhead cost is kind of less of an argument now um and then there's a a compression so like we we further improved how we're using L1 call data um it's actually closer to like 10 to 20% in main net um which I was surprised by but gas fees are now very very commonly below one penny um even for complicated things um and then the last was a um we switched our compression algorithm to use fast LZ um which makes the L1 data fee estimate um quicker and more accurate um so that you're not paying a higher priority fee than you need to um lastly this is not necessarily tied to vord but it's something that we've been doing on a per Monon basis is

we're increasing our gas Target per block which means how many transactions or how much gas can be spent on each block on the L2 um so we're I don't think this went live today it should go live tomorrow but we upped it from 7 .5 to 8.75 uh we plan within like a year to get that up to one giga gas um so coinbase is like two-year mission is to make it so globally anybody could transact under one second under one cent um and this actually almost gets us there from the base level um or from the base blockchain perspective um then it's to help other blockchains get there too um and yeah that's all I really wanted to cover um so I know that was a lot I'm sure if anybody has questions we can talk afterwards

uh and yeah thank you for your time thank [Music]