pragma solidity ^0.4.0;
contract Register {
uint256 public totalClaimed=0;
uint256 public totalBurned=0;
uint256 public totalConverted=0;
uint256 minClaimedValue;
address owner;
address zyroAddr=0x1f6bd8766f8a8AA58F7441C8dd3709aFA3a56202;
mapping(string => uint256) claimRecords;
mapping(string => uint256) convertedRecords;
constructor(uint256 _minValue) public {
owner=msg.sender;
minClaimedValue=_minValue;
}
event Claim(address indexed _from,string _to,uint256 _value);
event BurnToken(uint256 indexed _value);
function claim(string _zilaccount,uint256 _value) public returns (bool sucess) {
require(_value>minClaimedValue);
bytes4 transferFromMethodId = bytes4(keccak256("transferFrom(address,address,uint256)"));
if(zyroAddr.call(transferFromMethodId, msg.sender, address(this), _value)){
claimRecords[_zilaccount]+=_value;
totalClaimed+=_value;
emit Claim(msg.sender,_zilaccount,_value);
return true;
}
return false;
}
function burn() public returns (bool sucess) {
bytes4 transferMethodId = bytes4(keccak256("transfer(address,uint256)"));
uint256 _value = totalClaimed - totalBurned;
if(zyroAddr.call(transferMethodId, address(0), _value)){
totalBurned+=_value;
emit BurnToken(_value);
return true;
}
return false;
}
function convert(string _zilaccount, uint256 _value) public {
require(msg.sender == owner);
convertedRecords[_zilaccount]+=_value;
totalConverted+=_value;
if(claimRecords[_zilaccount] >= _value){
claimRecords[_zilaccount]-=_value;
}
}
function getClaimedByAddr(string _zilaccount) public view returns(uint256){
return claimRecords[_zilaccount];
}
function getConvertedByAddr(string _zilaccount) public view returns(uint256){
return convertedRecords[_zilaccount];
}
function getTotalClaimed() public view returns (uint256){
return totalClaimed;
}
function getTotalBurned() public view returns (uint256){
return totalBurned;
}
}
{
"compilationTarget": {
"Register.sol": "Register"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"constant":false,"inputs":[{"name":"_zilaccount","type":"string"},{"name":"_value","type":"uint256"}],"name":"convert","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"burn","outputs":[{"name":"sucess","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_zilaccount","type":"string"}],"name":"getClaimedByAddr","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTotalClaimed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalConverted","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTotalBurned","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_zilaccount","type":"string"}],"name":"getConvertedByAddr","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalClaimed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalBurned","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_zilaccount","type":"string"},{"name":"_value","type":"uint256"}],"name":"claim","outputs":[{"name":"sucess","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_minValue","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"_to","type":"string"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_value","type":"uint256"}],"name":"BurnToken","type":"event"}]