Slide 103
Slide 103 text
Copyright (C) 2018 DeNA Co.,Ltd. All Rights
10
3
pragma solidity ^0.4.18;
import "./SafeMath.sol";
import "./Ownable.sol";
import "./ERC20.sol";
contract Algo369 is ERC20Token, Ownable {
using SafeMath for uint256;
event TokenPurchased(address indexed buyer, uint256 value, uint256
tokens);
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
uint256 totalSupply_;
//100000000000000 wei = 0.0001 ether = 5YEN
//uint256 public tokenPrice = 100000000000000 * (uint256(10) **
decimals); // In Wei per (1 token * 10^decimals)
uint256 public tokenPrice = 100000000000000;
string public constant symbol = "ALG";
string public constant name = "Algo369";
uint8 public constant decimals = 0;
//function Alpaca() public ERC20Token {}
//function Alpaca(string name, string symbol) public ERC20Token(name,
symbol) {}
function Alpaca() public {
//10億
totalSupply_ = 1000000 * (uint256(10) ** decimals);
//totalSupply_ = 1000000000;
balances[owner] = totalSupply_;
}
function() public payable {
uint256 _tokensAmount = msg.value / tokenPrice;
require(msg.sender != address(0));
require(_tokensAmount <= balances[owner]);
balances[owner] = balances[owner].sub(_tokensAmount);
balances[msg.sender] = balances[msg.sender].add(_tokensAmount);
emit Transfer(owner, msg.sender, _tokensAmount);
function send() public payable {
uint256 _tokensAmount = msg.value / tokenPrice;
require(msg.sender != address(0));
require(_tokensAmount <= balances[owner]);
balances[owner] = balances[owner].sub(_tokensAmount);
balances[msg.sender] = balances[msg.sender].add(_tokensAmount);
emit Transfer(owner, msg.sender, _tokensAmount);
emit TokenPurchased(msg.sender, msg.value, _tokensAmount);
}
function totalSupply() public constant returns (uint256) {
return totalSupply_;
}
function balanceOf(address _owner) public constant returns (uint256 balance)
{
return balances[_owner];
}
function allowance(address _owner, address _spender) public constant returns
(uint256) {
return allowed[_owner][_spender];
}
function transfer(address _to, uint256 _amount) public returns (bool) {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
function approve(address _spender, uint256 _amount) public returns (bool) {
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount) public
returns (bool) {