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

Loading player…

Creating a Minimal Token

BaseMon, Oct 9, 2023, 12:00 AM

Create a minimal token that helps you understand the basics of token implementation in Ethereum. You'll learn about balances, total supply, and how to distribute tokens among different accounts. Join to get hands-on with tokens! 🚀💰 📚 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

let's start creating a minimal token this token will contain the minimal elements that a token should have keep in mind that this is not going to be a token that is compliant with any standard but it will help us to understand more about tokens now let's create a contract called Minima token as I mentioned the balances of the token holders are stored in a table and if you remember our introduction to solidity course we can use a mapping to store the balances and the key for each balance will be the address of the token holder okay so we can simply say mapping of address and we can use a u in 256 to keep the balance of each token holder let's do public and we're gonna call it balances okay so this data structure is gonna help us to a store the address of the token holder and its balance okay now we need another variable that is also going to be are you in 256 let's do it public and we're gonna call it total Supply this variable will help us to keep track of all the tokens okay now what we're gonna do is let's create a Constructor and let's initialize the total Supply and let's say we want the total Supply to be three thousand okay and then what we can say is we're gonna assign to the creator of this contract the total Supply what does that mean is that the person who deploys the contract will have all the tokens available okay here we are simply assigning all the tokens okay now let's test let's go to the deploy and run transactions let's deploy we have here the minimal token and let's check the total Supply we have three thousand which is what we expected now since the account that is deploying is this one let's copy the address and let's check the balance of this address as we can see now this person has 3 000 tokens which is the total Supply okay now what we're gonna do is something different remember that in remix we have multiple accounts so what are we gonna do is we are going to assign to those different accounts one third of the total Supply okay so let's copy and paste this and now let's copy this second address I'm gonna copy and we are simply hard coding this for for the moment then the next one I'm gonna copy okay and now let's play with this account okay now I'm going to deploy let's review the total supply three thousand and now let's check the balance of this account and now we have one thousand this is because when we are creating the token we are assigning one-third of the total Supply which is 3000 divided by 3 will give us one thousand now let's check the balance of the other accounts and as you can see they also have one thousand

Automatic transcript — names and jargon may be misspelled.