# Asset Rights Abstractions - a Case for Smart Contract Wallets | Devcon Bogotá

- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2023-10-07
- Duration: 25:06
- Watch: https://streameth.org/watch/yt-LPTivpZncuw
- YouTube: https://www.youtube.com/watch?v=LPTivpZncuw

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on Swarm, IPFS and more.
https://archive.devcon.org/archive/watch/6/asset-rights-abstractions-a-case-for-smart-contract-wallets/

Smart contract wallets (SCW) have a potential to streaml UX and increase compatibility of asset and dapp contracts. 

Well positioned SCW can overcome needs for devs to integrate increasing number of standards. Instead SCWs can improve composability between dapps and decrease the amount of TXs needed, enabling dev to focus on core features rather than handling custom or niche cases of asset contracts. 

PWN Safe is an example of such wallet enabling selfcustody of lending collateral.

Speaker(s): Josef J, Naim
Skill level: Intermediate
Track: UX & Design
Keywords: Wallets,UX,Gas optimization

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 6 was held in Bogotá, Colombia on Oct 11 - 14, 2022.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

foreign [Music] and they are going to share about azerite obstructions a case for a smart contract wallets go ahead [Applause] thanks hey everybody um my name is Joseph this is neim we are from Project called pawn and today we are not going to talk about Pawn but about something that we developed for the community uh because it's important to us and to our cause so we are going to talk about acid rights abstraction our case for smart contract wallets so [Music] I'm a CEO of Pawn whatever being a CEO means name is a smart contract app so he's the he's actually the guy who is going to tell you the interesting stuff I'm here just as a staffing um so first do I um so why did we started uh start developing a smartphone wallet in short Pawn is a is a generalized borrowing and lending protocol um but we also need like a whole bunch of tooling out there in the ecosystem and since it wasn't available at the time um we we decided to develop it ourselves um so Upon Our Kind of Holy Grail what we want to see what we want to build in the ecosystem is um seeing long-term Loans mortgage type of loans are being issued uh on chain so we're looking at like 5 10 15 years uh contracts that should last on chain and should be actually um you know perceived as uh as legitimate like today what we see in D5 is mostly short term or something that will you know get set up and can be erased like 30 seconds later uh but we kind of want to get us to the point where people will be able to uh back their long-term mortgages with digital assets and this is a important piece of the ecosystem or like piece of the tooling that we need um so we decided to dive into into smartphone wallets and kind of allow using the assets that you that you own um while you're using them to to back alone uh but our case or the case for uh for our smart wallet is is much wider so uh today we are going to dive into that um so most people I guess know smartphone wallets as um as a multi-sick or something that allows you to operate a wallet or operate an account as uh multiple multiple users but there is much more so depending on your level of uh you know um technical knowledge or just like the the time you spend in the ecosystem just a quick rundown what are actual smart growing wallets uh so contract wallets are essentially smart contracts that are creating a proxy um between a user or like an end user account uh and another contract uh with some extra logic added so there are some some examples uh why would you use it so first you can you can enable you can create like more events automations or like call wrappers around multiple contracts uh and do like more things in one transaction then you would otherwise be able to do a good example for that is you know this is safe or safe uh as it was recently renamed uh which uses it for multi-sync interactions or another great example is a deviceaver um smart contract wallet which makes it easier to operate um in the in the default ecosystem another example would be just general identities uh so there's a lot of talk about uh decentralized identity standards uh and a way you can use multiple keys in one smart contract and essentially like use the contract as your on-chain identity there is a whole bunch of whole bunch of attempts around the did or there's also the Urgent wallet which essentially does this very similar thing um now smartphone wallets aren't definitely useful for for everything they have they have some downsides so that's especially the gas overhead because again you you're using extra proxy you have to do more computation in every single transaction that you're um you're using it for uh and secondary uh you may require some level of integration so EIP 1271 for sign messages would be one example of like what everybody everyone else has to integrate in order for smart contract wallets to work just as like a user account would um so in our specific case like why do we want to mess up with uh with asteroids um as I mentioned we want to allow the case where you kind of can have your cake and eat it too where you can have um Assets in your custody but still create some sort of a deed some sort of a right uh for another person to eventually be able to access those assets and and kind of like take them um take them with them so um the very basic case for us is essentially creating a hook in the wallet in someone else's account that allows uh you to essentially drain the wallet uh if a certain criteria is met and obviously if the other person consents to it so they would actually like sign up for that in another contract um why is this what is it good for is that you don't actually have to move those assets that you have in the account you can just create this like uh right that will allow someone else to access those assets uh and if some people state from the previous talk uh from like EA or just the Enterprise ecosystem this could be useful for even like kyc'd assets because or like assets that require kyc because you don't have to move them from wallet you can just wait until the point where you actually have to move them uh and that's the point where you can kind of like start dealing with kyc because the actual asset didn't you know didn't move nothing nothing happened to it um so again for us the the case is the D5 mortgage where we just want to allow someone to um you know buy a piece of decentralized lock it as collateral keep that in their custody still like allow them to use it but use the value of the assets asset as a backing for loan another example would be you know like Dow voting rights again like you still want to use those but you might want to utilize the the value or that's that's kind of backing uh the particle token the same goes for gaming items or ens names are again a perfect example um another useful thing is that you can also allow asset renting you can just reverse the case and essentially just give someone the right to uh like transfer the right to someone else but keep the token transfer right and keep the ownership of the asset um and withdraw it later if certain criteria is met again so this is the basic intro and now finally uh now is the interesting stuff so passing the word over to nine uh thanks Joseph hi guys my name is name uh before we start for those who don't know me uh beside I'm being a smart contract I'm also a contemporary circus artist so I'm even though I'm used to performing in front of people I am not used to speaking in front of people so I'm super nervous now and uh I was thinking how can I like make me less uh nervous so I decided I want to perform you something uh unfortunately I'm jumping on a trampoline which is uh which cannot be fit here so I'll just show you a video of me being shot from your human cannon thanks guys yeah it helped me it helped me a lot so back to the topic uh let's define some requirements for this uh for this contract wallet uh obviously it has to act as a normal contract wallet that means that you have to be able to call orbitrary call later on on any address basically and the nice feature enabled tokenizing asset transfer rights we want to enable tokenizing these rights to fungible non-fungible and semi-fungible assets uh uh and one of two things it means is actually to enable the ATR token holder to transfer uh the assets from owner's wallet so you don't own the asset but you are able to actually transfer it and the second part of it is prevent the owner without the ATR token without the ATR token to transfer it so yeah you are not screwed if you are a token holder foreign first after some prototypes we try to implement our own smart contract wallet uh which is something we realize we don't want to do because we'll be basically Reinventing the wheel so after some research uh of uh gnosis save we realized they have uh two very nice components one is guard and one is module for those of you who don't know uh the safe ecosystem that well guard is a is a contract which you can basically link to your Save which will check every transaction made from your save for uh at the like before and after the transaction in our context uh it's a guard which will basically enforce the transfer rules okay so uh if if we see that the the safe has the ATR token minted but it's not the holder will basically revert the the transaction and that's the responsibility of the Guard uh the second component is a module this enables to execute the transaction without actually reaching the owner's threshold which is also something we really want because we want the ATR token holder which is not the owner of the save to be able to transfer or start the execution of the transfer from someone else's safe so yeah that's cool with these two components which I was like very surprised they have we were able to build this ATR smart contract on top of agnosis Save which is really great uh we encountered obviously some challenges so we will talk about them right now uh first is approval issue while minting an ATR token uh it's pretty obvious that you don't want to Mint an ATR token and have approved addresses at the same time uh because if you if you do the approved address can transfer the the asset without even triggering the the guard or the module so this is obvious like a thing we have to we have to solve uh next is something we called stalking attack it's basically a type of attack where uh I as an attacker will create a malicious asset I will tokenize its transfer rights I will transfer it to my victim's wallet and remove it with some non-standard way so let's say the asset can be transferred by the owner I'll I as an attacker am the owner so I'll be able to uh to withdraw that in that case the victim's wallet goes into uh Interstate where every execution will fail because the guard will not have the proper like sufficient tokenized balance so it's also bad uh then we have challenges like EIP 1271 where the input of the function is basically just hash and signature so we cannot like uh enforce the rules if we don't know what is actually like verifying uh then there is a gas overhead it's a contract wallet it's always will be there always will be some gas overhead plus there is a lot of checks for every execution right uh then there is the non-standard assets uh we have we currently support just the standards we cannot support non-standards asset because we are actually enforcing the the the transfer rules right uh so yeah that's one challenge and not possibly not possible to use the delegates goal because then it will alter the logic of the smart contract and again you are you are able to to transfer it or do whatever you want with it so let's talk about the first one yeah uh approval issue while minting ATR token uh uh we need to check that the the asset which is going to uh the asset which ATR is going to be minted uh doesn't have the approved address currently there is like four types of of approvals for erc20 it's approval amount for ERC 721 it's a proof ID or set approval for all and for ERC 1155 it's that you just set approval for all only one of these approved function has actually a getter for the address uh so it's it was a big issue at first but after realizing that all the approval ex or all the transactions which are approving the the assets are done through the wallet then we can basically just track all the all the approved addresses and uh on the time of minting we can check that the asset is not uh doesn't have uh An approved address so yeah cool we need to we need to check the approved addresses the stalking attack how I described previously uh it's it's the malicious asset which is transferred from the victim's wallet by the non-standard way uh it would revert on insufficient tokenized balance and but we don't we still want the ATR token holder to be able to transfer it to any asset so because of that we need to basically divide the transfer function into two uh first disclaim where uh I as a ATR token holder and transferring the asset to my wallet which is cool there is no possibility of stocking attacks so yeah we'll let you do that and the second is the generic transfer to any address but in that case uh we require the recipient permission uh in this permission uh the uh the recipient can actually specify what type of asset is going to be transferred by whom uh some expiration stuff and so on and so on so it's much harder for an attacker to actually execute this stalking attack it's still possible but it's much much much harder uh but still because it's it's possible we need to implement a function uh to recover the safe from from that attack which we did that's a good one so uh after solving some challenges uh the the final design looks like this we actually uh right you can see the the ATR token or the ATR module uh here is the here's the guard uh it's implemented as a proxy for basically be more future proof If there is some widely adapted ERC which we want to we want to like support we don't want to force every uh like safe owner to deploy new ones will will basically do like a force update for them uh then you can see the operator's contacts this is a contract responsible for tracking the approved addresses uh per safe per per the collection and uh our Ponce Factory just to like be sure that the address we are interacting with is actually safe and then there is some uh some like agnosis save agnosis save contract and uh and the owner because of the of this proxy still we didn't solve all the challenges so open challenges are enable EIP 1271. it uh will be possible if the wallet basically pre-approved the hash in that case we can actually check what is approved and if if it doesn't like break any transfer rules it'll say yeah okay you can this hash is approved so every call for the uh is valid signature will return to or the magic value uh for for this hash uh guess overhead of course we want to have a we want to have the gas cost as low as possible so currently minting the ATR token has a constant overhead which is night which is nice uh and transferring the asset via the ATR token has linear overhead because it's like it's depending on number of tokenized Assets in the in the safe uh because we need to check that every tokenized asset after the execution is actually there and that the tokenized balance is still sufficient uh then there is an issue with non-standard's asset I think this this issue will be there like forever because uh yeah that's like we can work only with the honest assets uh so if somebody is trying to give you his ATR token for some malicious asset which is not standard they find some like approved functions or transfer functions we cannot basically like prevent him to do that and if you accept this ATR token then yeah you're screwed sorry and the possibility of using delegate goals uh there is actually an option to like whitelist some addresses uh to be able to use the delegate call or to call the delegate call at uh but we cannot do it like generally we cannot say hey you can you can call delegate colon any any address because then it's a it's a huge security issue for us yeah and I think that's all so thank you there was me and Joseph thank you so much naiman Joseph and thank you for I also think we have two more thanks to shildo there are two slides where yeah two more slides I'm sorry yeah or maybe it's stupid to put two more slides after a thank you page but you know stuff happens uh if you can go to thank you one as actually oh yeah number 18. yeah cool so I I realized like maybe some of the some of the graphics weren't really visible here so if you go to uh Pawn dot mirror.xyz there is an article about the the pawn safe where everything should be described uh also you can just check out our website on pawn.xyz uh where you can see our outage see our repos we have a bunch of documentation uh for users or or developers as well and finally well here's our pull-up yeah thanks for coming and I think we have six more minutes for questions is it right yeah so if any of you have a question anyone there we go yeah thank you uh good afternoon uh how are you going to handle the I don't remember where the E the e i the correct AIP but there was one that what will allow you to approve and transmit at the same in the same transaction have you any plans for that I think it was 12.71 or something similar come again if we want to support standard that can approve and call in the same transaction yes there I believe there was one of the eip's that uh that allowed you to sign a transaction at several same several transactions in the same uh in at the same time if I understood it correctly there is one EIP I think it's 1373 something like that it's a token standard which implements another set of approved functions these approved functions can basically approve and call arbitrary data in one transaction uh we are actually supporting that so beside these well-known 27 721 1155 we are also supporting 777 and these 1363 I'm not sure about the number now so I hope I answered your question or it was something else anyone else thank you um lending out nfts is always a bit tricky and you mentioned you can lend it out without using collateral uh how is that realized and is that compatible with any existing uh wallets that would display nfts uh well the idea about not using collateral is that you will use collateral but the ATR token so basically if I want to lend you some assets some whatever asset I will first tokenize its transfer rights I will send you that asset and I'll keep the transfer Edge to myself so you are stated as an owner of that asset in the whole D5 ecosystem but if you stop paying me my installments or whatever I'm still able to transfer it back from you even though normally I'm not I don't have the rights to do that so it's not like uncollateralized in like very technical sense but you are not using the asset itself as a collateral you are using the transference instead foreign else yep hey guys thank you so would you elaborate a little bit about the account rental you were talking about the the like account rental or so and the bribery attack for the account Trend also if I have if I understand call it correctly then will will be allowed to rent our account on their usage of it so how yeah it was about specifically the assets but now if you want to take that one as a printing case all right well so essentially what what name did which I didn't realize when he was developing it uh but I thought it was super cool is that um within within the realm of um the the sales which have this particle guard and module enabled uh because you generate them using a specific like uh Contra Factory uh you can still uh transfer the asset uh to essentially like any safe that's that has that particular Guardian module and the asset token uh the the ATR token will still be executable and you'll be able to essentially get it from anyone anyone's wallet uh within within that particle realm so obviously like you have to you have to be um you have to realize like the particle asset has this deed created around it but it's essentially the same as like having real estate property and like having a deed on that property um and um then you know we can be like friends um that once you like reuse our gaming assets uh we can have the asset token regenerated I can safely like give my you know magic swords to to knives wallet uh I'll tell him to give it back to me in 30 days if you I can just claim it back and obviously you can you can put it into contract you can set your uh set kind of like exact parameters on like how the return should happen but the asset token the the HR token is basically the the thing that will execute a transfer later on perfect thank you so much name and Joseph
