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

Loading player…

ETH Penang: Intro To Token Bound Accounts ERC 6551

Ethereum MalaysiaWed, Oct 9, 2024, 12:00 AM

Julius discusses ERC-6551, an Ethereum Request for Comment (ERC) that defines a system that assigns Ethereum accounts to all non-fungible tokens (NFTs). These token-bound accounts allow NFTs to own assets and interact with applications, without requiring changes to existing smart contracts or infrastructure.

Transcript

so so uh these are the topics that I'm going to cover I mean the agendas I'm cover uh what is uh ERC 6551 I will and then I will give a brief demo what is it about uh then I will talk about some use cases and then we will talk about the The Proposal itself it is still an ERC uh in in review stage so I'll will talk about the what was actually proposed by this ERC and then talk a little bit about the ecosystem right now and the adoption about it so um what is ERC 6551 okay uh if okay first I need to just mention the authors uh jayen wind and Benny gang they are both from Future Primitive so they are the starters uh who who initially proposed this particular uh approach to to enable nft to bound to account right so they are the original authors but over time there are a number of people join in as an authors where they they share uh different approaches and and enhances the the approach for this ERC so that's why uh the authors uh this grow right okay so what is ERC 659 651 uh 6591 enables nfts to have their own wallets so that's the the just one liner to summarize the entire ERC if you just want to know the overall about this ERC this is it this is just that one liner it enables and the nft to have their own wallet right so when we talk about wallet what what do we mean by wallet we we I think uh everyone knows that in ethereum we have two two types of uh accounts right we have a UA accounts we have a smart contract account so when we talk about wallet is actually the smart contract wallet and in our context we name it token bound account the token bound the token refers to the nft and the account means this this account owns by or attached to an nft so in short we call it TBA token bound account so what is uh what does this TBA allow nft to do right uh TBA is a is a smart contract account it's just like an eoa so whatever you can do with EA account you can do with TBA so you can own an asset uh in this account at any asset it can be erc20 it can be 721 and 1155 if you look at this 721 721 is also an nft so that that means that an nft can own a token B account and in terms that this token B account can also own another nft so the the cycle goes on right the the the hierarchy goes on so it's it's a chain of uh ownership of nft all the way down it it can be nft or it can be anything at or any asset that can be owned by a ethereum account so besides owning assets um the TBA allows nft to also execute transaction because this is just a normal uh ethereum account you can execute transaction with it you can also deploy contract with it and it can also has its own transaction history so this means that we enabled the nft to not only be just a jpack within your wallet the the whole NL now become like a person right at like a like a person who can own assets who can execute transactions all that that that that things that you do right so it's it's a it's a powerful enablement for for nft so uh because of this a lot of people was excited to trying to put this ERC into their deps and and use them to actually uh enable a lot of new new use cases so the uh okay I want to talk about the design criteria so uh the original team they they have considered a lot of criteria for this particular uh ERC the the first one is Backward Compatible so this ERC is deliberately designed to work with all existing nft that means any nft currently on chain on any evm chain there's there's no modification to the to the to the contract needed so by default all nft in existence can has already have an account so that is by Design okay the second things about uh the the the design criteria is that they has to work uh well with the existing platforms like openc metamask e scans yeah because um as I mentioned just now the token bound account is just a smart contract account and that is a account model that is well understood by all this platform already right and it is uh designed to be fully decentralized uh nft has full custody of the TBA yeah so that's just a a brief overview about what this uh YC is about so next I wanted to uh show you a little bit from the visual visual perspective how how can you see uh the the the nft right okay give me a second uh all right um okay I want to show you this page right this page is I think familiar to many people this is openc and this is the testet this is in goalie um okay this is the artwork created by one of our uh e pinank member okay I uploaded this nft uh to uh to one of the nft contracts and then I show it in openc here and this is just a normal NFD uh but I have actually trans uh use this nft to create an account to deploy an account and I also send two nft into that account so how do you see it there is a button here and when you click on it you will see there's two additional nft here right under this collectable that means this original nft this one now owns these two and besides owning another uh another uh 721 uh nft you can also own assets that means you can have uh ethereum or any ERT ERC uh standard uh token that uh in existent you can actually send it over to this uh this uh uh TBA the token bound account right so so this this means that this particular main nft now owns assets plus also owns the the the tokens you can do that so if you take this URL you open up a new tab and you replace this with uh token b.org right so this is this is a site created by the original authors and you will be able to see that uh uh this explorer that was developed by the um by the token bound team and they have this they created exporer to let you visualize what you have uh in your in in your nft so you look if you can see this account this is the token B account address that belongs to this nft itself right and also you can see uh the this nft also own this asset 001 e so this is this is this is the the the whole thing about this ERC it gives this AR uh nft the ability to own additional assets yeah so um back to my slides um I will cover some of the use cases so why do we want our nft to custody assets why what what what is the significant of it right what benefit does it bring right uh okay the first one uh is airdrop right so we we we use to airdrop to an account right a normal account but with this ERC you can actually air drop something to nft so by by by having this nft uh all the nft in uh by having this ER see all the nft in existence by default already comes with an account so you can directly airdrop any tokens to an nft because by default every nft has an account so imagine last time when you uh are planning for an airdrop you are you are collecting all the dynamic uh um addresses from from the owner right so instead of doing that uh you can actually uh directly compute the nft address and directly air drop those uh tokens into the NFD uh TBA account so it it simplifies the entire air drop processes right okay and the other uh use cases is that now you can log in as a nft um we used to log in using our our own uh account right and using metamask or or that kind of things but now you can use the nft that you own to represent as yourself right uh you can imagine it as a as a character that belongs to you probably you can have a maybe multiple characters that represents you for for different scenarios right but let's say you a game when you are a gamer you can use use one of your game nft to be yourself and login using that particular nft but when you are at work right you join certain Dow right you can use another nft to represent you and use that nft to login to be your to be you right so this this is another of the use case because we cannot do this earlier because nft is not an account but now nft is so uh the third use cases is that um um probably in the scenario where you have a vault and the vault is generating some U yield for you over time right so uh we used to be uh joining certain Vault using our own address let's say for example and we have collected uh quite a number of use uh over time right and and over time right what what happen if you want to sell or transfer those uh uh yield that you collected in the vote to someone else so we used to just make a transaction from our own account to the other uh person who wants to buy it from you right but now that you can use nft to represent yourself you can use your nfty to join the Vault and ultimately all the elds will go under the nft and you can later sell your nft to another party and automatically whatever comes under that nft will be transferred over to the new owner so you don't you don't really need to sell your account uh by by sharing your private to the new buyers because you you you can you can transfer the whole nft ownership to the new buyers and you keep your own private key to yourself okay um the fourth uh use cases is that gaming profile so imagine you're a gamer you join uh you are very good in gaming and you collected a lot of armors um Weapons Under you right in the past uh all those goes into your your address your account but now you can join the game using an nft and all those uh weapons uh are mer goes under nft and you can actually opt to sell your nft by by directly transferring the nft out to the new buyer and everything go under the nft will will go in one shot so so so this is why it is it is very powerful um you you can't do this before this right uh we can we can do the same thing for social media you can you can build your portfolios or reputation in your social media and which comes with an value and you can transfer that value to to a buyer and you can also use this mft to sign in as as a as a as a signer for a multi because NF the the TBA the token B account is just a smart contract account you can use it to sign an nft might and you can also use it to control ens name so these are just a couple of uh use cases that um that uh this this ERC enabled right so I'm going to uh stop here and and if you have any questions you ask because uh whatever comes next is more for technical people or for developers is there any question I think you can unmute yourself if you want to ask question how does NST sign messages um you are using the token bound account that attached to the nft to sign messages the you okay the question is related to what tool you use to sign or or or does my answer just now answer your question yes the the token bound account is just a smart contract account uh you can imagine it it's like your 4 4237 account right and you can use your 427 account to sign transactions it's just like your UA you use metamask to sign the transactions but you can also use uh um um uh the regular tools or or your codes to connect to that particular token bound account to make a transaction uh that okay it okay it depends on what you want to do with this ERC for for sure this is an additional uh work that uh or or additional things that your depth needs to handle but do you the I think the qu the right question to ask is why do you want to adopt this particular ERC you would want to adopt this for certain purposes right so you you if you have decided that this particular features is needed within your depths um definitely you need to conform to the the standard defined by this ERC and of course that will add complexity to your dep so it all boils down to what you want to use uh ERC 65514 right there are all these uh use cases right um uh let's say there's a game that wanted to use this 6551 as the as the as the mechanism for them to to hold a gaming profile right so of course this particular gaming uh contract will add complexity because they want to they need to be conforming to this 6551 uh proposal um I would say uh of course it will definitely add complexity but uh that is defin uh that will benefit you because that is the features that you want to add into your deps um is there any other question H okay all right um let's talk about the proposal itself right so how does this ERC 6551 enables any anity to own other asset how how do they do it what was The Proposal about so the proposal involved three parts uh the registry there's a registry that they are proposing and there's a account interface and there's also um proxy so by combining all these three the enabl the nft to own an asset so let's go deep down into it okay this this particular diagram should be very familiar with if you have uh read some of the materials uh online about 6551 so this summarizes the entire uh parties or entities involved in the entire flows right so let's look at the the the left hand side so we have the regular nft uh here 721 NF here the contracts so this is one contract a this is one contract B and contract a has has a token 1 two 3 contract B has token 456 so as usual this contracts uh this token belongs to certain users it can be belongs to certain users and this user account uh most of the time is EA will own this uh token right and as part of this this until here these are the the regular things that everybody is familiar with right but under this proposal the uh the ERC proposal they are they are adding this registry there this registry is a is a is a contract that uh allow nft to deploy a token Bond account the the the accounts here account ABCs here these are the token bounce account so the registry can actually create uh all these accounts um the the the the token owner can instruct the regist to create all this account this these are what we call TBA and but this TBA is just uh itself is a proxy it's not the actual um account implementation the account implementation is here so you you can imagine that um the the real account contract sits here at the imple implementation part but what this registry creates are just proxies to this real implementation that means you have this account a if someone make a call to this uh account a the call uh will be redirected to the actual implementation right so if you look at this scenarios right uh we have one B implementation but this B implementation is being proed to by two different TBA so you can have the same implementation being shared across two different tbas so this is this is possible this is the whole purpose of this TBA the TBA is supposed to be lean supposed to conform to uh the the interface for is is Lan is a proxy to the actual implementation at back but this TBA is itself a smart contract wallet does that uh make is it make sense or is there any question okay this this users here owns the token here but this token owns the the token bound account here so indirectly this user controls this token bound account so if this user transfer out the ownership of this token to somebody else anything under this token this this this token anything under it will go together to another new buyer new new person yeah let me uh let me move on okay uh this is the the interface uh uh defined by these erc's right this there is a registry interface what this registry does is that it allows you to perform two actions one is to create an account when when I say create an account means this action this registry can be called by uh a person the owner of an nft to deploy an account so when you you can do that by calling this method and putting in the implementation address chain ID uh token contract and ID these three parameters chain ID token contract and token ID will uniquely identify any nft on any chain just these three parameters and you will have a seat parameters where uh where you can Define different values uh this seat allows each nft to own multiple token bound account so that means uh okay if I go back to the slides right um you look at this token this token has two line here so this one nft to nft owns two token bound account how can it own two account you can own two account by putting in two seeds different seats you can put zero for the first account and then you can put one for the next account then then it enables anity to have unlimited number of account right and this init data is just something that you send in to initialize the the token Bond account right uh the second function is uh is just a view function it allows you to retrieve uh the to compute the N account address so what the the account address for okay let me go back to this the account address for this token is is deterministic that means you do not actually need toate create this account but you can already transfer uh asset into that account so that that means today let's say today in your wallet you own an nft you actually do not need to create any account you can directly send any asset into the TBA address it the TBA address does not need to ex this it can be in a uh counterfactual state but you can already transfer token into the account but only when you wanted to perform certain actions with it then only you need to create the account by calling the the function inside the registry so I hope that makes sense uh to you so the the as part of the uh the the ERC they are proposing a Singleton permissionless and immutable uh registry so that that's their proposal but they they are not stopping you from deploying your own custom registry but uh this this this proposal is uh uh stressing that the importance of having a Singleton one uh because uh that promotes the trust among all uh parties who adopt this particular ERC so that's why we have a can iCal registry if you look at this link here the the the project team already pre create all this registry in all this chain here you can notice that they're all having the same address uh account because this registry contract is created by uh the create tool of code so they can all have the same address across different chain so if you developer in another chain that is not here um you can actually take the regist stre implementation from prub and you can actually deploy it to the chain that you want want it to exist but you can also work with the project team to get their help to deploy this registy for you in the chain that you you are working on so for now the registry uh address for this uh for the current state all sit here but uh please be reminded that this these addresses are going to change because this ERC itself currently is in the review state and um right uh and and there's a lot of changes been added and made uh every now and then so right before it is finalized uh the project team will actually redeploy the the canonical registry uh contract to the chain and this address will change so you can use this address for for your own testing But ultimately when they they finalize the the ERC this address will change you just have to take not of that and uh okay as I mentioned uh this this this method create the TBA but this TBA is just uh ERC 11167 proxy it's just a proxy uh that that delegates all the execution to the actual implementation which which mean this right this is just a proxy and all the calls to this proxy will be delegated to the actual implementation here will be executed the logic will sits here but the storage s sits here okay um okay it can be deployed to any chain and a known address this is what I mentioned just now and this this particular registry interface also support cross chain compatibility so you can have a scenario where you have an nft in one chain but that nft is controlling another TBA on another chain so imagine you have n on ethereum main chain main net but that NL has a utility on let's say optimism you can actually uh use the nft on main chain to do a vote let's say you you are part of the Dow you can do voting in another chain like like for example optimism yeah this is possible and this has already be implemented in their uh sample implementation in the GitHub you can have a look at it okay let's move on uh another interface that is uh proposed by this ERC is the account interface right this account interface refers to the interface that needs to be implemented by this account here okay it has a couple of uh functional method the first one is receive the receive is to receive the E sent into this account token is to get uh give you the information about the original nft that owns this account so it give you the chain ID it gives you the nft contract address and it gives you the token ID so this three uniquely identify a single uh nft okay the the there a meod cost state so this state is something that um the marketplace or the the dep needs to use to um to to indicate there are some State change within this account itself so the the the the purpose is to prevent fraud I I will cover the fraud later in the later slide so there are some scenarios where you can rot another person you uh if we do not implement the the relevant check that is needed and there's a method called is valid signature so this is a new enhancement we used to have a something called owner method here to indicate who is the actual owner of this account but over time the proposal changeed now they they become is valid signer so uh as I mentioned here this is is valid signer is here uh to make the whole proposal more generic to be able to support some other uh NFD standard that is that doesn't have a a single um owner so when I when a single owner a canonical owner that when I say single owner means if you look at 721 UMC 721 um uh spec right uh each nft is owned by just a single owner so that is very clear cut but if you look at the 1155 contract right um it's a semi funable so each token ID could have multiple count of it there multiple supply of a single token ID and they can belongs to different owners so it doesn't it doesn't fit the Paradigm of this this particular proposal because we need to be able to uniquely identify who is the owner this token who is the owner of this account account we cannot have multiple tokens owning a single account so the reason why we call this token bound account because it has to bound to one token not multiple token so so that's why that's why this particular uh method signature is is uh very important uh it opens up the possibility for other other specs to adopt this YC as well uh yeah um I think I I don't want to cover the rest uh let's save some time and um okay they also proposed another executable interface which is also something new uh They just added in like a couple of weeks ago um uh they want to enable the account to be able to execute uh any arbitrary uh execution right so uh this execute used to be inside here under the account but they extract extracted it out to to become a s alone uh interface because um because there is uh today there is not a uniform uh method signature for call for ex for calling execute on a smart contract account so the if you look at uh the noses safe right they have their own standards of executing if you look at others other 4337 let's say you have another meod signature for execution maybe you can look at arent maybe arent has another uh execu execute uh method signature so they are all different different and there's no standardization today so that's why for ERC 6551 today we are they are they are proposing this signature this methods in nature uh uh and extracted it out is and into a separate interface so um as part of the spec you must Implement one execution interface not necessarily this one you must execute one but it can it can be this one yeah all right uh if you developers uh there are a couple of things you need to take note um you have to be aware that the nft can be deeply nested nft can own another TBA which in turn can own another NF can own another TBA again and the cycle goes on right uh if you if you if your depb uh is do not want to support the deeply nested nft you need to build the custom logic into your account implementation right and ownership cycle um is something that you need to take note for certain Marketplace let say for example um you your your your Deb uh do not want the nft to be burnable right so when I say uh ownership cycle means an nft can own nft a can own tbaa and this tbaa can own nftb and this nftb can own another tbab but let's say the owner of the top level NF transfer the ownership of that nft to tbab so that become a cycle right so when when it become a cycle that means nobody owning anything so in in in a sense that uh you are actually that that transfer action is actually burning that that nft itself so burning not only the nft and anything comes under the nft that all they all burn inaccessible later so if your d uh do not have the need for burning you need to particularly check uh the transfer action uh make sure that it is not transferring to any of the sub tvas uh okay fraud is something uh kind of like possible uh if we are not careful so imagine that you you have an nft and under that nft you can own a lot of other nft and also assets and that your then your nft is very valuable so maybe you decided to you are maybe you are malicious person you want to uh sell this nft in the marketplace but you want to rck the buyer right you can actually list it in in the marketplace and wait for a buyer to to make a make a purchase right so and then you can actually uh work with the miners or the validators or you you you you you craft a a flashboard bundle to front run the you the the particular transaction the purchase transaction right before the buy the buyer purchase your nft you actually move all the valuable asset under the nft out to a separate account and what that buyer eventually gets is just top level NF and nothing under underneath it so you can do actually do this kind of fraud today uh using this uh ERC uh if if the if the marketplace does not actually check for this so that's why um uh I did mention a function called state right under the account interface uh that State uh can be leveraged by the marketplace to make sure that when somebody leas the nft for sale you need to record down the State and make sure when we perform the transfer the state is still uh there's no change of state in that account yeah and the last one is uh also this is similar to the front one so you have to uh make sure that uh for for those account implementation that uh approve you you that has some approval mechanism built in right so you um you can have the account implementations uh approve uh other address to perform transaction on the TBA not only the owner of the TBA can perform a transaction the owner can delegate that uh rights to another party to do the transactions this is a valid scenario so um um if you if if the marketplace wanted to be safe you need to check whether uh the owner actually delegate the execution right to any other parties before you make before you do the the to uh the token transfer yeah this is also um security consideration if you do not want your your Marketplace user to get wrecked I mean uh Rock by Rock by the the original nft owner the Malaysia user okay uh this is worth mentioning um the cross chain nft I mentioned it briefly just now so uh an nft can exist in one chain but can can also have the TBA across a different chain so this is uh implementation dependent so some of the dep uh can use have certain have the use cases like this they can use the bridges uh or some message passing mechanism to to allow the the cross-chain communication so uh uh out of box today uh if you go to the GitHub to look at the the the source code right uh out of box it is already supporting op stack so that means you can have an nft on ethereum main chain uh but this uh nft can actually make a transaction to a TBA in uh any op St so um uh it's a Crossing execution and so it's already supported out of box yeah okay uh let's briefly talk about the ecosystem I think I don't have much time uh go fast uh there's somebody's uh called Sky SK uh he has uh put together um the ecosystem map here so you can see a lot of project starts adopting this uh standards because uh it is uh very different from what we have in the past and it can support a lot lot of use cases right so one of it is a nosis noses guil uh nosis guil is a is a is a open source uh tools to support uh Dow right they actually adopted this uh ERC 6551 as part of their Mac offering their Mac offering allows uh uses standard to allow nft to hold the Assets in the down um another one is lens protocol I think everybody knows about lens uh lens uh built in support for 6551 in the version two uh yeah to to enable uh people to to enable the profile the the the the lens profile to hold the the means or the collects under the TBA rather than under the original uh address the owner address to to to ease the future transfer of those uh assets uh open F open f is a wallet as a service uh uh uh company they are combining uh 6551 with 4337 the account extraction uh tools uh they offering their wallets uh uh with the feature of 6551 uh pinata pinata uh build uh uh application uh that help us uh better visualize our our tree tree of ownership for for nft and the tbas so if you're interested you can go to this link here to see uh the the tree of ownership yeah uh adoption uh this is the Dune analytics I just pull this yesterday so if you can see the proposal starts to become uh Act uh somewhere around may this year so a lot of discussion a lot of people got to know about this uh 6551 and they are excited a lot of people start building application using these standards uh as of yesterday there are about 12,000 um ERC 6551 account being deployed on all the evm chain so there's about thousand over transaction happening there so this number continue to grow uh uh a lot of people starts uh uh to think about how can they uh adopt this into their protocol I think that's it um uh that's this the last of my slid is there any questions you can unmute yourself um to ask no question okay thank you everybody

Automatic transcript — names and jargon may be misspelled.