Verified contractPartial
Token
Address0x74c4a525cf256ffbb16075701f47faadf0d65eec
- Balance
0 ETH
- Transactions
1,522
- Compiler
solc 0.4.21
- Same code
230 more contracts
Details
- Compiler
- solc 0.4.21+commit.dfe3193c
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: no, runtime code: yes
- Verified on Sourcify
- Created in block
- 8,155,263
- Creation transaction
- 0xc69b820648…d0a500d65d
- Main copy (most transactions)
- 0x0dbc58bf…70e9b120
Token.sol
// Submitted by EthereumHistory (ethereumhistory.com)
pragma solidity ^0.4.21;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(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 Token {
string public name;
string public symbol;
uint256 public decimals;
uint256 public totalSupply;
address public creator;
bool public autoSend = false;
uint public start;
uint public end;
uint public rate;
uint public freeCount;
mapping (address => uint256) public balanceOf;
mapping (address => uint8) public buyCountOf;
event Transfer(address indexed from, address indexed to, uint256 value);
// buy token
function () public payable {
require(autoSend);
require(now >= start && now <= end);
uint256 weiAmount = msg.value;
uint256 tokens;
if (rate == 0)
tokens = freeCount * (10 ** decimals);
else
tokens = SafeMath.div(SafeMath.mul(SafeMath.mul(weiAmount, rate), 10 ** decimals), 1000000000000000000);
require(tokens > 0);
// 不要自己提到自己账户
require(creator != msg.sender);
// 首先检查发token的账户是否拥有对应数量的代币
require(balanceOf[creator] >= tokens);
// 当 rate 为 0 时,检查是否已经领取过
if (rate == 0)
require(buyCountOf[msg.sender] < 1);
// 开始转移代币
uint previousBalances = balanceOf[msg.sender] + balanceOf[creator];
balanceOf[msg.sender] += tokens;
balanceOf[creator] -= tokens;
// 这个是事件
emit Transfer(creator,msg.sender, tokens);
assert(balanceOf[msg.sender] + balanceOf[creator] == previousBalances);
if (rate == 0)
buyCountOf[msg.sender] += 1;
}
function getETH() public {
require(address(this).balance > 0 && msg.sender == creator);
creator.transfer(address(this).balance);
}
function Token(
uint256 initialSupply,
string tokenName,
string tokenSymbol,
uint8 tokenDecimals,
bool tokenAutoSend,
uint tokenStart,
uint tokenEnd,
uint tokenPrice,
uint tokenFreeCount
) public payable
{
name = tokenName;
symbol = tokenSymbol;
decimals = tokenDecimals;
creator = msg.sender;
totalSupply = initialSupply * ( 10 ** uint256(decimals) );
balanceOf[msg.sender] = totalSupply;
autoSend = tokenAutoSend;
start = tokenStart;
end = tokenEnd;
rate = tokenPrice;
freeCount = tokenFreeCount;
}
function transfer(address _to, uint256 _value) public {
// _value = _value * ( 10 ** uint256(decimals) );
require(_to != 0x0);
require(msg.sender != _to);
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
// 这个是事件
emit Transfer(msg.sender, _to, _value);
assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances);
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.