Skip to content

Instantly share code, notes, and snippets.

@omgbbqhaxx
Last active April 2, 2020 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omgbbqhaxx/7e9ddf69e112643f37d7f97aafe8d759 to your computer and use it in GitHub Desktop.
Save omgbbqhaxx/7e9ddf69e112643f37d7f97aafe8d759 to your computer and use it in GitHub Desktop.
pragma solidity ^0.6.3;
interface tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external;
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
* This contract neet to support referals system for erush's fast growth.
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20 {
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Burn(address indexed from, uint256 value);
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0x0));
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
}
contract contractBTT {
using SafeMath for uint;
address creator;
address erush = 0x2040FD61e31250D2913c9bfe61510cAC3bF212cB; //0x6EA53dfc58C5cbf68a799EdD208cb3A905db5939;
mapping (string => uint256 ) public balances;
mapping (string => bool) public pstatus;
mapping (string => bool) public wstat;
mapping (string => int) public oddeven;
constructor() public { creator = msg.sender; }
function uintToString(uint256 v) internal pure returns(string memory str) {
uint maxlength = 100;
bytes memory reversed = new bytes(maxlength);
uint i = 0;
while (v != 0) {
uint remainder = v % 10;
v = v / 10;
reversed[i++] = byte(uint8(48 + remainder));
}
bytes memory s = new bytes(i + 1);
for (uint j = 0; j <= i; j++) {
s[j] = reversed[i - j];
}
str = string(s);
}
function nAddrHash() view public returns (uint256) {
return uint256(msg.sender) % 10000000000;
}
function append(string memory a, string memory b) internal pure returns (string memory) {
return string(abi.encodePacked(a,"-",b));
}
function nMixAddrandBlock() private view returns(string memory) {
uint256 _bnum = block.number;
return append(uintToString(nAddrHash()),uintToString(_bnum));
}
function nMixAddrandSpBlock(uint256 bnum) private view returns(string memory) {
return append(uintToString(nAddrHash()),uintToString(bnum));
}
function checkReward(uint256 _bnum) private view returns(bool) {
uint pb = uint256(blockhash(_bnum+1))%2;
if(pb == 0 && oddeven[nMixAddrandSpBlock(_bnum)] == 2) {
return true;
} else if(pb == 1 && oddeven[nMixAddrandSpBlock(_bnum)] == 1) {
return true;
} else {
return false;
}
}
function yinyang(uint tokens, int _oddeven) public {
require(pstatus[nMixAddrandBlock() ] == false);
require(wstat[nMixAddrandBlock() ] == false);
balances[nMixAddrandBlock()] = tokens;
pstatus[nMixAddrandBlock()] = true;
oddeven[nMixAddrandBlock()] = _oddeven;
ERC20(erush).transferFrom(msg.sender, address(this), tokens);
}
function returnTokens(uint256 bnum) public {
require(pstatus[nMixAddrandSpBlock(bnum) ] == true); //if this is true thats mean he have a ticket.
require(wstat[nMixAddrandSpBlock(bnum) ] == false);
ERC20(erush).transfer(msg.sender, balances[nMixAddrandSpBlock(bnum)]);
wstat[nMixAddrandBlock()] = true;
balances[nMixAddrandSpBlock(bnum)] = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment