Created
September 19, 2018 08:58
-
-
Save k06a/15321a946d7fbe04868ac8959c016f45 to your computer and use it in GitHub Desktop.
BadToken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.24; | |
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | |
contract BadToken { | |
using SafeMath for uint256; | |
uint256 public totalSupply; | |
mapping(address => uint256) public balanceOf; | |
mapping(address => mapping(address => uint256)) public allowance; | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
event Approval(address indexed owner, address indexed spender, uint256 value); | |
bytes32 public name; // [!] bytes32 instead of string | |
bytes32 public symbol; // [!] bytes32 instead of string | |
uint256 public decimals; // [!] uint256 instead of uint8 | |
constructor(bytes32 _name, bytes32 _symbol, uint256 _decimals) public { | |
name = _name; | |
symbol = _symbol; | |
decimals = _decimals; | |
} | |
// [!] Returns void instead of bool | |
function transfer(address _to, uint256 _value) public /*returns(bool)*/ { | |
_transfer(msg.sender, _to, _value); | |
} | |
// [!] Returns void instead of bool | |
function transferFrom(address _from, address _to, uint256 _value) public /*returns(bool)*/ { | |
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); | |
_transfer(_from, _to, _value); | |
} | |
// [!] Returns void instead of bool | |
function approve(address _spender, uint256 _value) public /*returns(bool)*/ { | |
require((allowance[msg.sender][_spender] == 0) || (_value == 0)); | |
allowance[msg.sender][_spender] = _value; | |
emit Approval(msg.sender, _spender, _value); | |
} | |
function _transfer(address _from, address _to, uint256 _value) internal { | |
balanceOf[_from] = balanceOf[_from].sub(_value); | |
balanceOf[_to] = balanceOf[_to].add(_value); | |
emit Transfer(_from, _to, _value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment