The ShoppingToken
contract is a basic implementation of a token on the Ethereum blockchain. It allows for minting (creating) and burning (destroying) tokens, managing balances, and keeping track of the total token supply.
- Token Details: The contract stores information about the token, including its name (
Name
), identifier (ID
), and total supply (points
). - Balance Mapping: It uses a mapping (
balances
) to track token balances for each address. - Mint Function: Allows increasing the total supply and adding tokens to a specific address.
- Burn Function: Allows decreasing the total supply and removing tokens from a specific address, with checks to ensure the address has sufficient balance.
- Security: The burn function includes a conditional check to prevent burning more tokens than the sender owns.
Name
: A public string variable representing the name of the token.ID
: A public string variable representing an identifier or abbreviation for the token.points
: A public uint variable representing the total supply of tokens.
- Constructor: Initializes the token with a name, identifier, and initial supply.
- mint: Function to mint new tokens to a specified address. Increases total supply and recipient's balance.
- burn: Function to burn tokens from a specified address. Decreases total supply and sender's balance, with a check to prevent over-burning.
To use this contract:
- Deploy it on an Ethereum-compatible blockchain or online on Remix IDE.
- Upon deployment, provide values for
_name
,_ID
, and_initialSupply
to initialize the token details. - Use the
mint
function to add tokens to specific addresses. - Use the
burn
function to remove tokens from specific addresses, ensuring the sender has enough tokens to burn.
The contract is implemented in Solidity version 0.8.18
.
This project is made by Riddhima Langer, student of BE-CSE at Chandigarh University.