contract META {
string public name = "Dunaton Metacurrency 2.0";
uint8 public decimals = 18;
string public symbol = "META";
address public _owner;
address public dev = 0xC96CfB18C39DC02FBa229B6EA698b1AD5576DF4c;
uint256 public _tokePerEth = 156;
uint256 public _totalSupply = 21000000; // 21m, 18dp - one token is 1000000000000000000 therefore
event Transfer(address indexed _from, address indexed _to, uint _value);
// Storage
mapping (address => uint256) public balances;
function META() {
_owner = msg.sender;
balances[_owner] = 5800000; // premine 5.8m tokens to _owner
Transfer(this, _owner, 5800000);
_totalSupply = sub(_totalSupply,balances[_owner]);
}
function transfer(address _to, uint _value, bytes _data) public {
// sender must have enough tokens to transfer
require(balances[msg.sender] >= _value);
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = sub(balanceOf(msg.sender), _value);
balances[_to] = add(balances[_to], _value);
Transfer(msg.sender, _to, _value);
}
function transfer(address _to, uint _value) public {
// sender must have enough tokens to transfer
require(balances[msg.sender] >= _value);
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = sub(balanceOf(msg.sender), _value);
balances[_to] = add(balances[_to], _value);
Transfer(msg.sender, _to, _value);
}
// fallback to receive ETH into contract and send tokens back based on current exchange rate
function () payable public {
require(msg.value > 0);
uint incomingValueAsEth = div(msg.value,1 ether);
uint256 _calcToken = mul(incomingValueAsEth,_tokePerEth); // value of payment in tokens
require(_totalSupply >= _calcToken);
_totalSupply = sub(_totalSupply, _calcToken);
balances[msg.sender] = add(balances[msg.sender], _calcToken);
Transfer(this, msg.sender, _calcToken);
}
function changePayRate(uint256 _newRate) public {
require((msg.sender == _owner) && (_newRate >= 0));
_tokePerEth = _newRate;
}
function safeWithdrawal(address _receiver, uint256 _value) public {
require((msg.sender == _owner));
uint256 valueAsEth = mul(_value,1 ether);
require(valueAsEth < this.balance);
_receiver.send(valueAsEth);
}
function balanceOf(address _receiver) public constant returns (uint balance) {
return balances[_receiver];
}
function changeOwner(address _receiver) public {
require(msg.sender == _owner);
_owner = _receiver;
}
function totalSupply() public constant returns (uint256) {
return _totalSupply;
}
function updateTokenBalance(uint256 newBalance) public {
require(msg.sender == _owner);
_totalSupply = add(_totalSupply,newBalance);
}
function mul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
require(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal pure returns (uint) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
require(b <= a);
return a - b;
}
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
require(c >= a);
return c;
}
}
{
"compilationTarget": {
"META.sol": "META"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 0
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_receiver","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newBalance","type":"uint256"}],"name":"updateTokenBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"dev","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":"_receiver","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","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":"_owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_receiver","type":"address"},{"name":"_value","type":"uint256"}],"name":"safeWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"_tokePerEth","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newRate","type":"uint256"}],"name":"changePayRate","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"}]