Created
March 13, 2018 07:23
-
-
Save PillarDevelopment/7f5ee83207a530c6b86e30525558fa21 to your computer and use it in GitHub Desktop.
Scamcoin
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.4.18; | |
| library SafeMath | |
| { | |
| function mul(uint256 a, uint256 b) internal pure | |
| returns (uint256) | |
| { | |
| uint256 c = a * b; | |
| assert(a == 0 || c / a == b); | |
| return c; | |
| } | |
| function div(uint256 a, uint256 b) internal pure | |
| returns (uint256) | |
| { | |
| uint256 c = a / b; | |
| return c; | |
| } | |
| function sub(uint256 a, uint256 b) internal pure | |
| returns (uint256) | |
| { | |
| assert(b <= a); | |
| return a - b; | |
| } | |
| function add(uint256 a, uint256 b) internal pure | |
| returns (uint256) | |
| { | |
| uint256 c = a + b; | |
| assert(c >= a); | |
| return c; | |
| } | |
| } | |
| contract Ownable | |
| { | |
| address public owner; | |
| event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
| function Ownable() public { | |
| owner = msg.sender; | |
| } | |
| modifier onlyOwner() { | |
| require(msg.sender == owner); | |
| _; | |
| } | |
| function transferOwnership(address newOwner) public onlyOwner { | |
| require(newOwner != address(0)); | |
| OwnershipTransferred(owner, newOwner); | |
| owner = newOwner; | |
| } | |
| } | |
| interface tokenRecipient | |
| { | |
| function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; | |
| } | |
| contract TokenERC20 is Ownable | |
| { | |
| using SafeMath for uint; | |
| string public name; | |
| string public symbol; | |
| uint256 public decimals = 18; | |
| uint256 DEC = 10 ** uint256(decimals); | |
| address public owner; | |
| uint256 public totalSupply; | |
| uint256 public avaliableSupply; | |
| uint256 public buyPrice = 100 szabo; | |
| 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); | |
| function TokenERC20( | |
| uint256 initialSupply, | |
| string tokenName, | |
| string tokenSymbol | |
| ) public | |
| { | |
| totalSupply = initialSupply * DEC; | |
| balanceOf[this] = totalSupply; | |
| avaliableSupply = balanceOf[this]; | |
| name = tokenName; | |
| symbol = tokenSymbol; | |
| owner = msg.sender; | |
| } | |
| function _transfer(address _from, address _to, uint256 _value) internal | |
| { | |
| require(_to != 0x0); | |
| require(balanceOf[_from] >= _value); | |
| require(balanceOf[_to] + _value > balanceOf[_to]); | |
| uint previousBalances = balanceOf[_from] + balanceOf[_to]; | |
| balanceOf[_from] -= _value; | |
| balanceOf[_to] += _value; | |
| Transfer(_from, _to, _value); | |
| assert(balanceOf[_from] + balanceOf[_to] == previousBalances); | |
| } | |
| function transfer(address _to, uint256 _value) public | |
| { | |
| _transfer(msg.sender, _to, _value); | |
| } | |
| function transferFrom(address _from, address _to, uint256 _value) public | |
| returns (bool success) | |
| { | |
| require(_value <= allowance[_from][msg.sender]); | |
| allowance[_from][msg.sender] -= _value; | |
| _transfer(_from, _to, _value); | |
| return true; | |
| } | |
| function approve(address _spender, uint256 _value) public | |
| returns (bool success) | |
| { | |
| allowance[msg.sender][_spender] = _value; | |
| return true; | |
| } | |
| function approveAndCall(address _spender, uint256 _value, bytes _extraData) public onlyOwner | |
| returns (bool success) | |
| { | |
| tokenRecipient spender = tokenRecipient(_spender); | |
| if (approve(_spender, _value)) { | |
| spender.receiveApproval(msg.sender, _value, this, _extraData); | |
| return true; | |
| } | |
| } | |
| } | |
| contract ERC20Extending is TokenERC20 | |
| { | |
| function transferTokensFromContract(address _to, uint256 _value) public onlyOwner | |
| { | |
| _value = _value*DEC; | |
| avaliableSupply -= _value; | |
| _transfer(this, _to, _value); | |
| } | |
| } | |
| contract SkamCrowdsale is TokenERC20 | |
| { | |
| using SafeMath for uint; | |
| function sell(address _investor, uint256 amount) internal | |
| { | |
| uint256 _amount = amount.mul(DEC).div(buyPrice); | |
| avaliableSupply -= _amount; | |
| _transfer(this, _investor, _amount); | |
| } | |
| } | |
| contract SkamCoin is ERC20Extending, SkamCrowdsale | |
| { | |
| uint public weisRaised; | |
| function SkamCoin() public TokenERC20(80000000, "SkamCoin", "SKMC") {} | |
| function () public payable | |
| { | |
| assert(msg.value >= 1 ether / 10000); | |
| sell(msg.sender, msg.value); | |
| owner.transfer(msg.value); | |
| weisRaised = weisRaised.add(msg.value); | |
| } | |
| function setPrices(uint256 newPrice) public onlyOwner { | |
| buyPrice = newPrice; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment