GithubHelp home page GithubHelp logo

solidity's Introduction

Solidity Program: MyToken

This is a Solidity smart contract that implements a basic token called MyToken (MYTOKEN) with functionalities for minting and burning tokens.

Requirements

  1. The contract has public variables to store details about the token, including its name, abbreviation, and total supply.
  2. A mapping is used to track the token balances of different addresses (address => uint).
  3. The contract includes a mint function that takes an address and a value as parameters. It increases the total supply by the specified value and adds that value to the balance of the sender's address.
  4. The contract also includes a burn function that works in the opposite way of the mint function. It takes an address and a value as parameters, deducts the value from the total supply, and reduces the balance of the sender's address accordingly.
  5. The burn function includes conditionals to ensure that the balance of the sender is greater than or equal to the amount to be burned.

Usage

  1. tokenName: A public variable that represents the name of the token. In this contract, it is set to "MYTOKEN".
  2. tokenAbbrv: A public variable that represents the abbreviation of the token. In this contract, it is set to "MTK".
  3. totalSupply: A public variable that stores the total supply of the token. Initially set to 0, it increases when tokens are minted and decreases when tokens are burned.
  4. balances: A mapping that associates addresses with token balances. Each address's balance is stored as a positive integer.
  5. mint: A function that mints new tokens. It takes an address (_address) and a value (_value) as parameters. It increases the total supply by the specified value and adds that value to the balance of the specified address.
  6. burn: A function that burns existing tokens. It takes an address (_address) and a value (_value) as parameters. If the balance of the specified address is greater than or equal to the value, it deducts the value from the total supply and reduces the balance of the specified address.

Please note that this contract is a basic implementation and may require additional functionality and security measures for use in production environments.

License

This contract is not licensed.

solidity's People

Contributors

mashood39 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.