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

Loading player…

Biconomy 🛠️ Getting Started on Account Abstraction with the Biconomy SDK - Rahat Chowdhury

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Harsh Rajat from Push Protocol for a workshop titled "Onboarding 1 Billion Users through Web3 Communication: Push Protocol". Account abstraction (ERC-4337) can be a hard concept to grasp and even harder to understand how to implement into your projects. This workshop is aimed at giving you the base knowledge needed to understand Account Abstraction and leverage the power of the Biconomy SDK to start building using the principles of AA. Thank you to everyone who joined us for ETHGlobal Paris 2023! Paris is the city of light and birthplace of many revolutions. Therefore we were thrilled to be back in one of the most buzzing and free-spirited cities in Europe for ETHGlobal Paris 2023. A lot has changed in the European ecosystem since the last time we hosted a hackathon in 2019. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] thank you everyone for coming to my talk uh so we're going to be talking today about account abstraction and how you can get started using construction in your depths today with the bichonomy SDK uh it's a little bit about me my name is a hot head of developer relations I have economy be here throughout the week to help you out as you're hacking through this answer any questions that you might have formerly been a front-end engineer did some solidity um former founder didn't really work out but yeah also a former hip-hop artists I'm retired I do not do freestyles anymore because I'm not good at them anymore but yeah so I usually look like one of these two things um usually the first one so I wanted to kind of like talk a little bit about the current uh ux of web 3. if I were to try to bring uh my mom into using a D5 protocol she would have no idea what to do she would have no idea how to onboard herself onto a wallet go to an exchange get some funds transfer them over to the eoa and then go and finally at that point start to interact with a dab right and this is the exact set of steps that every single person who is not native to web3 needs to go through before they actually even use your dap if you're trying to actually get users for your app which is probably something you should do if you're building something get users make it as easy as possible for them to do so so there's a lot of things wrong with that General kind of feeling the first part is like that onboarding onto a wallet right there's this fear of losing private Keys a couple weeks ago I unfortunately got my own account hacked and got drained as a significant amount of funds but this whole like private G situation this whole like saving a bunch of words of nonsense that needs to be written down somewhere it's not a great ux complicated web through ux I just explained having to go through so many different significant Hoops in order just to get started doing your very first transaction on any dab and then there's the whole thing about paying too much gas fees so how can we actually improve the web 3 user experience incomes account abstraction uh eip437 which you'll see on my shirt we have some more of those downstairs if you're hacking out by economy definitely pick up a shirt um but what exactly is a kind of scratch in you can Define it as the ability to add arbitrary logic to the process of validating a transaction so any transaction adds some additional information to it that information helps you do whatever other type of logic you want to do when you add this information to it this new data object is called a user operation so this is like a new way of looking at transactions through the scope of a construction specifically through 4337 so user operations live in what's called an alternative mempo and you have service called a bundler which we'll take a look at this alternative mempo take these user option operations send them to what's called an entry point contract that lives on each chain and handle actually executing them into regular transactions so all of this stuff is achieved with what's achieved with using smart accounts or smart contract wallets normally wallets are secured by code uh well not normally these wallets are secured by code instead of the ucdsa so this allows for you to actually execute that additional Logic on top of your transactions so the main thing you want to ask yourself is how do I want to authenticate a transaction what additional logic do I want to add on top of it that's kind of like the most basic way of thinking about account attraction just taking a transaction and figuring out what else you can add before you validate or let it actually go through quick diagram just to show kind of like the life cycle of like how this works in the green box kind of represents a smart contract wallet secured by code it can be owned by eoa externally own account which is like your regular um you know Wallet account that you might be used to it can be secured by you know Hardware devices uh pass Keys which is going to be coming soon to our SDK currently in audit but these are what actually executes those user apps that live in this mempool and a bundler is simply a service they can be written in typescript Rust whatever is going to be looking at that mempool and sending it to that entry point contract now I mentioned the user op-amp pool can have additional information in it one bit of information that I might have is data regarding a paymaster contract a paymaster is simply going to allow you to do a couple different things a it can let you sponsor transactions on behalf of the user so from the user perspective they don't have to pay any gas you can also decide to let the user pay in erc20 tokens so it depends on like what kind of user Journey you want to build out um for for folks and eventually the entry point contract is going to handle the execution phase of the um okay the transaction um so all all of this is basically governed through this entry point contract that lives on each chain the infinitism team uh deployed um the entry point contracts couple a few months ago on the ethereum mainnet um there are energy coin contracts across polygon um and so how's optimism Etc uh several other chains as well if you ever want to just get like another quick breakdown of a constraction I've done a few Twitter threads that are have like a little whiteboarding session going through them um definitely take a look at that just it without any code just kind of like goes through explains some of the principles these also exist in blog form on our blogs so if you go to dichotomy.io head over to the blog you can read the blog format of this as well so I explained a whole bunch of stuff to you but to actually leverage account abstraction you probably don't want to code out all those contracts yourself build out all those Services yourselves so we give you a solution in the form of the dichotomy SDK so the dichotomy SDK comes in mixed imaginable packages so these are the three main packages that are going to help you um you know actually building out your projects as you're building this weekend first is our accounts package which is going to help you deploy your smart accounts um it's also going to help you creating user operations we have a bundler service in the background so you can use the bundler package to interact with that same for our paymaster so like I said paymaster Can sponsor Augustus transactions or allow users to pay gas with erc20 tokens the bundler is again what's going to look at the user apps that are created from the accounts package and send them to the entry point contract that exists on the chain that you wish to interact on the cool thing with the paymaster and bundler you don't have to actually use our services to use the SDK if you want to plug and play different Services as long as they are 437 compliant you just need a URL of a payment master of a bundler and you can plug and play it into our SDK so it's completely mixed and matchable with other services I said that I guess too soon that was my slide explaining that but let's dive into a demo and some code so on the screen here you'll see I have this is actually a live website you can go to it now and you swap Dover sell that app but uh it is a miniature version of uniswap this app is using the unisoft V3 router under the hood and he's also using the bichonomy sck in order to add a couple of uh functions to it so I'm going to connect to web3 and I'm going to pretend I'm actually just a user who has never onboarded onto a wallet before so since I don't have a metamask I don't have any wallet I'm going to use Google to login and I'm going to sign in using my email and once I've done that in the background it's just using web3 also under the hood to create an eoa for you and that eoa is actually going to be an owner of a smart account that is deployed by the SDK so this address here is actually the address of the smart account I have some funds on it from before so you'll notice I have some wrapped ether link uscc and I have nomadic even though this wallet is deployed on the polygon Mumbai Network so just a thing to keep in mind if I wanted to onboard quickly if I had no funds whatsoever I can hit buy crypto I can use bank account credit card anything I want to add funds directly to my wallet I already have some so we'll just not enter my card details there um so I have uh some usdc here so maybe I want to swap some usdc for some rap ether I'm gonna hit the swap button and in the background so there's nothing I have to sign there's no like um you know metamask pop-up that you have to go in and approve transactions things happening for you in the background um everything is like being signed for you what's happening in the background is there's two transactions actually running at the same time there is the approval and the swap okay uh I forgot to actually click on the link let me see I hope I cancel out it I can have a transaction response okay but um this is on polygon scan this is a mainnet transaction I think I let's just do the transaction again this time I'll remember to click it um so basically in the background it is approving and swapping uh one usdc all at the same time so that's two transactions being batched into one so as a brand new user uh to web3 I don't have to worry about approving x amount of tokens to be swapped it's just done it for me and it's only being done for the exact amount that I need to swap and you'll see here this is a transaction happening right now on mainnet on polygon menu refreshed okay cool so you'll see here it was completely successful I swapped one USD USC coin for the equivalent to the wrapped ether I had nomadic in my account so that was completely gasless if I wanted to I could switch this so that I paid for the swap using my usdc as well so that's another option that I could have enabled for my users so again it's up to you which which side of the ux do you want to you know work with it might you might come to the conclusion that it'll cost too much to sponsor all your users gas so maybe the usdc payment is something you would prefer or maybe um if you're using you know something like polygon where the transactions are low enough where it's totally fine you can just completely sponsor it yourself so how does some of this stuff work um in in the Discord group you'll see a bunch of links to our documentation uh several blog posts several example and quickstarter tutorials uh so if you want to see how it works in react how it works in xjs uh vit how it works with node I'm going to go over the node.js scripts right now um just because it's a little bit quicker to go through that in a workshop setting but initializing it is really just copy pasting a bunch of boilerplate code you initialize our bundler like I said you can use any bundler that you like I'm just using our bundler here just past the URL of the bundler that you're you know attached to same thing for the byconomy paymaster I'm attaching rpay Master to this these are these can be found on the byconomy dashboard so that's dashboard.meconomy.

