ERC-6551 Token-Bound Accounts enable NFTs to function as wallets by binding ERC-20 tokens to specific NFTs through a registry smart contract that generates unique wallet addresses based on the NFT contract address, token ID, chain ID, and salt. The registry creates accounts by deploying a base account smart contract and binding it to the NFT, allowing the NFT owner to receive, hold, and transfer tokens through the account's functions. This system ensures that when an NFT is transferred, the new owner automatically gains control over the associated token-bound account and its tokens.
Implementing ERC-6551 Token Bound Accounts | Smart Contract Tutorial
Added:this tutorial is for educational use only it is not authorized nor approved for any other use okay let's get this show started shall we but first let me ask you for a quick favor hit that subscribe button and smash the like for more amazing content like this the first thing that we are going to do is we are going to discuss how is the registry smart contract interacting with the account smart contract so we need to understand that there's a link between the two as far as the function goes there is the need for the registry smart contract to inform the blockchain that a new token bount address a token bound account has been made has been registered which means that I have to tell the blockchain xyc account number has a particular function okay has the function to receive erc20 has the function to send ERC 20s Etc it's no different from any other contract that receives or sends erc20 because we are implementing an interface to interact with the erc20 token okay the only difference is is that the permissions inside the smart contract are bound to the owner of the nft the magic is that if I send the nft to someone else the new owner the new wallet that is holding that nft should have the rights to execute the functions on the ERC 6551 account smart contract so we deploy One account smart contract that has I'm going to say the identity on the blockchain it has all the attributes that the wallet can execute can perform as far as the send the withdraw and all that so when we interact with an ERC 6551 account we are interacting with the smart contract every time that we generate a new account per nft ID we are quote interacting with a smart contractor that's basically how we do it okay to summarize we are doing a quick whiteboard so then you can understand the logic between the two the registry and the account smart contract we are deploying the ERC 6551 registry smart contract we are also deploying the ERC 6551 account smart contract and once we get those two then we can start generating the nft token bound accounts okay all right let's go ahead and let's get this show started okay let's get started right so we got a nft collection smart contract this will be an ERC 721 right and when we Implement token bound accounts what we are looking effectively is to bound a wallet to the tokens on the ERC 721 okay so we are going to effectively Implement an ERC 6551 account once we implement the ERC 6551 account I can send request to obtain information to the ERC 721 why because we are going to be interfacing to the ERC 721 nft collection smart contract what information do I need to obtain from the erc721 the owner of n nft why because if I need to withdraw tokens from my ERC 6551 account I need to know that I'm the owner and I'm allowed to do that okay awesome so this is literally what we're doing we're just adding a wallet to an nft which means that I need to be able to interact with the ERC 721 right so I need to be able to talk and hey give me the owner of this nft ID is the owner matching the wallet ID that is connected is attempting to perform the call is that wallet matching the message sender when we are talking to the account smart contract and if it is then allow it to okay in order for me to to create this account I need to bring the registry smart contract okay so we are going to implement an ERC 6551 one registry what what is that doing it's generating the token address and pushing that onto the blockchain and registering that account onto the blockchain okay so which means that I need to tell the ERC 6551 what's the contract the nft contract that we are going to be working or interacting and building those accounts which means that this smart contract right here let me go ahead and delete this which means that this smart contract needs to have a reference to the registry so it has to be providing the information well at least it should provide the attributes to the registered smart contract so then I can build those token bound accounts when I initialize this register smart contract I am going to be providing the nft collection and this will be the ERC 721 contract okay so I'm going to be providing that address every time that I register new accounts okay again this will be quote the registration contract any time that I need to build a new account I am going to be making the call to the registry to create that that account so the moment I do that I am going to be providing the address of the smart contract I am also going to be providing the nft ID so I need to tell the smart contract I am going to give you the nft ID why we need to give this information because when we attach the registry smart contract when we attach that smart contract to the ERC 6551 account right when we attach that the nft ID will be one of the attributes it's going to make that call to the Token smart contract and it's going to let's say for example ask who the owner of nft 10 is okay if the nft 10 owner is message sender message sender what is message sender it is the wallet or it is the user or the trigger to a function so it's basically making the call it's actually talking to the contract and executing calls so I am going to be sending a wallet address I'm going to be sending an address as my message sender If the message sender is in fact the owner of the nft ID right so if we have the nft ID that we are interacting on that Wallet account I am going to let that function finish and there's another item that I have to populate not only the nft ID also going to be populating the chain ID what is the chain ID the chain ID is the integer the value of the blockchain that we are interacting so every blockchain every main net test net has a chain ID so we are going to basically provide that chain ID and what's going to happen is one we once we provide those values and there's two other values that we have to work with which is the salt ID and this is not the ingredient that you use in food this is a value that we provide that will make the identifier unique that will make an address an object an ID anything is going to be unique it's going to be based on uniqueness okay so this will be the salt ID let's focus on three items smart contract and if T ID and chain ID so every time that I want to create a new token bound account I have to send the call to the registry you know to create the account and I have to specify those parameters once the account gets generated every time that we interact using the wallet address so let's say one A B C D whatever is that wallet address every time that I interact with that wallet address it's literally going to look for those parameters why because the moment I provided this information and I register that using the registry there is a moment when we convert this into bite code when we hardcode this in which we combine this into bytes into bite code so by by me providing all this information when we make the call I am going to be generating a unique ID that once we execute calls using that new token bound account the blockchain is going to be able to interpret the buy code and reference all those values is going to be able to translate that to all the values that I provided so let me go ahead and do one thing here I'm going to remove all this let me clean my whiteboard okay so how do we build that token bound account we are going to provide the ERC registry 6551 registry we are going to be providing the ERC 6551 account contract this is not the token account that we are going to generate per nft ID uh uh uh uh when we build this initial application when we build this ERC 6 5 51 we are going to be deploying two smart contracts that are basically base smart contracts which we then will use to build the token accounts it's not like I have to deploy a new contract a new account contract every time for every single nftd absolutely not what we are going to do we are initially deploying those two smart contracts then I am going to obviously obtain the smart contract address for my base account it has no information about nfts whatsoever okay listen carefully we are deploying that account smart contract we are going to obtain a contract address what is this contract going to do for us this is where we provide the available functions to interact with that quote wallet okay so this is where I am going to enable erc2 transfers we are going to be able to hold ERC 20s Etc what else can we do with this account smart contract we can also accept custom erc20 you see what I'm going why because this is the contract that we are mostly going to be working on this tutorial I am going to be making modifications so the account the wallet that we generate out of this contract has many functions and can accept many erc20 tokens how am I going to be able to accept many tokens well I have to somehow provide the token address the erc20 token address to the account if let's say I want to store us DT on the nft what am I going to do I need to build a function that talks to the erc20 interface but then specifies the contract address of usdt so in this case I am going to call send I'm going to call this send custom right check this out I am going to be sending custom erc20 tokens I'm going to create this function called send custom in the statements I am going to invoke the ierc 20 which is our interface for erc20 tokens then from there I am going to do what I am going to transfer I can call now functions inside the erc2 interface right so we can do transfer we can do burn we can do all kinds of things however the most important thing here let me change the color the most important thing that we need to do here is this ic20 interface must be bound to the usdt address okay and this will be the usdt contract or any any other token smart contract even your own custom rc20 token okay which means that now I have to build this function to allow all this to also accept so the wallet can receive can hold and can withdraw can remove those tokens out of the the token bound account right which means that I'm going to be building this to summarize that ERC 6551 account it's going to dictate what can you do with that wallet okay so we have to work with the account and we have to modify that account smart contract to do custom things and in my case what I'm going to do this tutorial I'm going to allow it to accept other erc20 tokens not just the native token okay when I'm going to be deploying the registry smart contract this account this smart contract address that we obtain when we deploy the ERC 6551 account base account I'm not going to provide any parameters it's literally a bare account that we are just going to deploy run get the address now that that contract is live on the blockchain on the registry smart contract I can start building those nft wallet accounts or token bound accounts and as I mentioned nft the parameters that I'm going to be providing are going to be the nft ERC 721 contract that's the contract address I'm going to be providing that the token ID the nft ID the chain ID and the ERC 6551 account why because that's how I'm going to tell on the registry smart contract hey I want to generate this new ERC 6551 account based on this smart contract and what features does the contract has for that Wallet account and then once we do this then we can go ahead and use and take advantage of the functions that we are going to be coding into that 6551 account smart contract okay it's like me building a base a blank account that has all the functions and then I'm going to start using it to build accounts on top of it okay it's very straightforward you you're going to see this and it's very very straightforward one last thing before we go ahead and deploy the smart contracts and we interact with that account which basically is what I'm going to be focusing on go ahead and remove all this how would the account be generated at all right and we mention we got the ERC 721 contract address that's one of the values that we provide we got the token ID or the nft ID we got the chain ID and we got the the ERC 6551 account the one that we are going to initially deploy we have all those parameters the moment I provide those parameters to the registry smart contract the registry smart contract has an interface and that is the IRC 6551 that what that is going to do is going to generate it's going to build that Wallet account and it's going to be building that Wallet account because it's going to be using the bite code okay it's going to be using basically machine language is going to be using code on the blockchain when you compile a smart contract before you de deploy it has to be converted into by code looks it's basically hex in values it's all hex what the blockchain is able to read is by code which means that I have to grab all this information and spit it out into an address I have to build that address so I have to build that wallet address and it has to be converted into buy code before it's sent and stored on the blockchain okay how is the contract address generated I think I'm going a little bit more in depth not just building nft wallet I want to give you even the lowlevel information okay so the moment that account that address which is just like a wallet address that wallet address gets generated it's using a up code it's using a library that builds those contract addresses when you deploy a smart contract right when you deploy let's say you deploy an arc you know any any smart contract you write to the blockchain you deploy a smart contract there is an address that is generated right so there is a smart contract address that gets generated during the deployment that ladies and gentlemen is the blockchain generating that smart contract address and it's generated using by code and is using op code there's a module that we use in the 6551 to generate those addresses and it's the open seing create two so it's called the create two you are going to see don't worry you don't have to actually write this all you have to do is import it and there is a function that we are going to go over that actually builds the Wallet account which means that even before the contract gets generated on the blockchain we are able to obtain what the address is going to be why this is very important you might be wondering why do I even care if I need to know the wallet that is going to be generated beforehand well ladies and gentlemen the reason why is because there is a read function there is a function to view on the registry smart contract that I not necessarily have to deploy in order for me to know the wallet address I don't need to provide this and deploy in order for me to figure out what the wallet address is going to be instead there is a view function that allows me to calculate and generate the values without actually deploying it you see what I'm going why is that so important is because with this I can effectively build a front end and just by passing all this information during the rendering of the front end I can ask the registered smart contract give me the wallet address and I can display it even if the user hasn't built any nft account I still can show the user what the wallet address is going to be regardless if I deploy it or not see how cool this is now I do have a function on the registry that allows me to just provide the information and the registry is going to give me the wallet address for any nft okay so that is very cool which means that I can use that to to do view calls I am going to be building a front end and every time someone Clicks in nft ID I should be able to generate that address on the Fly and show it on screen if the user decides to build the account he can click create account and they are going to create the account on the Fly and the wallet is not going to change because we are already pre-calculating the values the values I'm going to be providing those values beforehand very cool so let's go ahead so now that you know now that you know how this all works registry and we got the account build a account and then we use the account to deposit the tokens interact tokens okay so now with the account I can interact I can do everything and again if I transfer the nft to someone else the smart contract the registry smart contract is binded it's attached to the nft smart contract address which we provided when we initially generate the token ID that that wallet ID okay let's go ahead and let's stage and code the smart contract let's build the smart contract let's build the account smart contract and let's modify the account smart contract so that we can use custom erc20 tokens let's deploy what I'm going to do I'm going to be deploying the nft smart contract I am going to be deploying the token smart contract a test token so that we can try and see if we can deposit and withdraw test tokens as well okay so let's go ahead and do that Okie doie so there you have it this is the ERC 655 one registered smart contract what we are first going to do I'm going to give you the information straight out of the EIP this is the ethereum Improvement proposal right so we have the ERC 6551 and what we have to work with I want to show you real quick if we scroll all the way down here we go this will be the interface okay so this is what I want to show you so we are going to work with the IRC 6551 register this interface is the one that I was explaining to you that will generate the token bound account okay so if I have this function right here this function to create the account is going to require the following the implementation what's the implementation this will be the based account smart contract as I mentioned we are going to be deploying the account smart contract then with that account smart contract then I can build token bound accounts okay with the salt I can build a deterministic address it's basically a way for me to generate the uniqueness of the address by providing the information by by providing the salt okay so the chain ID is going to be the blockchain that we have this smart contract deployed okay and we obviously have to provide the token smart contract and this will be the nft smart contract as well as the token ID okay let's go and take a look at the contract itself okay so what am I doing importing the create two and as I mention at the end of the Whiteboard session the create to allows the smart contract to pre compute to pre-build the address so we know what's the account address of that that's going to be assigned to the actual nft wallet or in this case to the ERC 6551 bound so with the create two I can generate compute the address that will be the ERC 6551 token bound account let me show you the app okay so I'm going to show you the app so on the app if you can see over here let me see if I can scroll in there we go so if you can see right here this will be the token bound account okay so how am I able to click every nft and create the this address on the Fly and the reason why is because with the create to and the registry I have a function that allows me to view without deploying the address or in this case deploy the token bound account okay which means that I can pregenerate that address and deploy this because I can be calling the blockchain and I can be performing that view and obtaining the value and then I can pass that to the front end okay beautiful beautiful okay so let's go ahead and take a look the registry okay let's break it down with the registry first let's take a look first at the function that actually creates the account what is asking for us as the arguments is going to be the account contract this will be the implementation address of the account smart contract and you are going to see this is the ERC 6551 account okay so let me go back we are going to be providing that address right because we have to deploy the account and then with that I can start generating my token bound accounts I am going to be providing the chain ID this will be the ID of the blockchain the nft smart contract address the nft ID and the salt and salt if we decide not to use a different value for salt we can leave it as in zero okay so this will be if if we want to be more deterministic as far as the address I can play with the values in salt but in this case I just want to generate them randomly okay so in this case I am going to just provide zero here what that's going to do is now going to generate that code that will be used to build the account okay check this out what we are doing is we are using this creation code this interface creation code if you scroll down here we can see it right here what that's doing that is basically generating in memory the byte value that will be then used with the create 2 to determine what will be the account value so this address is generated with the create 2 basically the create to builds those addresses it it computes the address value okay with the creation code what we are passing this will be a proxy contract that allows me to interact let me show you the IC 1167 so this will be the contract proxy that allows the smart contract to communicate to other contracts as far as the proxy call so a proxy basically is me making a call on behalf of someone else say I send the call to this particular contract to the account then the account is going to send a call on my behalf to the destination contract all right so let me go back and then all with this information once I generate this encoded packet which basically what it's going to do is going to spit all the values and it's going to grab the attribute to determine what the account address is going to be which is quote the wallet okay so if we go back let me go onto create account we can see right here that once we obtain this by calling this creation code and and run through that then I can determine what the account address is going to be which is going to invoke cre A2 it's going to compute the address we are going to be passing the salt and like I mentioned we leave it at zero so then we are not going to build something that is going to be deterministic it's just random and then we are going to be passing the code okay so the code will be the value that we obtained when we did this creation code okay beautiful now I have an if statement that if the length is not zero then return to me the actual account value because we want to to know okay and then we are effectively going to deploy that account with the create 2 deploy function okay good so far awesome all right now we emit the event so we have that on the blockchain as an emit event when we execute every single function every single call to create an account when we click and create that function this will be done by the end user we are going to incorporate this onto the front end okay beautiful so now check this out now that we know when we pass all this information to the smart contract we know how we get the wallet address now let's work with the account itself okay check this out now with the account and you can see here that I'm invoking the IRC 6551 from my GitHub repo okay because this will be the implementation interface that we are going to be using and then the ERC 6551 bite code which B builds those bite values with the function that we saw previously the registry right so we're going to go back into the registry when when we do this we are effectively building the bite value that we are going to be passing when we build the account okay so when we build that account we will be obtaining that through the bite memory okay and you can see that is internal which means that is something that I'm going to be calling out of another function this is internal this is something that we are not going to be communicating with externally okay so this is internal for the smart contract to use with my other functions okay beautiful so now what I'm going to do I am going to show you the account itself okay so when we work with the account this is literally what I want to do with that wallet address okay so I want to allow transferring erc20 tokens and transferring the native token using this account smart contract which every time that I generate a token bound account using this account smart contract then all those functions that I'm going to be writing and I'm going to be adding into the smart contract are going to be available to be interacting with Okay so let's take a look here I am going to be providing the following okay so if this is an internal execute call to this if we want to know more about this one um I believe it's going to be inside the account interface so this is literally in the account itself in the base EIP ERC 6551 account contract okay there is a function that allows to execute that will basically send native tokens it's going to allow me to send the native default erc20 token not this is not custom this will be the native token to the blockchain that we are deploying this smart contract okay so let me go ahead I'm going to go real quick because we are going to be deploying this and then I'm going to be showing you by dropping some test tokens and we'll do the withdrawal and all that okay so check this out I'm going to code the first function the first function is going to be send what am I going to allow to send using this function it's going to be the native token on the more contract so in this case if I have e tokens if this was deployed on the ethereum blockchain I can store the native token which is eth onto the smart contract and I can then send to other wallet addresses the balance that is inside this smart contract okay which is awesome but first what do I need to make sure okay I need to make sure that the owner and this is not the owner of the smart contract this is the owner of the nft token ID how do I know that I'm going to show you the owner function this owner function check this out this owner function what is going to do is going to check if the colar if the colar matches the owner of the token ID that I'm interacting when I'm using the account so let's say I buil this account that's token bound account for nft ID number 150 right so what I'm going to do I am going to obtain who is the owner of that token and if I am the one who's making the call and I'm the owner I'm matching whatever the IRC 721 token smart contract gives us back as the value as the owner of that token if that's the case I am effectively able to then proceed to transfer the tokens whatever the tokens are inside this smart contract okay or this particular account okay so how do we see that I'm going to show you right here so I have the message sender owner is if I'm the owner of the token of the nft that is bound to this account then go ahead and verify what's the balance okay what's the balance on this smart contract for Native tokens and then I'm going to execute the two transfer and then amount I'm going to be able to send that to whoever I want okay so if I want to send it to my metamask wallet or any other ERC wallet I can pass that as the value of the address okay and it's payable because we're dealing with the native token okay awesome now here's the custom so when I working with a custom erc20 token what did I had to do in order for me to enable this on the token bound accounts let's take a look in here so what I'm doing is I'm effectively importing the safe erc20 and the ic20 interfaces so those interfaces are going to allow me to interact with erc20 tokens on the account okay so on this particular account I'm going to be able to do that which means that I am going to be passing on the function this function I wrote it myself I wrote it and I added it to the smart contract what I'm going to be doing is I'm going to be passing the destination who is going to receive the transfer of the tokens I am going to be passing obviously the amount and finally I am going to be passing the erc20 token smart contract that I have as custom let's say I have my own erc20 token a custom erc20 token and I aird dropped I deposit tokens onto all my accounts for every single nft I have a token B account I decided to cons build a loop let's build a loop and start sending those tokens to every single wallet that gets generated because again now with this function right here let show you back on the registry with this function I can pre determine what will be the address token bound account for each nft ID which means that I can call this every single time with a for Loop and auto send X amount of tokens in the function in the call okay awesome so let me go back let me show you because I can drop custom erc20 tokens onto the smart contract now I have to be able to determine if the balance inside the contract for the custom token smart contract address that I'm passing as the argument if there is enough balance in the smart contract so that we can allow the user to withdraw the funds okay to remove the funds out of the wallet out of the ERC 6551 wallet okay so we have this which means that I can now send any erc20 tokens onto the 6551 account or why because if I need to withdraw out of the account I just pass the token address as the argument and then I should be able to query that token smart contract and determine if I have the balance if there's tokens on the bound account I can use those token and I can send those tokens out to whoever I decide to send to okay beautiful now nft info so this is very important with this function I can determine on the token bound account to what token ID is this account attached to and this is very important why because with this I can confirm that ID number three belongs to this wallet or this wallet this token bound account is attached to token ID number three you see what I'm going let me go back if I use this information I can use this view info to build a front end that could confirm that the nft ID matches the token bound account for example I can confirm those two values aren matching and if I need to do a pre-authorization beforehand I can use this to validate that the token bound account matches the nft ID that is attached to and we are trying to make those calls beautiful so here's the thing I have the owner like I mentioned I'm going to be checking this is not the owner of the account this is the owner of the token smart contract remember the account owner is whoever owns the nft there's no difference here okay which means if I'm going to be selling the nft to someone else all those token all those erc20 tokens that that 6551 account holds for that nft are no longer mine are going to belong to the new owner which means that once that owner attempts to make the call they should be able to withdraw the funds so we have this information here and all of that is internal to validate that the hash matches that the owner that the information the bik code that we are interacting with between this particular smart contract and the registry matches and all that this is internal okay awesome so let me go ahead and deploy the two smart contracts we are going to be deploying The nft Collection smart contract and let's build some accounts okay let's do that I am going to be compiling the smart contract so first of all it doesn't matter which contract do I deploy first so I'm going to go ahead and deploy first the account okay so we got the account and we're just using the virtual machine with test machine not a blockchain and now we are going to be deploying the registry let me find the registry right here now we got both the account and the registry this is the base account ladies and gentlemen again let me let me let me repeat this is not the token bound account no this is the base account which we will use to tell the registry how is the token going to behave because that's the account and all those functions are going to be available for each token B account that we generate using this base account contract we got the account all right now what I'm going to do I'm going to take the opportunity I have a test nft smart contract so I'm going to do nft Soul so bring the nft is myart contract right here paste it let me minimize this it's a normal ERC 721 is my contract if you want to know how to build NF smart contract I have many tutorials that I'm working with nfts okay so be sure to check that out okay so I'm going to control s i effectively compil the smart contract so I'm going to go ahead now and this is for the nft smart contract I just need to pass the address of the deployer so this will be my wallet address going to transact now we have the nft smart contract deployed okay so first thing I'm going to do I'm going to min nfts so in this case I have um my test contract has a maximum supply of for nfts so what I'm going to do I am going to Mint all four nfts okay I'm going to say two I'm going to pass this address okay I'm GNA minant for myself I'm going to transact and boom I got four nfts how do we confirm this let's see balance of let me pass my address we got four nfts awesome so now I can pass the token ID and should be my wallet as the token ID of one two three and four awesome so we got all those four tokens on my wallet I can build the token bound accounts so let me go ahead on the registry before we do that what do I need to pass account contract this will be the base account smart contract that we deploy with all the functions that we have available okay so we are going to be passing that now we are going to be passing the chain ID because this is a test blockchain this is not even a real blockchain just going to pass one the nft contract this will be the nft smart contract let's copy the address paste it right here and the n f ID let's build the token account for nft ID number one salt make it zero I'm going to call it and ladies and gentlemen this right here will be the IRC 6551 token bound account for nft ID number one in this nft smart contract okay this is a a view call which means that this is not actually building the interface this is just the call to determine what the address is going to be which we can use again to make the front end and display every single wallet address awesome okay so let's go back now let's go ahead and build it now that we know what the address is going to be let me just go ahead and proceed to build it I'm going to grab all the values again going to copy this I'm going to paste it right here I'm going to pass chain ID one same same information I'm going to pass the nft smart contract address paste it here I'm going to pass the nft ID which is one and salt it's zero I'm going to transact and boom we got ourselves our first token bound account awesome now with this I want to now interact with this token bound account which we already deployed this is where we deployed so I'm going to show you the return which we should see the address somewhere here here we go let me confirm there you go this will be the address that was deployed okay so we got our first token bound account how do I interact with this token address copy I am going to now find my account again want to check the account but I'm not going to deploy it I am going to load with the token bound account which will allow me to now start using those functions okay now if I paste the token bound account that I just deployed that I generated if I deploy that add address now if I go down here this is ladies and gentlemen the actual token bound account now I can use functions inside here let's see the nft information we see that the chain ID is number one collection smart contact that we deployed and the token ID let me do the following I am going to be sending some test eth to this token bound account I'm going to copy the address right this is just like a wallet eth right we're going to be sending one eth and we are going to be sending this to this address 18 is it's just going to be empty array there we go we passed and now effectively we have sent one E from my wallet to the Token bound account okay so now we have effectively passed one eth to the Token bound account beautiful all right now here's the thing how do I send from the token bound account to another wallet and let's use this wallet right here AB this one okay so what I'm going to do I'm going to copy the address and I have to return back to my wallet because that's the wallet I'm going to be allowed to send the tokens from I'm going to go ahead and send okay I'm going to say two I'm going to paste the wallet that I want to send that one e and I'm going to say one but I'm going to be passing 18 zeros because it's the same way 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 awesome and finally I'm going to transact boom we have effectively removed one e out of the token bound account now let's take a look at the at that wallet that we just transfer that one e okay there you go 101 beautiful finally let's go ahead and deploy a custom erc20 token and let's attempt to transfer between wallets okay let me go ahead into here I'm going to go ahead and deploy a new file I'm going to say usdt this will be my fake token let say here usdt Soul beautiful and then now what I'm going to do I'm going to find that smart contract and I'm going to just paste it right here and there he goes this is a base uh erc20 a very simple erc20 token smart contract I'm going to contrl s and now let me go ahead and deploy it and again it's asking for the owner of the smart contract this will be and boom we got the smart contract now let me find here we go awesome okay so what I'm going to do I am going to be minting to myself let's say a th tokens say one two three I'm going to Mint 1,000 fake usdt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 okay we going to Mint boom and we have successfully mint th000 usdt fake okay now I am going to be passing my wallet address to confirm that I do have those th000 usdt so I'm going to say balance of paste boom we got th awesome now I want to pass I want to send 400 to the Token bound account okay so let me go ahead and grab the token bound account right and you can see it once again it's not the account smart contract address the base account no is going to be every time that we generate a new token bound account we are going to be interacting with the account ABI using the address of the token bound account okay so now let me go ahead and copy my token bound account the usdt the fake usdt I'm going to now say I'm going to pass it to that token bound account this will be the address and I'm going to say I'm going to pass 356 usdt tokens 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 okay so we're going to pass custom erc20 tokens transact boom we have successfully passed now I want to confirm that that bound account has the 356 tokens usdt so I'm going to just confirm it right here boom we got 356 tokens now what I want to do Here's the final test now I want to first of all I want to confirm that this wallet address has no usdt at all okay so make sure that it's zero okay boom zero now what I'm going to do I am going to head into the ERC 65 51 account and I am going to be transferring to this address the 300 or like 200 tokens not 300 200 tokens okay and then we're going to go back and confirm that it was able to transfer the tokens to this wallet address okay let's see so what I want to do I am going to head under the account and I'm still as the owner perfect now I'm going to send custom I'm going to send to the address which is the address that we got here right the new the other wallet and going to be passing 200 tokens two 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 okay we're passing 200 tokens and now we need to pass the erc20 token smart contract that we want to transfer those tokens from right so this token bound account should have 200 tokens from this erc20 token smart contract okay so let me go ahead and find what the value is of this fake USD and let's use it here this will be the fake USD let me transact o let's take a look and see if we indeed transfer from the token bound account aka the nft to this other wallet to this wallet right here let's do it let me press once again beautiful awesome right let's end it up here you got all the picture around the ERC 6551 account and the register smart contract we know how we are going to be building those two and how are we going to be interacting on the next and final video video we are going to be building the web front end and we are going to be connecting this to a test net just like the real blockchain and will generate token accounts as if I was the user if I just connected my mamass wallet I should be able from the web to connect this and interact and send and receive tokens straight onto my nft all right I hope you like this video and if you do give it a thumbs up subscribe if you haven't subscribe too hey and we'll see you on the next video bye the [Music] side give the side you're the sun isn't this a
Up Next

Blockchain & Money: Money, Ledgers & Bitcoin | MIT Lecture
@mitocw
1.9M views•2020-01-23

Torrent File Format & Bencoding: A Technical Deep Dive
@AsliEngineering
12.5K views•2022-08-08

Launch a Solana SPL Token: Mint, Transfer, and Metadata - Tutorial
@net2dev
15.4K views•2024-06-21

Understanding Ethereum: A Comprehensive Beginner's Overview
@99Bitcoins
3.1M views•2018-06-26
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Blockchain & Crypto






































