/**
*This is the only live Ace Wins Contract. The previous contract is not used any longer. ACW is the new ticker. The old ticker ACE is no longer in use.
*/
pragma solidity ^0.4.16;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract AceWins is Ownable {
uint256 public totalSupply;
mapping(address => uint256) startBalances;
mapping(address => mapping(address => uint256)) allowed;
mapping(address => uint256) startBlocks;
string public constant name = "Ace Wins";
string public constant symbol = "ACW";
uint32 public constant decimals = 10;
uint256 public calc = 951839;
function AceWins() public {
totalSupply = 12500000 * 10**uint256(decimals);
startBalances[owner] = totalSupply;
startBlocks[owner] = block.number;
Transfer(address(0), owner, totalSupply);
}
function fracExp(uint256 k, uint256 q, uint256 n, uint256 p) pure public returns (uint256) {
uint256 s = 0;
uint256 N = 1;
uint256 B = 1;
for (uint256 i = 0; i < p; ++i) {
s += k * N / B / (q**i);
N = N * (n-i);
B = B * (i+1);
}
return s;
}
function compoundInterest(address tokenOwner) view public returns (uint256) {
require(startBlocks[tokenOwner] > 0);
uint256 start = startBlocks[tokenOwner];
uint256 current = block.number;
uint256 blockCount = current - start;
uint256 balance = startBalances[tokenOwner];
return fracExp(balance, calc, blockCount, 8) - balance;
}
function balanceOf(address tokenOwner) public constant returns (uint256 balance) {
return startBalances[tokenOwner] + compoundInterest(tokenOwner);
}
function updateBalance(address tokenOwner) private {
if (startBlocks[tokenOwner] == 0) {
startBlocks[tokenOwner] = block.number;
}
uint256 ci = compoundInterest(tokenOwner);
startBalances[tokenOwner] = startBalances[tokenOwner] + ci;
totalSupply = totalSupply + ci;
startBlocks[tokenOwner] = block.number;
}
function transfer(address to, uint256 tokens) returns (bool success) {
updateBalance(msg.sender);
updateBalance(to);
require(tokens <= startBalances[msg.sender]);
startBalances[msg.sender] = startBalances[msg.sender] - tokens;
startBalances[to] = startBalances[to] + tokens;
Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint256 tokens) returns (bool success) {
updateBalance(from);
updateBalance(to);
if (startBalances[from] >= tokens && allowed[from][msg.sender] >= tokens && tokens > 0) {
startBalances[to] = startBalances[to] + tokens;
startBalances[from] = startBalances[from] - tokens;
allowed[from][msg.sender] -= tokens;
Transfer(from, to, tokens);
return true;
} else { return false; }
}
function setCalc(uint256 _Calc) public {
require(msg.sender==owner);
calc = _Calc;
}
function approve(address spender, uint256 tokens) public returns (bool) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining) {
return allowed[tokenOwner][spender];
}
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed owner, address indexed spender, uint256 tokens);
}
{
"compilationTarget": {
"AceWins.sol": "AceWins"
},
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_Calc","type":"uint256"}],"name":"setCalc","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"calc","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"compoundInterest","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"k","type":"uint256"},{"name":"q","type":"uint256"},{"name":"n","type":"uint256"},{"name":"p","type":"uint256"}],"name":"fracExp","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}]