MavinToken is a simple ERC20 token smart contract designed for minting and burning tokens. This project serves as part of the Solidity Beginner class.
- The contract includes public variables to store coin details (Token Name, Token Abbreviation, Total Supply).
- Utilizes a mapping to store addresses and their corresponding balances (address => uint).
- Contains a mint function, taking an address and a value as parameters. This function increases the total supply and the balance of the sender's address.
- Provides a burn function that reverses the mint operation, effectively destroying tokens. It requires an address and a value. This function reduces the total supply and the balance of the sender's address.
- Includes validation in the burn function to ensure the sender's balance is greater than or equal to the amount being burned.
To run the program, use Remix, an online Solidity IDE. Follow these steps:
- Visit the Remix IDE website.
- Create a new file using the "+" icon in the left sidebar. Save it with a .sol extension (e.g., MavinToken.sol).
- Copy and paste the provided code into the file.
Deploy the contract to your chosen network and interact with its functions using a web3 provider such as MetaMask or a similar tool.
The contract's constructor accepts two parameters:
name
(string): The token's name.symbol
(string): The token's symbol.
The constructor initializes the token's name and symbol.
The mint
function allows anyone to increase the total supply and the balance of a specified address. It takes two parameters:
_to
(address): The address to mint tokens to._value
(uint256): The amount of tokens to mint.
The burn
function enables users to decrease the total supply and their own balance, provided they have enough balance. It takes one parameter:
_value
(uint256): The amount of tokens to burn.
This function validates the user's balance before performing the burn.
This project was created by Tobi Emmanuel Agbaje.
This project is licensed under the MIT License.