Skip to content

Instantly share code, notes, and snippets.

@weaming
Forked from eternauta1337/BasicToken.sol
Created July 29, 2022 12:17
Show Gist options
  • Select an option

  • Save weaming/34e4d9f2054fb82ad903029ae9e21c7c to your computer and use it in GitHub Desktop.

Select an option

Save weaming/34e4d9f2054fb82ad903029ae9e21c7c to your computer and use it in GitHub Desktop.

Revisions

  1. @eternauta1337 eternauta1337 revised this gist Jul 30, 2018. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions BasicToken.sol
    Original file line number Diff line number Diff line change
    @@ -2,18 +2,21 @@ pragma solidity ^0.4.24;

    contract BasicToken {

    mapping(address => uint256) balances;

    uint256 totalSupply_;
    mapping(address => uint256) balances;

    constructor(uint256 _initialSupply) public {
    totalSupply_ = _initialSupply;
    balances[msg.sender] = _initialSupply;
    }

    function totalSupply() public view returns (uint256) {
    return totalSupply_;
    }

    function transfer(address _to, uint256 _value) public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);

    balances[msg.sender] = balances[msg.sender] - _value;
    balances[_to] = balances[_to] + _value;
    return true;
  2. @eternauta1337 eternauta1337 created this gist Jul 28, 2018.
    25 changes: 25 additions & 0 deletions BasicToken.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    pragma solidity ^0.4.24;

    contract BasicToken {

    mapping(address => uint256) balances;

    uint256 totalSupply_;

    function totalSupply() public view returns (uint256) {
    return totalSupply_;
    }

    function transfer(address _to, uint256 _value) public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);

    balances[msg.sender] = balances[msg.sender] - _value;
    balances[_to] = balances[_to] + _value;
    return true;
    }

    function balanceOf(address _owner) public view returns (uint256) {
    return balances[_owner];
    }
    }