io that's where you would go to like get your API Keys authorize your smart contracts and everything there um and then the last part is just creating this by economy smart account configuration so you're just going to be passing um a the signer which is your wallet um your eoa because you're able to pass just any signer object you don't actually have to use our social login you can use any social login that provides you an ether.js object so you can use magic you can use web3 off which is what we use under the hood anything that you like that you're used to it is compatible with rsdk as long as you have that ether JS transaction object so here um just a quick thing I'm initializing the byconomy account I created the account and I'm just logging out the owner so the owner is the eoa that is used to actually put this um to actually um sorry the the notification messed me up um that is actually used to create this smart account so right now all of our smart accounts have to have an owner we are in um audit to have like future versions where you can have like an owner list uh smart account so definitely keep an eye out for that but for now you do have to have it owned by some external eoa in the case of wet3 off they do create a new way for you in the background that owns everything so let's just take a look at minting in nft pretty um basic kind of thing example so I have this interface of a safe Min function I have the nft address here one of the main things I need to do really is just basically get information about this specific um function that I want to execute and there's a couple ways to do that so this is one of the ways the docs has different examples how you would do this on front end it'll be slightly different but you're just going to get some information about the actual function that you want to execute pass it any parameters that it needs once you have that info you're going to start building out the actual user operation but the only part of the user operation you need to build out is this two and this data field the two is just going to have the address that you're interacting with and the data is just going to have this information here about the transaction that needs to be executed so we have this build user op function attach to our smart account which is just going to take an array of these constructed transactions so you can put one transaction in here you can put several transactions in here one if you put one transaction it will just execute that one if you put several transactions in this array it will bundle those together into a single transaction so that's how I did that approve and swap on the unit swap demo uh these are just some typings and then the other main thing to see here uh is this paymaster and data is going to take that user op it's going to take data that you can build out using um rscj and there is a mode there we go so there's a mode here for how you want to sponsor if you want to sponsor um complete the gasless you just use a sponsor tag if you want to sponsor with the erc20 tokens meaning let the user pay in your rc20 tokens you simply switch this flag it's just a flag that you switch nothing too difficult there and the last part this is specific to erc20 sponsorship is just getting feed quotes So what are the quotes for the different types of swaps that they can do currently we support a few different stable coins you can get a full list of that on our docs to see which coins that we support I usually just use usdc for demos just the easiest one so let's go ahead and execute this take a look at that so yarn depth um it's I'm just going to uh log out the owner the address this code is also available on the links that are shared in Discord you'll see that a user op hash is um printed on the screen as well let me actually a bit bigger cool so this is on not on mainnet this is on polygon Mumbai I think from the chains that are sponsoring uh this time we support polygon as well as Linea so those are two different chains that you can launch on and you'll see here that there were two uh nfts minted all in one transaction I passed that transaction twice in the array and let's just confirm that so that is token 149 and 150. we're gonna grab the address from here let's head to openc and verify that that was done and we have 149 150 here cool so all of these all this code you can definitely take a look at on our um you know on our docs as well as the notion pages that we've provided in Discord that show you some examples of how you can go through and build a lot of these things out we have tutorials and starter kits that show you how to actually use other sponsors technology along with our Tech as well as just like different variations of like how you would do this and actually that's how you would do this in react or using Vite so whatever flavor front end you kind of like to use we have a couple different tutorials for doing that as well so definitely explore that there is one other um I guess our larger um price prize that we have so if we take a look at the prizes you'll see that there are two 2 500 prizes for the best use of session Keys uh that are built on top of our smart accounts we have a tutorial that will go through how to build your own session key module on top of our smart account as well so definitely take a look at that if you're interested in building with session keys for uh for anything else we do have three one thousand dollar prizes for best use for best consumer use cases in web 3. um as well as a two thousand dollar pool prize to be uh eligible for the approval prize you just have to successfully execute a single user operation uh so long as you do that you are eligible to be part of the full price if you need any deaf support uh myself and Yash will be here in person um he's the guy right now at the booth um and we have another person about Chicago on Discord who you can tag and ask for questions as well if you need to refine your pitch or your idea we have Tommy and Ahmed who are both around Ahmad is our CEO Tommy is um you know part of our content team and is amazing at weaving stories together so if you need help on your ideas or refining your pitch definitely these guys are cool people to go to and yeah if you're excited to build definitely let us know uh ad by economy on Twitter uh at our hot coats on Twitter and uh thank you uh if there's any questions happy to answer those thank you foreign [Music] with react native with some configuration um but right now it's just mainly a JavaScript SDK but we do hope to have more um support for other mobile I think so so the SDK has upgraded to version 2 from version one yeah so what's the main difference between version 1 and version 2. so version 2 is more modular um so one of the things that I was kind of talking about is how you can use mix and match the different packages with other services so we opened it up so that you can use any bundler any pay Master service we do of course offer the full Suite you can definitely just use ours if you want to but if you have any specific use cases that you want to use like other services with that's what it opens up with we also made it a lot easier to execute user operations than our previous version um so it's a lot of improvements on the developer experience side as well

Automatic transcript — names and jargon may be misspelled.