ETH Penang: EIP-4337 Account Abstraction
Ethereum Malaysia·Mon, Oct 9, 2023, 12:00 AM
In this talk, Jing Xuan goes over "Account Abstraction" which is used to abstract away the complexity of smart contract interactions with the Ethereum network.
Transcript
hello it's not easy working you know okay okay I'll repeat again yeah so um good evening everybody my name is zing Shan and today I'm here to share about erc4337 um account instructions so um right now I'm working as a full stack web tree developer um building a protocol between algorithm and evm blockchains and today I'm going to share about erc4337 which is also known as account abstraction right so [Music] um erc4337 I think I'm going to announce is like um a few I it's already been in a space like for years but um this uh EIP and right now it's an ERC right is um like just officially uh Deploy on I think like months or last month so it's like a few months in and when this ERC came out there's quite a lot of hype about um this thing and you can see like all over the Twitter for the photos kind of like deaf um ethereum related kind of Twitter account you'll see they um tweeting about erc4337 and one of the reason is because this re this ERC is being um like you'll see this kind of slogan In Articles when it's like um describing about the erc4337 it's being um um like promoted or like being say as the proposal that could onboard the next billion uh of users to ethereum um blockchain is a very good technology um but I think like the next step for the blockchain is definitely to uh it's about adoption right so everybody is saying okay blockchain is very nice but um the odd like when when we speak about this kind of conversations adoptions is always something that will um that we'll discuss about and one of the reasons that um adoption um is not going in that like it can be better in my opinion um but because of the accounts accounts part of ethereum when you first want to interact with a decentralized applications or you want to create an account interior there are actually quite some problems that um people might face and for myself as an example I face quite some problems when I'm creating a account and I would like to share with you guys within during the next slide right so okay the next slide is empty slide um so this kind of reminds me that I want to ask um questions to you guys as well so what are the problems that you guys face when you firstly created a account to join the ethereum blockchain or to interact with some devs right anybody um have any problems that they face and they would like to share anybody um yeah Yep this one anymore else like truth like yeah like it's not that familiar right and any anymore okay yep so um there's a few I would like to discuss here so like the first one is like what um this gentleman say just now like create if account and handling the private key so uh for myself right when I firstly create um a if account uh in metamask okay I was like I was always using um email and password and then when I firstly want to create the if account I was like okay um creating account um should be simple uh should not needed like no tutorial is needed I just download metamask follow the step should be pretty user friendly and yeah it is user friendly but there are something still kind of confused me right so the first thing is that when I um create the account I've seen a password right yeah I thought okay that's the password for the account but actually that's the password for the metamask extension in your browser and after you pass that phrase right and then it kind of gives you a seed phrase right and the seed phrase is like draft seed phrase and when I see about this I was like okay okay there's a password okay and this might like this looks like the real password and after that um when I discovered about this then I was like kind of like okay if I this matama's account Works kind of different with our typical web 2 accounts why one of the reasons that kind of like um concerned me a lot is because uh I kind of like changed my password quite frequently um when using um apps or web 2 apps and I kind of like what if there's one day I forgot my password uh it's okay I have a recovery uh email I have my um Gmail and then or I like I kyc right so I can go with the customer service to get my account back in some ways but in in ethereum or in a blockchain most account doesn't work this way you create an account and you are being assigned a private key for a draft uh words seed phrase or bammonic phrase right but those phrase are only generated once and you need to and it's pretty hard for you to remember the private key or it's a bunch of strings but uh Sif phrase might be a lazy a little bit easier but still pretty hard okay so uh that's kind of concerned me because what if someday I write this in a paper and I lost it and the funds inside the if account might be stuck in there forever and what if uh what if my private key is like to somebody right and that also I have no if they get the private key they have all my funds so that's like there's no some it's it's not like the web 2 kind of thing where you still have a third party a centralized party who can help you right they could help you in some ways but yeah this is one of the benefits of having something like centralized controlling but uh yeah this is also one of the disadvantages of being decentralized yeah so uh this is kind of a really big concern to a lot of people who are using a web 2 kind of account and the next one is gas fees okay I remember this so when I want to uh do like when I want to create an account and that's like I want to do it because I want to stick some tokens and um firstly I thought like uh this token uh this token I could uh I could trade somewhere okay yep it can be trade somewhere but if you want to go to a centralized exchange to do all those things then you would go through another round of trading accounts but this time is easier you you use the email you use a password just that you need to do more security like um like a Google authenticator things like that okay after it's done right then you need to learn how to do P2P transactions to buy your coins not I I believe like most people don't like have every like have um people around you are actually doing like selling Bitcoins for fire most of us during uh we get our coins through P2P transaction in a centralized exchange right now and you need to learn how to do P2P because it may sounds um like you need to trust the centralized exchange as your escrow and before before you buy a token you actually need to transfer your money like it like a bank transaction using your bank login to your bank account and then send the funds to the person who are selling you the uh the tokens and you kind of want you so you kind of before you get your tokens you already need to spend you already like take like some money out of your bank and you are not really sure like will it come back if you're a first-timer right and then you need to go to a P2P and you need to learn like um the safe way of doing a P2 position session okay and that's not even you find your ethereum account yet okay after you buy the P2P then you need to swap and you I mean you need to like exchange to if maybe like if you are using the ethereum then you need to change to the native token which is ethereum if okay okay now you already swapped to if but you have another problem and like for me as a new like when I'm a newcomer to space when I want to withdraw the month I will start thinking how can I withdraw uh the token to my if account and then I need to learn uh to click the withdrawal button in the centralized exchange and then there are like a lot of words which um I like it's my first time seeing singam right so it's like erc20 bep20 BB2 and there's like Solana there's a trc20 so there's like a lot of blockchains right and then uh I'm really not sure which one is the correct one and then yeah and then if you select the wrong one the funds is sent to the wrong blockchain and then you need to you need to buy your fire through P2P again to swap into the correct native token send it through the correct blockchain to the correct address so this is really like quite um some Hassle and if you if you buy the wrong token uh initially when like I I thought I could use a usdt right so I I buy some usdt because usct the withdrawal fees is lower and then at that moment I remember uh because it's because I uh that moment I thought trc20 could work somehow but after I Bridge it I sent to my ethereum tokens and then um yeah it's a different blockchain and I want to try to bridge it to the erc20 and I wanted to try to bridge it and I found okay I need if right now I need if as gas fee and then I need to go to this centralized exchange to buy if again and then send it to my ethereum account right so things like this could happen so it's like really um quite some hassle gas free and fun accounts and there might be even some scenarios that you need different accounts for different multi-purpose right so for example um somebody like somebody would prefer they have an account for just receiving funds and selling funds without doing any approval any contract interactions and if they want to do some contract interactions they will have another account and the account is like they just put some of the funds and but to do uh some basic contract interaction but that kind of requires you to have multiple Waters and you need to manage them um yeah it could be a lot uh it depends but um for some people this is also um some problem that they might need to face and they need to like remember quite a few um phrases so um yeah so for bird eye view for all of those um things that I mentioned just now you like it's almost inside this diagram you need to create account you need to con you need to handle the private key and you need to purchase the funds and you need to pay the gas fees and initiate the uh you need to transfer funds initiate the transaction and pay gas fees right and I need to wait for transactions and you need to wait the transaction to confirm and before you continue right so all of this is um yeah it's quite some hassle for some new person uh what if there's somebody who which is not tax saving um so it's actually quite some entry barrier uh for them to join this ecosystem right so and then people found this like problems like this can be solved using um account extractions um which propose the user to use Smart contract wallets instead of EOS so there's two words here this contract wallets and EOS okay so what is Smart contract Wireless and eoa so I believe like smart contract wallet is pretty easy to understand just a wallet um based on a smart contract and eoa is actually um the account that we always use um like the account that you created with your metamask right this is the ear goals okay okay it's louder um this is the eoa account and it's actually the account that control um with the private key and that's a eoa account and there's contract accounts so it's actually um this kind of accounts is actually a smart contract wallet it's deployed on the network and is controlled by the code so um some of you might realize if you like if you try to look at either scan or you try to check some um spark contract address right you will realize that actually when we deploy a smart contract the smart contract can actually receive funds we can actually send funds to the smart contract just like how we send funds to other accounts you just go to your metamask type in the account address and then you just send and you can send the funds to the smart contract account but this also depends that if is it that your smart contract account is already um ready to receive these funds if the smart contract account doesn't have any functions written to withdraw the funds then the funds sent to the Smart Control account will be um yeah we'll be stuck for that because we will be stuck um with the smart contract account yeah so um this is one of the reason why we need a standard for this kind of smart contract written so like erc20 like ERC 71 actually all of this are just smart contract codes but because um they need to use a standard so that everybody use this use these functions like this functions is written with the same parameters is written with the same contract names and this would be easier for dapps to interact with them and yeah and then account instructions we have this erc4337 which is uh we just launched like months ago and here are some examples why smart contract wallet could be a better uh could be a better wallet than a typical eoa wallet so um firstly permission controls okay for eoa if you have the private key you can do everything yeah I mean you can do anything right and then but if contracts accounts um some of them like this is kind of like a multi-sick water kind of idea so you have a list of accounts right and in order to approve a transaction for that transaction to to be executed you will you can specify like you need like three out of five signers for that um transaction to be approved and this kind of puts some security um for that wallet and this is like uh what we like it's like the multi-sig wallet and you also can do batch transactions right with contract accounts so for example if you want to like do something with a token your erc20 token you want to do something with your token or maybe you want to stick into a pool you really you will realize before that you really stick into the pool you kind of need to sign two transactions the first one is that you need to sign approval transaction to approve this amount of token to be delegated to uh some spender and then that spanner can only spend that amount of tokens that you approve okay after this transaction then you would and then this next step is like to sign the real transaction the real sticking transaction right okay so but with contract accounts um this kind of transactions can be bundled together as a batch you can like you can just instead of sign in two accounts to do that interaction it can be um programmed to um only to only like with just one confirmation on your wallet just one approval and then you do the approving of a token and you also transfer the token okay and the other one uh is like account recovery so remember that I say like um if the private key is lost and then your eoa uh you if you don't like you don't store your private key properly if the property is lost somewhere then yep the funds may be stuck on the account but with contracts we can do something called like account recovery so this is something like when you create an account you can specify like um I have a few address okay this kind this address is my guardian this address is my like when I lost my private key it's okay because this account as long um I have access to this Guardian this Guardian could actually change the ownership of the contract back to me so um yeah so losing your private keys or your seat freeze might not seems like that that much of a big deal in this situation and um because it's smart contract wasn't right so you can do everything as long as programmable you can also like set transaction limits uh like um within the day you can only spend like how many if you can spend like 0.5 if that kind of like um protects your smart contract accounts as well yeah so um with all of the like introduction um for the past like 10 10 minutes I'll I'm going to like gather all of this and then to show you guys like two examples so this example is about a web true game a web tree game implementing 4337 and the like account instructions and another web free game which is not implementing 337 right and okay let's look at um what if this Vector gain doesn't use a 4237 account instruction Pro um standard to uh it needs you to use an eoa to play the game so firstly you will need to go through the creating if account procedure right so you need to like create handle your private key find the account things like that okay so this is the first thing you need to do and after that you need to fund account right and when you're playing a game then actually one makes a game a web 3 game is that all of those transactions is on the blockchain so let's say um you when you do some transactions right you may need to do a multiple transaction in a day or maybe in an hour in 10 minutes account you need to like confirm the transaction every time and okay and this is kind of like it's this is kind of some problem because you don't you it's like confirm a transaction every time it's okay but you also need to take care of your guest fee right so if you want to play a game you need some money um to fund the account and that is like the money that is ready to burn as the gas fee and that's that will also stop like because most of the people who like play games are like maybe high school or like they don't really like comfortable to spend some real money um to play a game I mean before this like I mean in the starting phase when they just like trying out the game right but yep before like yeah you would need um some funds in your account in this scenario um like when you're just starting out playing a game and yep you will need multiple waters for a different purpose and then yeah you are unable to access assets if the private key is lost so what if right now we have account instruction and this web 3 game is being um implemented uh with the standard of erc4337 okay instead of creating account before the game like uh the game can do something like you just log in you just log in like maybe using email or password okay on the the example that I'm mentioning here is like just a very general example um it's a smart contract wallet everything is programmable and I'm just giving an example here right so when you first log in uh a smart contract account is being created and it's created when you it's created it's not you the one who created it's the game created for you because um it's a smart contract every time when somebody like log into your game and then it will just deploy a new spark control account to this um to this uh to this um person right and then this data is being saved in some database and then um 4337 actually enables us to have a paymaster okay so gas fee handled by paymaster as long as paymaster is paying um specified in the in the Smart Control account um user operations guest fee will be handled by the paymaster so it's a web free game everybody um could play the game and then it's kind of like a web 2 experience which you don't need to fund the account to pay the gas fees and because it's programmable a session key function could also be implemented to approve the transaction like map automatically within a time frame and like also like maybe a batch transactions things like that which um I mentioned in the previous slides and enable multiple wallet functions like transaction limits it could um because like it's your wallet it's the wallet designed by the game right so the game could actually program some customized functions to it like transaction Limits schedule payments things like that and then yep and then you it was it could also implement the social recovery function um to help somebody who lost their private key to have another recovery person to help them to recover their Assets in the game okay so um here's the bird eye view of how it actually works for erc437 so firstly um there's you'll notice like something new instead of just use like instead of you just like um send some transactions to the mempool it actually goes through a user operation mempool this time so um every transaction um using like 437's uh accounts is that you need to have for you if there's something new which is also known as like user operations and user operations is actually similar with um our like okay so metamask kind of abstract like like hide all of those sending um sending transaction stuff for you and it's actually if you go deep into it then you'll found that it's actually kind of similar when you sign a track session the field that is needed to send addressing you right now is actually kind of similar with the user operations you need the sender you need a nonce and then the init code um some core data and also pay Master there's a paymaster there which is to pay your gas fees um and then also a signature a signature which sign um by the account that um like the owner of this spot um this smart contract awarded so when we go back to it so every just imagine like every every um transaction right now is being submitted in this kind of form user operations so the user operations will be sent to the user operation mempool first and then there's a bundle bundler will kind of like bundle all of those user operations and then into a batch transactions and then um send to the ethereum blockchain and then here's another more detailed kind of feel so an eoa an eoa signs um okay signature is something can be stored right so eoa let's say I the game kind of store the person um signature and the signature is only like it's programmable and then I mean the program to store some kind of signature and then the signature is being attached with the user operations so the user operations could be sent to the mempool and then go through the bundle and then there's like that and then there's this entry point contract entry point contract is something which is only uh there's only like one entry point contract in the whole blockchain like verified the only one verified and this being um the boundary will call this entry point contract and then after they call this entry point contract the entry per contract will will go and will go to your smart contract wallet which implemented the 4037 4337 standard you can it will send the user operations to the um entry point contract and then it will kind of like poke poke the smart contract okay is this user operations um is it like valid okay if it's valid then we'll go through that do we have enough of gas and then um do you have a paymaster and then if there's a pay Master the gas will be um will be um handled by the pay master and then if it's not then it will get the gassy from the user uh and then validate user operations um and then it's all valid then only the transaction will be executed yep so after all of this kind of like technical introduction so in the end what's What's um erc4337 meant for the Deaf it may be in future there will be uh more for sure more like new wallets provider with the 4337 um standard and your application may need to adopt with this and prepare the integration with this kind of wallet providers and the Second Step um you may need to um if you want to like some extra functions um you will also need to um study this standard and then integrate your decentralized applications with this kind of Standards such as like recurring payments and what what what the crc457 mean for the users that means like in the near future or in the future there will be wallet providers like new world providers um support for 337 so it's it's they will hide everything from you making is very user friendly just like metamask but um the you the the flow to use it may be kind of different and like a new metamask right um if it goes very viral then you might need to learn the how to use a new water but mostly will be the same and I believe it will be really uh user friendly and then a more familiar kind of user experience when interacting with the depths still remember the example that I um like the comparison example just now um it will handle everything for you and then you can even do like 2fa and then a recovery so it's a more familiar like a web tool kind of experience for accounts in ethereum okay so um yeah so uh yeah I okay take a photo yep so um here is some example which is already accessed in um in like this few months uh most of them are from the ethereum um hackathon so the first one is so wallet they actually just raised like three million of funds for this and this started with the hackathon here and then um firstly they started like recovering a kind of account and then I think right now there's more functions implemented and there's rhinestone and rhinestone is kind of like modularized um the wallet is something like you there's a wallet and then if you want a transaction limit then you can integrate transaction limit and then at some point you can um uh just this is being done by the diamond proxy so it's like you can upgrade your wallet with some features and you can download with some features right so um it is quite um interesting and there's also a noses right novices okay nervousness um not sure if I'm mentioning correctly but like novices is actually a project in um in scale ethereum um hackathon this year and then it's actually um it's kind of like also um like you can select some of the features but it's more about security uh customize your own preferable security uh for your wallet and then there's banana small wallet which did um the Z which they use um zero knowledge proof to uh with 437 um I kind of forget like how's their demo but you guys could check it um if I'm not wrong it's like um it's like they used like 2fa and the 2fa is being done through TK proof and then there's like some 2m 2fa functions um with the wallet yep I might be wrong but uh it's but I'm just kind of remembering is something about Journal unleash proof and then I yeah should be with something with 2fa yep and then of course um the if Infinity account extraction repo so which is um this is like the official um repo for um account instructions um from if infinitism and yeah there's a lot of uh if you are deaf and you want to learn like how it basically works you can check how their contracts is written and how they run their tests to have a few of how yeah this is being done in um construction yeah um yeah and then that's um so far that's my that's my um introduction about ERC 437
Automatic transcript — names and jargon may be misspelled.