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

Loading player…

Transferring a Minimal Token

BaseMon, Oct 9, 2023, 12:00 AM

Implement a minimal token in Ethereum and understand its limitations. Discover how to transfer tokens between parties and validate balances. Unleash the power of token transactions with a step-by-step guide! 📚 Head to Base Camp for full courses on smart contract development: https://docs.base.org/base-camp/docs/welcome ✅ Subscribe to our channel here: https://www.youtube.com/@BuildonBase ► Build on Base: https://base.org ► Follow us on Twitter: https://twitter.com/buildonbase ► Join our Discord: https://base.org/discord

Transcript

now as you can see this minimal token implementation allow us to track the balance of each parties however we have many limitations one of them is that we don't have the capability to transfer tokens and how do we transfer tokens in fact transferring tokens from one party to another is simply updating the balances of each party okay then let's do a function we are gonna call transfer where specify to who we want to send the tokens and also the amount that we want to send then we say there is going to be and external and now what we do is the balances of the sender whoever is calling transfer is going to be now equals to balances that he already has okay in this way we are accessing the value minus the amount that he wants to transfer okay and then the balances of the new person of the two address is going to be equals to the balances that he already has okay Plus the amount okay as you can see we are simply taking tokens from this party and putting tokens to this party however again everything is about keeping a table with the balances okay um let's add are required here to validate a condition the condition will be that the balance of the sender has to be bigger or equals than the amount that he wants to transfer and if that is incorrect we simply say insufficient balance okay now let's test I'm going to deploy again with the first account and now let's check the balance again 1000 total supply three thousand but now let's send to the party number two okay so I'm copy the address then I come back to the first account and I'm gonna say I want to transfer to the second address the second account this one I want to transfer um 100 okay so if I do transact okay it was successful now let's check the balances okay now I have 900 because I transfer 100. and now the total Supply let's see what is the value still three thousand okay now let's check the balance of the other party which in theory should be one thousand and one hundred right so let's check it and is correct

Automatic transcript — names and jargon may be misspelled.