Created
April 29, 2022 10:33
-
-
Save TobiCrackIT/a0ab8d4f32e6f8335063a2caaa623482 to your computer and use it in GitHub Desktop.
RaceToken
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
pragma solidity >=0.7.0 <0.9.0; | |
contract RaceToken { | |
string _name = "Race Token"; | |
string _symbol = "RCT"; | |
address deployer; | |
mapping(address => uint) balances; | |
mapping(uint => bool) blockMined; | |
mapping(address => mapping(address => uint)) allowances; | |
uint totalMinted = 1000000 * 1e8; | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | |
constructor(){ | |
deployer = msg.sender; | |
balances[deployer]=1000000 * 1e8; | |
} | |
function name() public view returns (string memory){ | |
return _name; | |
} | |
function symbol() public view returns (string memory) { | |
return _symbol; | |
} | |
function decimals() public pure returns (uint8) { | |
return 8; | |
} | |
function totalSupply() public pure returns (uint256) { | |
return 10000000 * 1e8; | |
} | |
function balanceOf(address _owner) public view returns (uint256 balance) { | |
return balances[_owner]; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool success) { | |
assert(balances[msg.sender]>=_value); | |
balances[msg.sender]-=_value; | |
balances[_to]+=_value; | |
emit Transfer(msg.sender, _to, _value); | |
return true; | |
} | |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { | |
if(balances[_from]<_value){ | |
return false; | |
} | |
if(allowances[_from][msg.sender]<_value){ | |
return false; | |
} | |
balances[_from] -= _value; | |
balances[_to] += _value; | |
allowances[_from][msg.sender]-=_value; | |
emit Transfer(_from, _to, _value); | |
return true; | |
} | |
function approve(address _spender, uint256 _value) public returns (bool success) { | |
allowances[msg.sender][_spender] = _value; | |
emit Approval(msg.sender, _spender, _value); | |
} | |
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { | |
return allowances[_owner][_spender]; | |
} | |
function mine() public returns(bool success){ | |
if(blockMined[block.number]){ | |
return false; | |
} | |
if(block.number % 10 != 0 ){ | |
return false; | |
} | |
balances[msg.sender] = balances[msg.sender] + 10*1e8; | |
totalMinted = totalMinted + 10*1e8; | |
blockMined[block.number]=true; | |
return true; | |
} | |
function getCurrentBlock() public view returns(uint){ | |
return block.number; | |
} | |
function isMined(uint blockNumber) public view returns(bool){ | |
return blockMined[blockNumber]; | |
} | |
//0x980f400ed012a683930b4a61ac22bce1c70041e1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment