-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,556 additions
and
543 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
pragma solidity ^0.4.16; | ||
library SafeMath { | ||
function mul(uint256 a, uint256 b) internal constant returns (uint256) { | ||
uint256 c = a * b; | ||
assert(a == 0 || c / a == b); | ||
return c; | ||
} | ||
function div(uint256 a, uint256 b) internal constant returns (uint256) { | ||
uint256 c = a / b; | ||
return c; | ||
} | ||
function sub(uint256 a, uint256 b) internal constant returns (uint256) { | ||
assert(b <= a); | ||
return a - b; | ||
} | ||
function add(uint256 a, uint256 b) internal constant returns (uint256) { | ||
uint256 c = a + b; | ||
assert(c >= a); | ||
return c; | ||
} | ||
} | ||
contract ERC20Basic { | ||
uint256 public totalSupply; | ||
function balanceOf(address who) public constant returns (uint256); | ||
function transfer(address to, uint256 value) public returns (bool); | ||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
} | ||
contract BasicToken is ERC20Basic { | ||
using SafeMath for uint256; | ||
mapping(address => uint256) balances; | ||
function transfer(address _to, uint256 _value) public returns (bool) { | ||
require(_to != address(0)); | ||
require(_value > 0 && _value <= balances[msg.sender]); | ||
balances[msg.sender] = balances[msg.sender].sub(_value); | ||
balances[_to] = balances[_to].add(_value); | ||
Transfer(msg.sender, _to, _value); | ||
return true; | ||
} | ||
function balanceOf(address _owner) public constant returns (uint256 balance) { | ||
return balances[_owner]; | ||
} | ||
} | ||
contract ERC20 is ERC20Basic { | ||
function allowance(address owner, address spender) public constant returns (uint256); | ||
function transferFrom(address from, address to, uint256 value) public returns (bool); | ||
function approve(address spender, uint256 value) public returns (bool); | ||
event Approval(address indexed owner, address indexed spender, uint256 value); | ||
} | ||
contract StandardToken is ERC20, BasicToken { | ||
mapping (address => mapping (address => uint256)) internal allowed; | ||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { | ||
require(_to != address(0)); | ||
require(_value > 0 && _value <= balances[_from]); | ||
require(_value <= allowed[_from][msg.sender]); | ||
balances[_from] = balances[_from].sub(_value); | ||
balances[_to] = balances[_to].add(_value); | ||
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); | ||
Transfer(_from, _to, _value); | ||
return true; | ||
} | ||
function approve(address _spender, uint256 _value) public returns (bool) { | ||
allowed[msg.sender][_spender] = _value; | ||
Approval(msg.sender, _spender, _value); | ||
return true; | ||
} | ||
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { | ||
return allowed[_owner][_spender]; | ||
} | ||
} | ||
contract Ownable { | ||
address public owner; | ||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | ||
function Ownable() { | ||
owner = msg.sender; | ||
} | ||
modifier onlyOwner() { | ||
require(msg.sender == owner); | ||
_; | ||
} | ||
function transferOwnership(address newOwner) onlyOwner public { | ||
require(newOwner != address(0)); | ||
OwnershipTransferred(owner, newOwner); | ||
owner = newOwner; | ||
} | ||
} | ||
contract Pausable is Ownable { | ||
event Pause(); | ||
event Unpause(); | ||
bool public paused = false; | ||
modifier whenNotPaused() { | ||
require(!paused); | ||
_; | ||
} | ||
modifier whenPaused() { | ||
require(paused); | ||
_; | ||
} | ||
function pause() onlyOwner whenNotPaused public { | ||
paused = true; | ||
Pause(); | ||
} | ||
function unpause() onlyOwner whenPaused public { | ||
paused = false; | ||
Unpause(); | ||
} | ||
} | ||
contract PausableToken is StandardToken, Pausable { | ||
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { | ||
return super.transfer(_to, _value); | ||
} | ||
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { | ||
return super.transferFrom(_from, _to, _value); | ||
} | ||
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { | ||
return super.approve(_spender, _value); | ||
} | ||
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) { | ||
uint cnt = _receivers.length; | ||
uint256 amount = uint256(cnt) * _value; | ||
require(cnt > 0 && cnt <= 20); | ||
require(_value > 0 && balances[msg.sender] >= amount); | ||
balances[msg.sender] = balances[msg.sender].sub(amount); | ||
for (uint i = 0; i < cnt; i++) { | ||
balances[_receivers[i]] = balances[_receivers[i]].add(_value); | ||
Transfer(msg.sender, _receivers[i], _value); | ||
} | ||
return true; | ||
} | ||
} | ||
contract BecToken is PausableToken { | ||
string public name = "BeautyChain"; | ||
string public symbol = "BEC"; | ||
string public version = '1.0.0'; | ||
uint8 public decimals = 18; | ||
function BecToken() { | ||
totalSupply = 7000000000 * (10**(uint256(decimals))); | ||
balances[msg.sender] = totalSupply; | ||
} | ||
function () { | ||
revert(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
pragma solidity ^0.4.19; | ||
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } | ||
contract SafeMath { | ||
function safeMul(uint256 a, uint256 b) returns (uint256) { | ||
uint256 c = a * b; | ||
require(a == 0 || c / a == b); | ||
return c; | ||
} | ||
function safeSub(uint256 a, uint256 b) returns (uint256) { | ||
require(b <= a); | ||
return a - b; | ||
} | ||
function safeAdd(uint256 a, uint256 b) returns (uint256) { | ||
uint c = a + b; | ||
require(c >= a && c >= b); | ||
return c; | ||
} | ||
} | ||
contract Owned { | ||
address public owner; | ||
function Owned() { | ||
owner = msg.sender; | ||
} | ||
function setOwner(address _owner) returns (bool success) { | ||
owner = _owner; | ||
return true; | ||
} | ||
modifier onlyOwner { | ||
require(msg.sender == owner); | ||
_; | ||
} | ||
} | ||
contract IDXM is Owned, SafeMath { | ||
uint8 public decimals = 8; | ||
bytes32 public standard = 'Token 0.1'; | ||
bytes32 public name = 'IDEX Membership'; | ||
bytes32 public symbol = 'IDXM'; | ||
uint256 public totalSupply; | ||
event Approval(address indexed from, address indexed spender, uint256 amount); | ||
mapping (address => uint256) public balanceOf; | ||
mapping (address => mapping (address => uint256)) public allowance; | ||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
uint256 public baseFeeDivisor; | ||
uint256 public feeDivisor; | ||
uint256 public singleIDXMQty; | ||
function () external { | ||
throw; | ||
} | ||
uint8 public feeDecimals = 8; | ||
struct Validity { | ||
uint256 last; | ||
uint256 ts; | ||
} | ||
mapping (address => Validity) public validAfter; | ||
uint256 public mustHoldFor = 604800; | ||
mapping (address => uint256) public exportFee; | ||
function IDXM() { | ||
totalSupply = 200000000000; | ||
balanceOf[msg.sender] = totalSupply; | ||
exportFee[0x00000000000000000000000000000000000000ff] = 100000000; | ||
precalculate(); | ||
} | ||
bool public balancesLocked = false; | ||
function uploadBalances(address[] addresses, uint256[] balances) onlyOwner { | ||
require(!balancesLocked); | ||
require(addresses.length == balances.length); | ||
uint256 sum; | ||
for (uint256 i = 0; i < uint256(addresses.length); i++) { | ||
sum = safeAdd(sum, safeSub(balances[i], balanceOf[addresses[i]])); | ||
balanceOf[addresses[i]] = balances[i]; | ||
} | ||
balanceOf[owner] = safeSub(balanceOf[owner], sum); | ||
} | ||
function lockBalances() onlyOwner { | ||
balancesLocked = true; | ||
} | ||
function transfer(address _to, uint256 _amount) returns (bool success) { | ||
require(!locked); | ||
require(balanceOf[msg.sender] >= _amount); | ||
require(balanceOf[_to] + _amount >= balanceOf[_to]); | ||
balanceOf[msg.sender] -= _amount; | ||
uint256 preBalance = balanceOf[_to]; | ||
balanceOf[_to] += _amount; | ||
bool alreadyMax = preBalance >= singleIDXMQty; | ||
if (!alreadyMax) { | ||
if (now >= validAfter[_to].ts + mustHoldFor) validAfter[_to].last = preBalance; | ||
validAfter[_to].ts = now; | ||
} | ||
if (validAfter[msg.sender].last > balanceOf[msg.sender]) validAfter[msg.sender].last = balanceOf[msg.sender]; | ||
Transfer(msg.sender, _to, _amount); | ||
return true; | ||
} | ||
function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) { | ||
require(!locked); | ||
require(balanceOf[_from] >= _amount); | ||
require(balanceOf[_to] + _amount >= balanceOf[_to]); | ||
require(_amount <= allowance[_from][msg.sender]); | ||
balanceOf[_from] -= _amount; | ||
uint256 preBalance = balanceOf[_to]; | ||
balanceOf[_to] += _amount; | ||
allowance[_from][msg.sender] -= _amount; | ||
bool alreadyMax = preBalance >= singleIDXMQty; | ||
if (!alreadyMax) { | ||
if (now >= validAfter[_to].ts + mustHoldFor) validAfter[_to].last = preBalance; | ||
validAfter[_to].ts = now; | ||
} | ||
if (validAfter[_from].last > balanceOf[_from]) validAfter[_from].last = balanceOf[_from]; | ||
Transfer(_from, _to, _amount); | ||
return true; | ||
} | ||
function approveAndCall(address _spender, uint256 _amount, bytes _extraData) returns (bool success) { | ||
tokenRecipient spender = tokenRecipient(_spender); | ||
if (approve(_spender, _amount)) { | ||
spender.receiveApproval(msg.sender, _amount, this, _extraData); | ||
return true; | ||
} | ||
} | ||
function approve(address _spender, uint256 _amount) returns (bool success) { | ||
require(!locked); | ||
allowance[msg.sender][_spender] = _amount; | ||
Approval(msg.sender, _spender, _amount); | ||
return true; | ||
} | ||
function setExportFee(address addr, uint256 fee) onlyOwner { | ||
require(addr != 0x00000000000000000000000000000000000000ff); | ||
exportFee[addr] = fee; | ||
} | ||
function setHoldingPeriod(uint256 ts) onlyOwner { | ||
mustHoldFor = ts; | ||
} | ||
function feeFor(address from, address to, uint256 amount) constant external returns (uint256 value) { | ||
uint256 fee = exportFee[from]; | ||
if (fee == 0) return 0; | ||
uint256 amountHeld; | ||
if (balanceOf[to] != 0) { | ||
if (validAfter[to].ts + mustHoldFor < now) amountHeld = balanceOf[to]; | ||
else amountHeld = validAfter[to].last; | ||
if (amountHeld >= singleIDXMQty) return 0; | ||
return amount*fee*(singleIDXMQty - amountHeld) / feeDivisor; | ||
} else return amount*fee / baseFeeDivisor; | ||
} | ||
bool public locked = true; | ||
function unlockToken() onlyOwner { | ||
locked = false; | ||
} | ||
function precalculate() internal returns (bool success) { | ||
baseFeeDivisor = pow10(1, feeDecimals); | ||
feeDivisor = pow10(1, feeDecimals + decimals); | ||
singleIDXMQty = pow10(1, decimals); | ||
} | ||
function div10(uint256 a, uint8 b) internal returns (uint256 result) { | ||
for (uint8 i = 0; i < b; i++) { | ||
a /= 10; | ||
} | ||
return a; | ||
} | ||
function pow10(uint256 a, uint8 b) internal returns (uint256 result) { | ||
for (uint8 i = 0; i < b; i++) { | ||
a *= 10; | ||
} | ||
return a; | ||
} | ||
} |
Oops, something went wrong.