pragma solidity ^0.4.19;
contract MINTY {
string public name = 'MINTY';
string public symbol = 'MINTY';
uint8 public decimals = 18;
uint public totalSupply = 10000000000000000000000000;
uint public minted = totalSupply / 5;
uint public minReward = 1000000000000000000;
uint public fee = 700000000000000;
uint public reducer = 1000;
uint private randomNumber;
address public owner;
uint private ownerBalance;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => uint256) public successesOf;
mapping (address => uint256) public failsOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
modifier onlyOwner {
if (msg.sender != owner) revert();
_;
}
function transferOwnership(address newOwner) external onlyOwner {
owner = newOwner;
}
/* Initializes contract with initial supply tokens to the creator of the contract */
function MINTY() public {
owner = msg.sender;
balanceOf[owner] = minted;
balanceOf[this] = totalSupply - balanceOf[owner];
}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _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);
}
/* Send coins */
function transfer(address _to, uint256 _value) external {
_transfer(msg.sender, _to, _value);
}
/* Transfer tokens from other address */
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/* Set allowance for other address */
function approve(address _spender, uint256 _value) external returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
function withdrawEther() external onlyOwner {
owner.transfer(ownerBalance);
ownerBalance = 0;
}
function () external payable {
if (msg.value == fee) {
randomNumber += block.timestamp + uint(msg.sender);
uint minedAtBlock = uint(block.blockhash(block.number - 1));
uint minedHashRel = uint(sha256(minedAtBlock + randomNumber + uint(msg.sender))) % 10000000;
uint balanceRel = balanceOf[msg.sender] * 1000 / minted;
if (balanceRel >= 1) {
if (balanceRel > 255) {
balanceRel = 255;
}
balanceRel = 2 ** balanceRel;
balanceRel = 5000000 / balanceRel;
balanceRel = 5000000 - balanceRel;
if (minedHashRel < balanceRel) {
uint reward = minReward + minedHashRel * 1000 / reducer * 100000000000000;
_transfer(this, msg.sender, reward);
minted += reward;
successesOf[msg.sender]++;
} else {
Transfer(this, msg.sender, 0);
failsOf[msg.sender]++;
}
ownerBalance += fee;
reducer++;
} else {
revert();
}
} else {
revert();
}
}
}
{
"compilationTarget": {
"MINTY.sol": "MINTY"
},
"libraries": {},
"optimizer": {
"enabled": true,
"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":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","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":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minted","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"reducer","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdrawEther","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"failsOf","outputs":[{"name":"","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":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"minReward","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"successesOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]