ERC-4337 Create Account - who pays for gas? / Tom Teman
EthPrague 2023 · June 2023 · 18:21
Tom Teman examines account creation under ERC-4337, the account abstraction standard, and the question of who pays the gas to deploy a new smart contract account. Until ERC-4337 is enshrined on every network, creating accounts stays relatively costly, so whichever dapp onboards a user first is left paying fees that also benefit every other app. The ETHPrague 2023 talk looks at this onboarding dilemma for smart wallets.
Speakers
Topics
From EthPrague 2023, hosted by ETHPrague.
Transcript
yeah okay so hi everyone uh welcome to my presentation without a present without a deck so my name is Tom tiemann uh so a little bit about myself I founded Portis back in 2018 which was acquired by shapeshift in 2020 and I joined the foundation in the beginning of this year to work about around account abstraction to act as a product manager um so when we're talking about construction we generally want to get around the problem of eoas and as we all know eoa is externally owned accounts are
challenging to say the least um so some of the challenges and I'll go over them briefly because this isn't a talk about account abstraction in general I'm going to go briefly over that for people who are not that you know familiar with it but there's something more interesting which I want to get into and we're also a little bit short for time so hopefully we'll get there quickly so EOS are mostly a problem because of the fact the big problem is that it's one key you know you have this one key the to rule them all you lose your one key you lose your funds you make too many copies someone can get a hold of them you lose your funds and so there's it's really problematic in terms of ux but a bigger challenge I think in the world of ethereum is the fact that there's no key
rotation for instance with Bitcoin if you fill your keys compromise you can just easily say okay I'm just moving all my assets to a different wallet that's it with ethereum it's not just your key that you own it's also your address your public key which is known in different contracts so if you want to rotate your key there's no easy way of doing that and sometimes it's not it's not even possible some contracts may say oh look there's a time delay for a year if you want to change your wallet or whatever so it's a big problem and Recovery is also a big issue we notice that a lot importers because we were a self-custody wallet if someone lost their password didn't write down their seed phrase we would be in a situation we would be like well we're sorry there's not much we can do
about that um in addition there's no granular control right if we're talking about just one single key it means it's one single key that does everything and you know in the world of web 2 when you're using like bank account stuff like that you have a lot of safeguards in place which we don't have with just one single key and so no multi-stick no spending policies no nothing this one key does everything no granular control um also in terms of gas payment well you know when you want to use when you want to sign a transaction then you got to have some if in your wallet that's a huge challenge both from an onboarding perspective but also from a privacy
perspective if I want to just claim an nft with a wallet with a brand new one I need to have some ethernet wallet which means that if had to originate from somewhere which might be kyc'd so I'm losing that privacy with pay masters we can have the gas being paid by third party so I can just create a new wallet someone else pays for gas that's while it remains pristine in the sense that it's never nobody knows where it came from right we can have the Privacy that we want and also for daps EOS are a challenge because there's no flexibility like there's no batching there's no um you know stuff like automation if you want to have a recurring payment so I wanna I want my wallet to listen to an event a trade that happens and automatically do something there are
ways to accomplish that but they require usually some sort of centralization or trust which we don't like that much we were trying to avoid stuff like that so with account abstraction we're we're basically abstracting three things the validation of your transactions which I would break down into two which is the author authentication and authorization authentication is is this key valid and what we're changing here doesn't have to be just an AC SDA key it can be any key we want and we're seeing wallets doing using either their secure Enclave which is a great option or which basically turns every smartphone into a hardware wallet or sign in with Google if you
want that's fine for whatever that key can do which is the second part which is the authorization what can it um yes the authorization which says what is this key allowed to do so thanks to account abstraction we can have this much better control over permissions something we're used to from web 2 right ACLS stuff like that we we we're getting the same Concepts which we need to have there's good reason why they came about uh execution which I mentioned the automation the batching of transaction that is also something that we are allowing to abstract even nonsense this is something that we're semi-abstracting which allows you greater flexibility when you're talking about you know signing transactions at the same time
from multiple entities Etc oh wait we got slides okay great so um this is where I am right now and finally I think I mentioned Gas payment so allowing third parties to pay for gas fees either fully subsidize it or they accept usdc and they pay the eth this has been a very big challenge for dapps and wallets in general and having something which is part of the protocol something that is standardized really really helps user adoption which brings us to erc4337 so I mentioned what we get out of the full
account abstraction I won't go over that again the censorship resistance is very important so a lot of account abstraction proposals or not proposal but solutions that are out there right now they have some sort of centralization element to them mostly around relaying the transaction because ethereum is still ethereum you still need an eoa wallet to sign a transaction because that's how the protocol works so there is some sort of centralization because you don't have the equivalent of bundlers and everything that erc4337 has speaking of bundlers we're also very adamant about this being a robust infrastructure just like how you have a lot of ethereum clients we also want to have a lot of bundler clients which keep in mind they're very similar okay
bunders are block builders in a sense or are working with block Builders they are not submitting the big use the big transaction that Phil that is sorry that is full of user Ops to the mempo they are submitting it as the next block otherwise there's all kind of front running and problems like that so we want to make sure this is very robust and there's a lot of implementations and currently we have typescript go rust I'm missing a few but a lot okay and this is part of the great thing about erc4337 there is no protocol change okay and I see we have not a lot of time left so I I'm not gonna dwell on this too much but you can check out the new website we have and you can have a lot
of resources there and a lot of information okay so we're getting to the interesting part of the conversation of the talk which is beyond the kind of section let's say we've made it okay let's say that everybody uses erc4337 and you know killer dapps are here and we're going for one billion users you know okay we've done it we have some killer adapts out there okay and there they want to get to mainstream adoption the image is upside down that's kind of funny okay so a spoiler the this information will not really matter once we move Beyond ERC 4337 into an EAP meaning this is actually enshrined in a protocol but we don't expect this to happen for at least
a couple of years and this system we we can't just wait for that to happen if we wanna you know get to mainstream adoption soon we have to account for things which I'm going to talk about in this conversation so a part of creating an account with account abstraction with erc4337 is deploying a smart contract and deploying smart contracts is quite expensive and when we calculate how much that can end up costing on each Network and these are rough estimates okay don't you know and also the prices changed in the last two days so you know things are different but these are roughly the prices per Network okay some of them the calculation is a bit different if we're
talking about networks like optimism and arbitrum it's not exactly the calculation I showed beforehand but these are the roughly the costs now this raises a question like who pays for that right like first of all there's a problem with the fact that it costs as much as it does in the sense that just imagining on web 2 just creating a user account costs you like 50 Cent per user just creating the user just like putting that DB entry in your you know centralized server would be that expensive but there's a bigger problem here okay because you're not just paying a lot relatively a lot right you're also sponsoring the next dap that comes along assuming that the DAP pays that through
a paymaster which is a very reasonable thing to assume because right now wallets like let's say for example Argent are paying for deploying the contract but that's because they're aiming at you know Traders people who are not exactly the average person if we're talking about someone just onboarding to your application and fulfilling that you know hopeful dream that they don't even know it's blockchain right it has to be transparent to them it's not like a Trader wallet so the application will pick up the tab but then then the user goes to the next application and well that's great they get they get that bonus for free right and you know from a product perspective from a business perspective that is something we have to resolve for
the applications because they they will have an issue with that like saying like why do I pay for the next guy right there are some caveats here first of all you don't have to create the wallet right away you can do we can using Create two you can have the address of the contract in advance so if you want to just receive funds or whatever before that and have just an address without paying the deployment cost we can have that but until EAP 649 to or any other solution is implemented that allows signatures for you know pre-deployed contracts to be created and adopted by the networks there are some solutions there and there you are from from our team came up with a lot of great ideas
around that it you know signing messages is something that is essential in the in the onboarding process and until we have that we still have to think about okay how do we solve the cost of deploying a contract because until you deploy the contract there's not much you can do so one one approach is ioused I mentioned origin okay so we're just like okay we'll deploy the contract and once you start actually spending your hard-earned cash on buying stuff then you know you owe us a little bit pay us back the problem there the challenge is that there's risk because who's to say that user will end up buying anything so you paid you put up the money first but then
it doesn't end up paying you and if we're talking mainstream adoption you know millions of users percentage-wise that becomes a game of numbers which can be very difficult um another approach is ADS right we can have the user see ads we all don't like ads that much but you know it works then we we can have this kind of like triangular approach where the um users these ads and the pay masters gets compensated from the Ad Agency and they pay for the cost so the DAP isn't even a part of that right it's like all between the wallet and the paymaster and it's like super simple for the DAP but there is a cost here as well when you think about it which is the brand right
because the um seeing ads isn't fun so I'm going on application one I'm seeing a lot of ads to create my account then when I'm going on application too I see nothing so the first application also paid something for the next application in a sense which is diluting its brand right the second application has a great experience so that's also not so great in just ignoring that fact that the first application pays for everything again the images flip outside of it it's even better this way I think that a few remains okay there's the word in Hebrew okay which means which is flyer means to be a sucker but it's a big part of our culture that nobody wants to be
the sucker and in this case the first application is the sucker it's paying somehow either directly with its brand or by assuming risks so what can we do about it so one approach which I think is a nice way to think about it is amortization which is something from Finance it's not exactly lack of organization but it kind of gets the idea across which is where everybody pitches in as as more dapps join in okay so the rules the basic rules and this is just this is not something you know this is just like a beginning of a conversation here okay so accounts when you create a new account is a user through adapt first you're
limited to only using that app okay you can only interact with its contract because it paid for it you can still do basic stuff like send money to your friends or receive funds whatever but you can't interact with other contracts you can always buy your freedom pay back the debt what it what it paid and you get back full control of your account and as more dapps join they get they also are able to inter allow the user to interact with their contract at some point you open up the contract completely because from a gas payment that's like doing all that calculations just doesn't make sense anymore this is a pretty straightforward approach assuming like G is the con the gas cost of the initial deployment this
is how much dap number I will pay okay the first app pays G the next one will pay half sorry sorry half the gas cost to the first app and moving forward you can also see how much it will pay for each individual dab now this is a little hard to understand like this so I created a nice little animation which I hope will work after all the shenanigans so it will look like this but let's see great okay it seems like it's working so the first app pays for the ease of understanding let's assume the gas cost is one one of whatever doesn't really matter so the first one pays one then the second one pays half to DAP one so now that one in essence paid half the second
one paid half they're like equal Partners in how much they paid um the third app will pay a third divided between each one so it's 1 6 and 1 6. you do the math you see everybody pay the third and we're all equal Partners in how much we paid moving forward you get the point it's one fourth one twelfth to each one and slowly over time everybody's pitching in in the same way and yeah and once 10 dapps if paid if pitched in like the user already logged into 10 different apps and they all pitched in you'll see that the original deployer only paid 10 of the original cost making this a lot easier for them to swallow also from a business
perspective they know all the other dapps pay 10 so they can feel a lot better about it from a game theory perspective they don't feel like they came out as a fryer okay it it then starts to taper off right then it takes another 10 dabs to only get you know five more percent so it doesn't really make sense also from the calculation and how exactly is this implemented in terms of the contract itself there's a lot of cool ways to do it it wouldn't make sense to calculate and pay every time obviously there will be each dab can kind of put up a lot of money you can just keep track of how many dabs have participated and whenever adapt wants to cash out it can but most of the time things can even out because
it pays to onboard they use a new user but it also got paid from a previous step so probably doesn't make sense to constantly pay each other obviously from a gas perspective can we do more well obviously but like just some food for thought when you walk out of here so maybe we want to ask new daps to also account for the interest of how much like they paid one month ago if they put that money into some sort of staking mechanism they would have earned interest on it so maybe the next step also has to pay for that interest to make it completely Fair and maybe we can have a more sophisticated we we definitely can have a more sophisticated amortization
mechanism something less linear maybe a bit more accounting for all kinds of edge cases Etc and what we're starting to see in the ecosystem is wallets that are very modular and the mod like you have this basic smart account and you have models that can models can plug into so maybe this is a way to also compensate those models and another way of managing the balance that I talked about is maybe through pay masters which can reduce a lot of the gas costs because it happens off chain but can be done in a way which still maintains you know security and not a problem of trust I have 10 seconds so I'll just wrap up with this web 3 makes us rethink how we approach things that in web 2 seems like completely you know
basic problems uh check out our you know our website or you know follow us on Twitter and you know let's go for those 1 billion users thank you very much wonderful thank you Tom give me a round of applause what a fantastic talk mate um I'm afraid we like don't have time for questions unfortunately um but you can put them online if you can go back to and put them online next up we have Leonardo's talking about data availability um we'll be back in a second [Music] foreign