Biconomy 🛠Intro to Modules on the Biconomy SDK
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
One of the key features of Account Abstraction is custom validation modules. That is the ability to execute arbitrary logic to validate a transaction. Biconomy Smart Accounts and the Biconomy SDK allow developers to use our custom modules and extend and build their own. In this Workshop, we will explore modules and use them with the Biconomy SDK. Some of the most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long hackathon at ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
foreign [Music] hip-hop artist I've retired I no longer do freestyles I'm sorry um but you can follow me on a couple different places Twitter our hot codes uh rahad.lens on lens if you need a primer on account abstraction I did do an intro to kind of traction at eath Paris you can see a replay of that on this link so if you're new to account extraction in general you can check that out this is not an introduction course to account abstraction this is going a little bit deeper into a newer feature that we just recently released so I will give you a just like a small kind of like you know overview but if you want to go deeper into what account distraction is highly recommend checking out this video and some of the resources yep this is okay um it's not showing my slides oh okay I'm gonna go to your system preferences displays mirror all right cool so this is the QR code now if you want to um go through that introduction to kind of traction um highly recommend going through this it'll give you an overview what a construction is and just like a general introduction to our SDK uh so really quickly though um I will go over some of the details in that video so the dichotomy SDK allows you to tap into the full stack of account abstraction so we give you pay masters bundlers as well as packages to create your own smart accounts so the smart account package helps you to deploy your own smart accounts as well as create user operations that eventually get executed as transactions our paymaster package you use one URL and you can switch between doing gasless transactions as well as doing erc20 token payments for gas so we're really focused on like the developer experience you just use one URL switch the mode and you're good to go bundler package you can use our bundlers we have bundlers available on several different chains to actually send your user operations to the entry point contracts on every chain that we're deployed on so now we're introducing the smart account platform which is our Focus for this hackathon as well as like some of the different prizes that we have available for you so the smartcom platform is built around extending our smart accounts to allow you to create and use different modules so some of the modules that we have available for you today that you can start using allows you to do a few things we have a regular ecdsa module which just relies on an eoa to sign and verify your messages similar to like the experience that we've had with our previous offering with our previous version but going a step further we now also have a multi-chain validation module which acts the same way as the ecdsa module you use an eoa to sign for your transactions but using that eua and one signature you can interact on multiple chains all all with one signer so you don't have to have your user switch between different networks you can just interact seamlessly across chains and completely abstract away the need for your user to even think about what network they're even using we have session key managers which is going to be the focus for today's Workshop this enables the use of sessions and session validation modules for your triggered apps so think of it this way you sign once and then you start doing transactions and you don't have to keep signing over and over again you unlock actual fluid web 2 experiences where you can do things like working on web3 social sign once you don't ever have to like if you think about if you've ever used lens protocol you don't have to sign every single time that you you know like something or you know comment or post it's a similar experience to this so like I said today's focus is on session key modules let's dive into a quick demo and some code so here's the Demo First hit this connect to web3 button metamask will pop up I'm going to connect cool I've connected and although my um address ends in bdfd you'll see that the smart account address is different it this smart account was deployed I'm using my um you know eoa as the signer so this is showcasing the ecdsa wallet here the ecdsa module I'm going to hit this create session button in the background a session will be created I just sign once so this is what I meant before I signed once right every single other transaction that I do in this demo I will not have to sign again so it's creating a session for me in the background letting that kind of go cool success session was created now in this demo I'm simply just going to hit this transfer one usdc button what's going to happen is I've already pre-loaded my smart account with some testmatic as well as some test uscc and I'm going to send usdc to back to this account so just to show you right now there is 29 usdc on this smart account I hit transfer one usdc in the background it's happening no metamask Pap up right nothing that I have to sign it's just a nice little seamless experience I'm just waiting for it to kind of like go through in the background cool I get my actual transaction happening here but before we look at the transaction you'll see that my uscc balance went up to 30. didn't have to sign didn't have to do anything this is an actual like think about this as like an actual experience of like how a web 2 user would use venmo right you're sending some funds to another user but you're not signing every single time you're not approving it every single time now you can actually unlock these experiences on chain so this is the transaction that just went through about 12 seconds ago I'm sending one usdc from uh this account to the other one um all on the polygon Moon by Chain we're um act we're on major all pretty much all major um almost all major evm chains if you want to look at our bounties as well as some of the chains that are available here we're available on polygon were available on base we're available on Linea as well as arbitrum so if you're hacking on any of those chains for the hackathon you're able to use rsdk cool so that's a very basic example right just um kind of like what's possible let's see how that actually works I'm gonna go over to our documentation and show you an implementation of the session key um a validation module smart contract that actually allows us to happen so you can actually use this as an example to build your own session key validation modules but in this instance this is an erc20 session validation module which takes a few different permissions for you to look at for the little demo that I just did one it's going to take some information for the session key itself that this session key is going to have four different arguments in it and I'll kind of go over those later it's going to take a token in this case I send usdc so the usdc token address is going to take a recipient in my case I hard coded the recipient only to be my other eoa you can obviously change this logic but this makes it so that within the session I can only transfer the rc20 tokens to that specific account so here we're like looking at the different permissions of what's actually allowed in this session and then there's just a max amount that I cannot cross over during any of these sessions right so this is just doing all of the checks making sure that the token that is supplied in the argument matches the token in the session key which would be your C2 uh the usdc that I used this is also requiring that the call Value equals zero if you want to you know do your own kind of like session key validation module let's say you're minting nft that needs some value you would remove like a line like this and just make sure there's a certain value attached to it so this is just like a base for what you can use to actually build your own modules next it's just checking if the recipient is actually the same as the one that's specified in the session again I can only send to that one recipient and making sure that the max amount is not exceeded this specific function here and this specific function here they do more or less the same thing this function is called from our session validation manager uh the manager essentially you supply it a deployed um smart contract in this case I deploy we deploy this contract for you so you can start doing the transfers yourself but if you wanted to use your own contract build it on top of this deploy it just switch the contract address you have a session validation module that you can use with our SDK so this is called specifically by the session key manager and if you're doing something like batching sessions together we have another batch session router which allows you to batch multiple different types of sessions this is the function that's called in that case if you want to learn how to like build if you want like the base kind of like how to build uh we we have the actual contracts that are linked here so you can use the interface and follow the example here to build your own modules deploy it and use it on our SDK how do you actually use it so to actually use it in in a application first thing you want to do is set up your bichonomy smart account in this case I'm using the dichotomy smart account V2 that's our latest version of the smart account itself you create an instance of your bundler you can grab your bundler straight from the dashboard for test stats you can actually use just use variations of this this link and just change change ID also from your dichotomy dashboard you can grab a URL for your paymaster and I recommend using your own URL because none of your transactions will work on this URL um but cool this is just like a connect button just to connect to like the actual um you know metamask wallet nothing fancy here I'm just doing an ether's request for uh request accounts and then I'm using our ecdsa ownership validation module to create the signer that's going to control the smart account so that's this this step here essentially passing the signer that I get from metamask over to the ownership module here the cool thing about this is we're signer agnostic this is one way of me creating a signer a simple way through ether's JS however you can use any type of authentication system that you want another um you know um sponsor here is privy if you wanted to use privy to create a signer you can actually use their um um you know SDK create assigner pass it to us now you have a by economy smart account created by the signer from a privy account and this is the same if you want to do something like wallet connect you want to use wall connect to connect get your signer you can do that too this is just a basic example this is not the only way to create the signer you can create the signer in any way you want as long as you pass the signer to the address you're good to go last thing here we create the account these are just the different you know validation modules and everything you need on the erc20 only creating the session side of things where you actually create your session one thing that I mentioned before is you're essentially using a deployed smart smart contract right that's the smart contract that we went through before replace this with any smart contract that you want that you've built on top of that for your specific use case right so if you want to add more permissions more granular activity onto your module you can do so you want to replace it with like an ERC 721 module go ahead whatever you want all you got to do is just replace this address okay in terms of the actual transfer itself again we're making sure that we're using that erc20 module we're making sure that we use the session key manager module this is all just copy and pasteable things from our documentation this repo is available on GitHub there is a step-by-step how to recreate this exact project on our documentation as well just for the interest of time I can go through every single detail um but here I'm transferring the funds to a specific um you know eoa which is the eoa that I created before if I were to change this this um specific um transaction would fail because I can only I only specified that I want to send to this address and that is done when you actually create the session which is over here the session key data itself which holds four arguments it's going to be the session key eoa you're basically creating an eoa for your dap that's going to sign on your behalf you're passing it a token address you're passing it a receiver address and a maximum amount so these are the permissions that you create on your front end and pass to your session key validation module for it to check against every time you do a transaction and then there's just a few other pieces of data how long is it valid for it's zero zero here which means it'll be valid forever you shouldn't do this in production make sure you actually have an end date um you just pass a Unix timestamp here and you're good to go and the last thing that I want to call out here in this demo we're saving the session key private key to local storage this may or may not be something you want to do in production but you have to look at the trade-offs of doing it this way versus saving it on some server if you save it on some server you have direct access to the private key of this session so you want to look at the trade-offs do you want to keep that on the client side and let the user kind of just like worry about that and make sure they don't have any malicious code running or do you want to manage it for them so look at the trade-offs for your specific use case depending on how you want to go on on that end but this is a quick run through of the code now really quickly let's chat through stuff that you can build so our top prizes revolve around awesome use cases with our modules what are some things you can build I've actually seen a couple people come up to me asking about this already payment subscription you can build a module that allows a merchant to pull funds from a smart account you can actually just use even the base erc20 contract that I have and add just additional bits of logic to it and you can probably create this this weekend pretty quickly automated token trading again another thing that you can just build on top of the erc20 session module that we showed based on different market conditions based on how much gas currently how much gas the gas prices token prices do specific token trades or add daily limits to your spending dudes replace the erc20 token entirely with nfts ERC 721 nft rentals create a module that allows PDP out of two rentals between users look at gaming modules we just looked at like signing transactions for on-chain gaming kind of sucks you don't want to keep signing every time you do an action on chain how can you use session keys to improve Gaming use cases do something like creating a wallet burner Factory allow users to create burner accounts for specific transactions give an account the ability to do a specific transaction and then never use it again and if you're excited to build let us know we're ad by economy or hot codes on Twitter um you're not the only one who's excited today we actually just passed 600 000 user operations that have been um that have gone through our system so we'd love to see you kind of like adding to that number and joining in the community who's building around by economy so I'll be around all week we have a couple of Engineers who are here as well would love to see what you guys built
Automatic transcript — names and jargon may be misspelled.