GithubHelp home page GithubHelp logo

erc20token's Introduction

ERC20 Token

This code is a basic implementation of an ERC20 token. ERC20 is a standard interface for tokens on the Ethereum blockchain. It defines a set of rules that tokens must follow, such as how to transfer them, how to check balances, and so on.

Explanation

    // SPDX-License-Identifier:MIT
    pragma solidity ^0.8.17;
  • At the beginning we have comments which show information on the license we are using and publishing the code under and also the version of Solidity language we are currently using.
    contract Erc20Token{
  • This line marks the beginning of the a new contract called Erc20Token.
    string public name;
    string public symbol;
    uint8 public decimals
    uint private totalSupply;
  • The lines declare some properties of the token:
    • name: The name of the token (e.g., "MyToken").
    • symbol: A short code representing the token (e.g., "MA").
    • decimals: How many decimal places the token takes
    • _totalSupply: The total number of tokens.
mapping(address => uint) private balances;
mapping(mapping(address => uint)) private allowed;

  • These lines declare two "mappings". In simple terms, mappings are like dictionaries in Javascript and many other languages. The enable us associate a value to another.

    • balances: Maps address to the amount of tokens they have.
    • allowed : Maps addresses to other addresses to other address and the amount of tokens a address is allowed to spend on behalf of another address.
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
  • These lines declare two events. Events are away to log information on the blockchain.
    • Transfer: This event is emitted when tokens are transferred from one address to another.
    • Approval: This event is emitted when one address approves another to spend tokens on its behalf.

erc20token's People

Contributors

arnoldmn 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.