This repository contains the Solidity smart contract for AbdulBasitCoin (ABC), a simple token implementation designed for learning purposes. The contract defines a custom token with minting and burning functionality while maintaining essential security checks.
-
Token Details:
- Name: AbdulBasitCoin
- Abbreviation: ABC
- Total Supply: 1,000,000 (initially set)
-
Mapping for Balances:
- A
mapping
is used to keep track of token balances for each address.
- A
-
Mint Functionality:
- Adds tokens to an address.
- Increases the total supply.
-
Burn Functionality:
- Removes tokens from an address.
- Decreases the total supply.
- Ensures sufficient balance exists before burning.
The contract includes public variables to store token details, making them accessible to users:
string public tokenName = "AbdulBasitCoin";
string public tokenAbbrv = "ABC";
uint public totalSupply = 1000000;
A mapping
associates each address with its respective token balance:
mapping(address => uint) public balances;
The mint
function allows authorized users to increase the token supply and assign tokens to specific addresses:
function mint(address _address, uint _value) public {
totalSupply += _value;
balances[_address] += _value;
}
The burn
function reduces the token supply by removing tokens from a specific address. It includes checks to ensure the balance is sufficient:
function burn(address _address, uint _value) public {
require(balances[_address] >= _value, "Insufficient balance to burn");
totalSupply -= _value;
balances[_address] -= _value;
}
The contract adheres to the following requirements:
- Public variables for token details (name, abbreviation, total supply).
- Address-to-balance mapping for managing user balances.
- Mint function to create new tokens and assign them to an address.
- Burn function to destroy tokens and reduce total supply.
- Safety checks in the burn function to prevent burning more tokens than available.
- Deploy the Contract:
- Deploy the contract on the Ethereum network or any compatible EVM chain.
- Mint Tokens:
- Call the
mint
function with the recipient address and the number of tokens to mint.
- Call the
- Burn Tokens:
- Call the
burn
function with the address and the number of tokens to burn. - Ensure the address has sufficient balance before calling this function.
- Call the
This project is licensed under the MIT License. See the LICENSE
file for details.