New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Paymasters 101: Disrupting transaction fees by Antonio Ufano Gallego

Ethereum DenverMon, Oct 9, 2023, 12:00 AM

Ethereum user experience is still far from optimal, and nowhere close to competing with many Web2 payment UX experiences for instance. Account abstraction and paymasters are some of the biggest UX upgrades to hit Web3, and they’re natively supported by zkSync 2.0. In this workshop, we will cover: - AA overview - How accounts work in ETH now - Problems AA solves - Paymasters - What they are - Paymasters in zkSync - Hands on: - Testnet paymaster - How to build your own paymaster: different flows - A paymaster powering for ETH Denver Antonio Ufano Gallego Developer Relations Engineer zkSync Antonio is a full-stack developer and an indie maker. After 15 years working in the banking industry, he decided to quit his job to build his own projects like thelifeboard.app and soliditytips.com. He is a Developer Relations Engineer at Matter Labs, the creators behind zkSync. https://twitter.com/uf4no

Transcript

this is big enough I guess can you see it great so thank you everyone for coming we're going to talk about uh pay masters and account extraction in general and how they can disrupt transaction fees oh man images are not working that was my profile picture but you can see me so yeah a bit a bit about myself my name is Antonio I'm a developer relations engineer at matalabs and I have around 15 years of experience as a software engineer and two years ago I started getting into blockchain learning solidity I started this blog called soliditytips.com there it goes where if you are learning solidity you can find some tips uh for you and ufano it's my Twitter profile so if you want to follow me you just have to go there the this is the agenda for the next 30 minutes or so we're gonna talk about what is CK sync just a quick overview and then we're gonna talk about how accounts work on ethereum and the problems that we have right now ux problems after that we're going to talk about about account abstraction because it's supposed to solve most of those ux problems and finally we're going to talk about how we have implemented account abstraction on cksync and how to create paymasters which are the coolest thing about eip4337 to be honest so uh let me adjust this a little okay matalabs our mission is to accelerate the mass adoption of public blockchains and obviously ethereum is the most popular blockchain so we've been doing it with cksync we created a c casing version one more than two years ago which was a roll up that used zero knowledge technology to and to make payments and transfers it was like a proof of concept for zero knowledge technology and it's been used by projects like Bitcoin if you have used Bitcoin before and you have get Bounty for example you can claim that Bounty using CK sync and your fee the fees will be super super cheap compared with ethereum we have also release CK sync era which is sequencing person two we just rebranded it and it's a general purpose blockchain is a full roll up powered by a CK ebm we're increasing the scalability scalability of ethereum but by moving the execution of the transactions of the layer 1 and to the layer 2. and we are reducing transaction fees as well because we are bundling a lot of transactions together in batches before sending them to their one so basically the cost of doing a single transaction in the L1 is split between all the transactions in the batch that's that's how you get super super cheap transactions as we are sending the information of the transaction Studio One using validity proofs we are inheriting the security of ethereum so if you know about the blockchain trilemma that scalability was was an issue we are basically checking all the boxes and one of the coolest thing is that sequencing era is powered by CK ebm which is ebm compatible so you don't need to learn a new programming language for smart contracts you can use solidity or Piper right now and thanks to a special compiler that that we have in the future you will be able to write smart contracts with rust or C plus and more programming languages apart from that we can say it's ebm plus because apart from the default features of the AVM we also have account extraction pay masters and l102 Communications so we have even more features on top of it and I can't distraction and pay masters they are the hardest topic right now and they are super cool because they promise to improve the user experience in general so before learning how they improve the user experience we need to know the the problems in user experience right now and to understand those problems we need to know we need to talk about the how accounts work on ethereum right now so let's go to it so on ethereum we have two types of accounts we have externally on accounts and smart contact accounts and externally owned account is your metamask or your Ledger or your trust wallet or any other client and they have an address announce and a balance if you don't know what announce is it's just at the counter of the transactions that you have its account is associated with with assigner an assigner is basically a private key and a public key you use your public your private key to sign transactions and the blockchain is able to verify that a transaction was signed uh by the owner of the account based on design on the on the private key and the externally own accounts are the only ones that can initiate transactions on the other hand we have Smart contact accounts and these accounts also have an address and announced a balance but they also have code because when you're deploy a smart contract that smart contract has some code they are not associated with assigner and obviously they cannot initiate transactions so if you send if to a Smart contract the only way to withdraw it is to for that smart contract to have a withdrawal method or a function and to call that method from an externally owned account so smart content accounts they just live there there's no way that they can start any transaction so this generates a few ux problems the first one is that as the account and designers are are so coupled together if you lose your private key you lose your account and if for whatever reason you find a private key you will own the account uh so basically you can you can say that at the end of the day they are basically the same because if you have if you have one you have the the other uh on the other hand we have managing private Keys which is super super difficult even for experienced users uh nowadays if you create a new account the first thing that the wallet asks you to do is to print your zip trace or your private key and store it safely whatever that means people don't know what to do with them and people lose them all the time and again if you lose your private key there is no recovery at all and how many times have you tried to go into Google or your Facebook account or whatever you don't remember the password you have to use the recovery to recover it doesn't exist on blockchain if you lose your account it's gone forever um finally the the logic to sign transactions is hard-coded in DVM and there is no way to change it so yeah that's what it is and with animations this looks better so these problems are the things that account instruction is trying to solve the first one is instead of having accounts linked to assigner basically we're breaking that relationship so no more signer because we will use a Smart content accounts and instead of having a logic to sign transaction hardcoded in the evm uh that logic we will put that in the smart contracts so it's fully programmable so basically the solution to all these problems is to use Smart contract accounts so here are all the problems uh that I mentioned earlier and with externally owned accounts and with smart contact accounts so again there is no more this relationship between the let me make this bigger that's a little better between the there's no more relationship between designer and the account then again the the logic to sign transactions is put in the smart contract is not recorded in the ABM anymore then we have different methods to sign transactions we can use Biometrics or Google authenticators they are super super cool and obviously this is programmable so you can put recovery methods in your smart wallet you can have a backup case you can have social recovery or many different things so most of the problems uh they're solved so again these are some of the features on ux improvements we can have different signature schemes instead of the one hardcoded in the ebm we can have a multi-sync accounts native multi-sake accounts we can have accounts with the spending limits imagine you have one an account that it has a monthly limit for whatever reason or application specific accounts you can have One account to interact with Abe One account to interact with openc and ft Marketplace so all this logic anything any logic you can think of you can put it into into the smart contract account and it will work and also again recovery methods like social recovery backup keys yeah okay there is a problem we all start using smart contract accounts but only externally own accounts can initiate transactions how does this work how are we going to do it and that's what eap4337 is meant to solve so I'm going to explain a little bit what eip437 is because it introduces a lot of new Concepts so let's go through them and there's a lot of info here so first we have the concept of user operations and user operations are intentions of a user to execute a transaction in a blockchain and this will be like the transactions generated for smart contract wallets to simplify things then this smart contact accounts they will send user operations to a dedicated mempool and this is this is key on this so we will have externally on accounts sending transactions to the mempool that we are now on Smart content accounts sending these user operations to a dedicated mempool then we have the concept of bundlers bundles are notes running a specific code and what they do is they monitor the the user operation mempools and they bundle a bunch of them together and they send them to a special smart contract that is called entry point and the entry point contract will verify the user operations and execute them uh and that's again that's a lot of info so this is how it will look like it so on the top we have the current uh transaction flow of ethereum so we have the externally on accounts sending transactions to the mempool and then we have the nodes validators picking those transactions and putting them into blocks The eip4337 Proposal in the AP proposal you have Smart contract accounts that create these user operations and they send them to the to this new member and then you have the bundlers which are again these new nodes picking up these transactions bundling them together and sending them to the entry point contract so you can think of the entry point contract as a ethereum system contract and the entry point will validate the transactions execute them and put them into the next block okay so what about paymaster pay masters were in the title of the presentation and we haven't mentioned them yet so pay masters are a pretty cool feature of vip4337 and they are a smart contract that is used to sponsors transactions for other users they are an extension of the entry point contract so the entry point will detect if a transaction is supposed to be handled by a paymaster and the paymaster will run some validations and pay the transaction fees for the user or not so with a paymaster you can allow users to you can have gasless transactions for users or you can allow users to pay fees in erc20 tokens for example which is pretty cool again some use cases of pay masters pay and fees with erc20 tokens and if you think about it if you allow users to pay fees with other tokens that means that you are increasing the utility of that token imagine that unit swap decides that any swap will be the fees will be paid with the unit token so that means that from that moment on the unit token is no longer just used for governance it has this utility so it has more value other things that you can build with paymasters you can decide that you can pay fees for any user that has a specific nft this is a pretty cool use cases use case for daos for example or you can have a paymaster that pays the first 10 transactions of every month for a user and again a pay masters are just smart contracts so they are fully programmable any logic that you can think of you can put it on them so the summary of eip437 is this uh it's a new transaction flow for smart contract accounts and if you see what's going on here pay masters are just in the new flow so that means that pay masters are not supported by externally own accounts which is Obama because we all have metamask wallets so we won't be able to use paymasters we will have to create our own smart contact account so when account instructions uh yesterday basically they announced it yesterday so I had to redo a couple of slides of my presentation and yeah they announced that the audit of the entry point a smart contract was finalized and they deployed the smart contract into mainnet so and they also announced uh that there are a few providers running these bander nodes and payment on creating paymasters for users so you can say that account extraction is live on ethereum since yesterday which is great because it opens the door for all these uh ux improvements so here's the the ethereum implementation we have now we can deploy programmable programmable smart contract accounts which means that your boarding is we have improved the onboarding because we might have no private Keys we can have recovery methods so in general a lot of ux improvements and we have pay masters for smart contract accounts eip4337 was not implemented at a protocol level because that would have required like another hard work so they didn't want it to do that and what we have is two separate transaction flows so any everything that they did they did for dcip was adding things on top of ethereum a couple of things that are not so great is that it requires additional clients to run the bundlers so that's one thing my masters are not available for externally on accounts which is a bummer and all of this is great but the transaction fees are still a little high on ethereum so they couldn't do anything about that but these things come there to something yeah of course we can can we can we take eap4337 uh one step further we did uh in CK sync era so let me show you how it is okay with animation this is better because it's less information every point so era we have a account extraction implemented on its live or may not so we didn't have to do any we didn't have to put a construction on top of an existing protocol because we were building a new protocol from scratch and account extraction has been in our radar from the beginning so for us there were zero compromises and this has allowed to allow us to do it in a different way which is more simple both for users and for Developers smart contract accounts and pay masters are first-class citizens because underhood all accounts even externally own accounts every single account behave like a smart contract account and every single Account Support pay masters so if you are using a metamask or trust wallet you can still use it and if you want to send transactions to a pre-master it will still work there is a single mempool and a single transaction flow and this is the key every single transaction no matter if they come from an externally owned account or a smart contact account they both go to the same mempo and we have our own version of the bundler and the entry point contract this is inspired by eip4337 and our bundler is called the operator and the entry point contact is called the bootloader so all of this looks like this which is a more simpler transaction flow or cksing you have externally owned accounts and smart contract accounts sending transactions to the same mental as we just have a single mempool we don't need the two different nodes and bundles we have just a single bundler which again we call the operator and then our entry point contract which we call the board the bootloader and as all transactions I'm following the same transaction flow or can use by Masters which are optional and yeah this is how it looks okay oh it's rolling so how do you build up a master it it you have you can do a lot of cool things with pay masters how do you actually create one before going into the specifics on how you can create pay masters just a reminder of what is the developer experience on CK sync era you can use solidity and Viper or Piper to write your smart contracts so again no need to learn a new programming language or anything like that you can use existing Dev tools like hard hat metamask or Foundry for example uh if you have a project and you want to bring it to CK sync era there is minimal changes that you have to do in the integration zero changes in your smart contracts minimal changes in your Integrations and we have sdks in JavaScript python go Java and Swift and this sdks are not like completely different they are built on top of the most popular libraries so for example the JavaScript SDK is built on top of ethers and it uses providers wallets contracts to to instantiate a contract just you need the contact address the ABI and signer provider so it's exactly the same the python SDK for example is built on top of web3.pi so again the developer experience is is very very easy so uh paymaster again is a smart contract okay and again you can put any logic that you want on them obviously there's you have to follow a few rules one of them is that the paymaster must implement the methods on the IP Master interface and that interface is provided by us in the sequencing contracts packets and this interface has two methods one it's validate and pay for for pay Master transaction and the other one is post transaction and as you will imagine the validate and pay for premaster transaction it receives all the transaction data and some payload and with that you can do any validations that you can think of the the validation to check if if the user has an nft or a validation if they are sending a password if you're if your paymaster is password protected for example you will do these validations here and after that you will calculate how much in in gas fees this transaction is going to take you can see here in this line using gas limit and max speed per gas and you will have to transfer that exact amount from the paymaster to the boatloader contract which is this call or this method over here and once you pay the fees because at the end someone is paying the gas pieces that is transparent for the users but the paymaster is the one that is that will pay them once that paid you will have to return a success or an empty value and that's basically it the post transaction method is optional and you can use it for to emit an event for example that hey this transaction has been executed and it was processed by the paymaster for example then in sequencing we have two pay Master flows built in one is the general one that you can use to basically anything and it receives a payload with any parameters that you can send and again this is useful for if the paymaster is protected by a password you will send the password and it will go through the general built-in flow the erc20 flow which is called approval based is used because if you have used an erc20 before you know that you have to approve and then you have to spend so that that will mean that you will have to ask the user to send two transactions so the way we do it is if you send the if you are using this flow it will be a single transaction for the user and the our transaction flow will do the approved behind the scene so it will be a single transaction for the user front-end Integrations so obviously you have your smart contact you have created it next thing you have to do is deploy it to the test net or to the mainnet obviously and then you have to fund it because at the end the paymaster needs some if to pay for the gas fees so you'll have to find it and then in your front end there are some parameters that you have to include in the transactions to to actually make sure that the transaction will be processed by the pay master for that you will have to use the get baymaster params of the CK sync web 3 Library which is here and this method receives the paymaster address and it also receives an object with a type which is the type of flow that you're going to use again this is general or approval based and then the inner input which is any payload that you want to send to the paymaster passwords Keys whatever you need to run your validations if you are using the approval base flow you will also have to provide the esc20 token that you are using and the amount of tokens that you will that the flow will approve for you and finally in your transaction you will send these parameters in as transaction overrides in in an object that is called custom data you're fine you will send it here and that's all you have to do so you create a smart contract you deploy it from the front-end integration is just too many more changes and your application is using pay masters paying fees for your users or allowing them to pay in year c20s which is very very cool another thing that is pretty cool is that we have built the full track experience using CK sync era and using a paymaster if you have checked in on the oh I'm not going to be able to show you guys because yet I don't have animations but if you have check-in on the event which you have because you're here you have received a code to claim some bidderbox tokens these are an erc20 that is deployed on CK sync and you can use that to buy food in the food trucks outside the way it works is you download my ether wallet or you can use any other wallet because paymasters are supported by metamask or any other wallet you can claim your tokens and once you go to the food truck they will give you a QR code that you can scan and you will be paying your food with erc20s and you can use an empty wallet a completely new wallet with zero it because we are using a paymaster and we are detecting okay this person is sending a transaction and the receiver is one of the food trucks so we will pay the transaction fees so that's why it's completely transparent for you guys no need to use to use if no need to know what gas fees are this is a very very good uh Improvement in user experience and here I had all the screenshots of the app which you you cannot see and here I have some logos from us because we are one of the main sponsors of the event Sikhism era we have hackathon bounties going on if you want to participate again we have built the foot track experience we have two boots one at the entrance another one in the main floor super big and we have a lot of torques panels workshops going on so if you are interested in what we're building and layer twos and how what we're doing to scale ethereum just come talk to us ask us anything so main takeaways second era is a layer 2 roll-up powered by a CK ebm you can say it's an ebm plus because we have account extraction paymasters and any more features that are special specific for CK sync we Implement account extraction at a protocol level which is simpler for users for Developers a construction in general is great because it improves the user experience a lot which means that it will increase the adoption of blockchain blockchains which is our mission and pay masters are super awesome I think they are the greatest things to happen with erp4337 I think they can create like a new economy around them so yeah they're great you've learned a little bit how to build them if you're late or want to know more about pay masters uh you can take our docs because we have a tutorial on how to create your own paymasters don't worry there's no need to take pictures I have a QR code in the next slide so yeah more about our construction there is a Blog series from Argent which have been talking about our construction for years now and we finally have it uh again this is this tutorial that explains you step by step how to create a pay Master on cksync era and deploy it on the test net and use it there is also a tutorial about how to create the smart contract accounts native multisig accounts on CK sync a lot of more information of sequencing era is in our docs and then we have a Discord Channel with more than half a million people developers they're asking questions and discussing about the protocol and obviously our Twitter account make sure that you follow the official account because there is a lot of scams and if this loads yeah this is the QR code you can scan it it has a link to the presentation and it also contains a link to another Workshop that I did a few days ago about an introduction to layer twos in general with some code examples a repo that you can follow to deploy a smart contact on cksing and interact with it and we also have our job board here because we are hiring so yeah that was it thank you everyone for coming and yeah

Automatic transcript — names and jargon may be misspelled.