Last active
January 20, 2022 20:59
-
-
Save anonymous-research-group/0702ec58a8cf50ae3b7eca762e3ba2cb to your computer and use it in GitHub Desktop.
BaseToken is the ERC-20 token upon which the Ethereum Social Engineering attacks A1-A7 are implemented
This file contains hidden or 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.5.16; | |
| import "../openzeppelin-contracts/GSN/Context.sol"; | |
| import "../openzeppelin-contracts/token/ERC20/ERC20.sol"; | |
| import "../openzeppelin-contracts/token/ERC20/ERC20Detailed.sol"; | |
| import "../openzeppelin-contracts/math/SafeMath.sol"; | |
| contract BaseToken is Context, ERC20, ERC20Detailed { | |
| uint256 tokenPrice = 100 wei; | |
| using SafeMath for uint256; | |
| using SafeMath for uint; | |
| constructor () public payable ERC20Detailed("BaseToken", "BT", 18) { | |
| _mint(_msgSender(), SafeMath.div(msg.value, tokenPrice)); | |
| } | |
| function buyTokens() public payable { | |
| _mint(_msgSender(), SafeMath.div(msg.value, tokenPrice)); | |
| } | |
| function sellTokens(uint256 amount) public { | |
| _burn(_msgSender(), amount); | |
| address(msg.sender).transfer( SafeMath.mul(amount, tokenPrice)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment