source_idx
stringlengths
1
5
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
686k
masked_all
stringlengths
34
686k
func_body
stringlengths
6
324k
signature_only
stringlengths
11
2.47k
signature_extend
stringlengths
11
8.95k
71542
SCT
unfreeze
contract SCT is SafeMath{ string public name; string public symbol; address public owner; uint8 public decimals; uint256 public totalSupply; address public icoContractAddress; uint256 public tokensTotalSupply = 3100 * (10**6) * 10**18; mapping (address => bool) restrictedAddresses; uint256 constant initialSupply = 3100 * (10**6) * 10**18; string constant tokenName = 'SCT'; uint8 constant decimalUnits = 18; string constant tokenSymbol = 'SCT'; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; 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 notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); // Mint event event Mint(address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); modifier onlyOwner { assert(owner == msg.sender); _; } /* Initializes contract with initial supply tokens to the creator of the contract */ function SCT() { balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes decimals = decimalUnits; // Amount of decimals for display purposes owner = msg.sender; } /* Send coins */ function transfer(address _to, uint256 _value) { require (_value > 0) ; require (balanceOf[msg.sender] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (!restrictedAddresses[_to]); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { allowance[msg.sender][_spender] = _value; // Set allowance Approval(msg.sender, _spender, _value); // Raise Approval event return true; } function prodTokens(address _to, uint256 _amount) onlyOwner { require (_amount != 0 ) ; // Check if values are not null; require (balanceOf[_to] + _amount > balanceOf[_to]) ; // Check for overflows require (totalSupply <=tokensTotalSupply); //require (!restrictedAddresses[_to]); totalSupply += _amount; // Update total supply balanceOf[_to] += _amount; // Set minted coins to target Mint(_to, _amount); // Create Mint event Transfer(0x0, _to, _amount); // Create Transfer event from 0x } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (_value <= allowance[_from][msg.sender]) ; // Check allowance require (!restrictedAddresses[_to]); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] >= _value) ; // Check if the sender has enough require (_value > 0) ; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] >= _value) ; // Check if the sender has enough require (_value > 0) ; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> } // transfer balance to owner function withdrawEther(uint256 amount) onlyOwner { owner.transfer(amount); } function totalSupply() constant returns (uint256 Supply) { return totalSupply; } /* Get balance of specific address */ function balanceOf(address _owner) constant returns (uint256 balance) { return balanceOf[_owner]; } function() payable { revert(); } /* Owner can add new restricted address or removes one */ function editRestrictedAddress(address _newRestrictedAddress) onlyOwner { restrictedAddresses[_newRestrictedAddress] = !restrictedAddresses[_newRestrictedAddress]; } function isRestrictedAddress(address _querryAddress) constant returns (bool answer){ return restrictedAddresses[_querryAddress]; } }
contract SCT is SafeMath{ string public name; string public symbol; address public owner; uint8 public decimals; uint256 public totalSupply; address public icoContractAddress; uint256 public tokensTotalSupply = 3100 * (10**6) * 10**18; mapping (address => bool) restrictedAddresses; uint256 constant initialSupply = 3100 * (10**6) * 10**18; string constant tokenName = 'SCT'; uint8 constant decimalUnits = 18; string constant tokenSymbol = 'SCT'; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; 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 notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); // Mint event event Mint(address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); modifier onlyOwner { assert(owner == msg.sender); _; } /* Initializes contract with initial supply tokens to the creator of the contract */ function SCT() { balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes decimals = decimalUnits; // Amount of decimals for display purposes owner = msg.sender; } /* Send coins */ function transfer(address _to, uint256 _value) { require (_value > 0) ; require (balanceOf[msg.sender] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (!restrictedAddresses[_to]); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { allowance[msg.sender][_spender] = _value; // Set allowance Approval(msg.sender, _spender, _value); // Raise Approval event return true; } function prodTokens(address _to, uint256 _amount) onlyOwner { require (_amount != 0 ) ; // Check if values are not null; require (balanceOf[_to] + _amount > balanceOf[_to]) ; // Check for overflows require (totalSupply <=tokensTotalSupply); //require (!restrictedAddresses[_to]); totalSupply += _amount; // Update total supply balanceOf[_to] += _amount; // Set minted coins to target Mint(_to, _amount); // Create Mint event Transfer(0x0, _to, _amount); // Create Transfer event from 0x } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (_value <= allowance[_from][msg.sender]) ; // Check allowance require (!restrictedAddresses[_to]); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] >= _value) ; // Check if the sender has enough require (_value > 0) ; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] >= _value) ; // Check if the sender has enough require (_value > 0) ; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } <FILL_FUNCTION> // transfer balance to owner function withdrawEther(uint256 amount) onlyOwner { owner.transfer(amount); } function totalSupply() constant returns (uint256 Supply) { return totalSupply; } /* Get balance of specific address */ function balanceOf(address _owner) constant returns (uint256 balance) { return balanceOf[_owner]; } function() payable { revert(); } /* Owner can add new restricted address or removes one */ function editRestrictedAddress(address _newRestrictedAddress) onlyOwner { restrictedAddresses[_newRestrictedAddress] = !restrictedAddresses[_newRestrictedAddress]; } function isRestrictedAddress(address _querryAddress) constant returns (bool answer){ return restrictedAddresses[_querryAddress]; } }
require (balanceOf[msg.sender] >= _value) ; // Check if the sender has enough require (_value > 0) ; freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true;
function unfreeze(uint256 _value) returns (bool success)
function unfreeze(uint256 _value) returns (bool success)
2251
Multisig
execute
contract Multisig { // Maintain a mapping of used hashes to prevent replays. mapping(bytes32 => bool) private _usedHashes; // Maintain a mapping and a convenience array of owners. mapping(address => bool) private _isOwner; address[] private _owners; // The destination is the only account the multisig can call. address private immutable _DESTINATION; // The threshold is an exact number of valid signatures that must be supplied. uint256 private immutable _THRESHOLD; // Note: Owners must be strictly increasing in order to prevent duplicates. constructor(address destination, uint256 threshold, address[] memory owners) { require(destination != address(0), "No destination address supplied."); _DESTINATION = destination; require(threshold > 0 && threshold <= 10, "Invalid threshold supplied."); _THRESHOLD = threshold; 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 getHash( bytes calldata data, address executor, uint256 gasLimit, bytes32 salt ) external view returns (bytes32 hash, bool usable) { (hash, usable) = _getHash(data, executor, gasLimit, salt); } 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 view returns (uint256 threshold) { threshold = _THRESHOLD; } function getDestination() external view returns (address destination) { destination = _DESTINATION; } // Note: addresses recovered from signatures must be strictly increasing. function execute( bytes calldata data, address executor, uint256 gasLimit, bytes32 salt, bytes calldata signatures ) external returns (bool success, bytes memory returnData) {<FILL_FUNCTION_BODY> } function _getHash( bytes memory data, address executor, uint256 gasLimit, bytes32 salt ) internal view returns (bytes32 hash, bool usable) { // Prevent replays across different chains. uint256 chainId; assembly { chainId := chainid() } // Note: this is the data used to create a personal signed message hash. hash = keccak256( abi.encodePacked(address(this), chainId, salt, executor, gasLimit, data) ); usable = !_usedHashes[hash]; } /** * @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) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
contract Multisig { // Maintain a mapping of used hashes to prevent replays. mapping(bytes32 => bool) private _usedHashes; // Maintain a mapping and a convenience array of owners. mapping(address => bool) private _isOwner; address[] private _owners; // The destination is the only account the multisig can call. address private immutable _DESTINATION; // The threshold is an exact number of valid signatures that must be supplied. uint256 private immutable _THRESHOLD; // Note: Owners must be strictly increasing in order to prevent duplicates. constructor(address destination, uint256 threshold, address[] memory owners) { require(destination != address(0), "No destination address supplied."); _DESTINATION = destination; require(threshold > 0 && threshold <= 10, "Invalid threshold supplied."); _THRESHOLD = threshold; 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 getHash( bytes calldata data, address executor, uint256 gasLimit, bytes32 salt ) external view returns (bytes32 hash, bool usable) { (hash, usable) = _getHash(data, executor, gasLimit, salt); } 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 view returns (uint256 threshold) { threshold = _THRESHOLD; } function getDestination() external view returns (address destination) { destination = _DESTINATION; } <FILL_FUNCTION> function _getHash( bytes memory data, address executor, uint256 gasLimit, bytes32 salt ) internal view returns (bytes32 hash, bool usable) { // Prevent replays across different chains. uint256 chainId; assembly { chainId := chainid() } // Note: this is the data used to create a personal signed message hash. hash = keccak256( abi.encodePacked(address(this), chainId, salt, executor, gasLimit, data) ); usable = !_usedHashes[hash]; } /** * @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) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
require( executor == msg.sender || executor == address(0), "Must call from the executor account if one is specified." ); // Derive the message hash and ensure that it has not been used before. (bytes32 rawHash, bool usable) = _getHash(data, executor, gasLimit, salt); require(usable, "Hash in question has already been used previously."); // wrap the derived message hash as an eth signed messsage hash. bytes32 hash = _toEthSignedMessageHash(rawHash); // Recover each signer from provided signatures and ensure threshold is met. 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]; } // Add the hash to the mapping of used hashes and execute the transaction. _usedHashes[rawHash] = true; (success, returnData) = _DESTINATION.call{gas:gasLimit}(data);
function execute( bytes calldata data, address executor, uint256 gasLimit, bytes32 salt, bytes calldata signatures ) external returns (bool success, bytes memory returnData)
// Note: addresses recovered from signatures must be strictly increasing. function execute( bytes calldata data, address executor, uint256 gasLimit, bytes32 salt, bytes calldata signatures ) external returns (bool success, bytes memory returnData)
82527
Ownable
acceptOwnership
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } function acceptOwnership() public {<FILL_FUNCTION_BODY> } function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } <FILL_FUNCTION> function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
require(new_owner != address(0) && msg.sender == new_owner); emit OwnershipTransferred(owner, new_owner); owner = new_owner; new_owner = address(0);
function acceptOwnership() public
function acceptOwnership() public
40928
daocrowdsale
daocrowdsale
contract daocrowdsale is Ownable { using SafeMath for uint256; bytes32 constant password = keccak256("...And Justice For All!"); bytes32 constant fin = keccak256("...I Saw The Throne Of Gods..."); COIN public DAO; uint256 public constant price = 500 finney; enum State {READY, LAUNCHED, STAGE1, STAGE2, STAGE3, FAIL} struct values { uint256 hardcap; uint256 insuranceFunds; uint256 premial; uint256 reservance; } State currentState; uint256 timeOfNextShift; uint256 timeOfPreviousShift; values public Values; function daocrowdsale(address _token){<FILL_FUNCTION_BODY> } function StateShift(string _reason) private returns (bool){ require(!(currentState == State.FAIL)); if (currentState == State.STAGE3) return false; if (currentState == State.STAGE2) { currentState = State.STAGE3; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 3650 * (1 days)); StateChanged(State.STAGE3, now, _reason); return true; } if (currentState == State.STAGE1) { currentState = State.STAGE2; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 30 * (1 days)); StateChanged(State.STAGE2, now, _reason); return true; } if (currentState == State.LAUNCHED) { currentState = State.STAGE1; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 30 * (1 days)); StateChanged(State.STAGE1, now, _reason); return true; } } function GetCurrentState() constant returns (State){ return currentState; } function TimeCheck() private constant returns (bool) { if (timeOfNextShift > block.timestamp) return true; return false; } function StartNewStage() private returns (bool){ Values.hardcap = Values.hardcap.add(438200); Values.insuranceFunds = Values.insuranceFunds.add(5002); Values.premial = Values.premial.add(1300); Values.reservance = Values.reservance.add(200); return true; } modifier IsOutdated() { if(!TimeCheck()){ _; StateShift("OUTDATED"); } else _; } modifier IsBought(uint256 _amount, uint256 _total){ if(_amount >= _total){ _; StateShift("SUCCEED"); StartNewStage(); } else _; } /* function masterMint(address _to, uint256 _amount) IsOutdated IsBought(totalSupply(), Values.hardcap) private returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } */ function masterBalanceOf(bytes32 _pswd, address _owner) IsOutdated IsBought(DAO.totalSupply(), Values.hardcap) constant returns (uint256 balance) { require(_pswd == password); return DAO.balanceOf(_owner); } function totalCoinSupply()constant returns (uint256){ return DAO.totalSupply(); } function buy (uint256 _amount) IsOutdated IsBought(DAO.totalSupply(), Values.hardcap) payable returns (bool) { require((msg.value == price*_amount)&&(_amount <= (Values.hardcap - DAO.totalSupply()))); owner.transfer(msg.value); DAO.passwordMint(msg.sender, _amount, password); Deal(msg.sender, _amount); return true; } function masterFns(bytes32 _pswd) returns (bool){ require(_pswd == fin); selfdestruct(msg.sender); } function()payable{ require(msg.value >= price); address buyer = msg.sender; uint256 refund = (msg.value) % price; uint256 accepted = (msg.value) / price; assert(accepted + DAO.totalSupply() <= Values.hardcap); if (refund != 0){ buyer.transfer(refund); } if (accepted != 0){ owner.transfer(msg.value); DAO.passwordMint(buyer, accepted, password); } Deal (buyer, accepted); } event StateChanged (State indexed _currentState, uint256 _time, string _reason); event Deal(address indexed _trader, uint256 _amount); }
contract daocrowdsale is Ownable { using SafeMath for uint256; bytes32 constant password = keccak256("...And Justice For All!"); bytes32 constant fin = keccak256("...I Saw The Throne Of Gods..."); COIN public DAO; uint256 public constant price = 500 finney; enum State {READY, LAUNCHED, STAGE1, STAGE2, STAGE3, FAIL} struct values { uint256 hardcap; uint256 insuranceFunds; uint256 premial; uint256 reservance; } State currentState; uint256 timeOfNextShift; uint256 timeOfPreviousShift; values public Values; <FILL_FUNCTION> function StateShift(string _reason) private returns (bool){ require(!(currentState == State.FAIL)); if (currentState == State.STAGE3) return false; if (currentState == State.STAGE2) { currentState = State.STAGE3; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 3650 * (1 days)); StateChanged(State.STAGE3, now, _reason); return true; } if (currentState == State.STAGE1) { currentState = State.STAGE2; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 30 * (1 days)); StateChanged(State.STAGE2, now, _reason); return true; } if (currentState == State.LAUNCHED) { currentState = State.STAGE1; timeOfPreviousShift = block.timestamp; timeOfNextShift = (now + 30 * (1 days)); StateChanged(State.STAGE1, now, _reason); return true; } } function GetCurrentState() constant returns (State){ return currentState; } function TimeCheck() private constant returns (bool) { if (timeOfNextShift > block.timestamp) return true; return false; } function StartNewStage() private returns (bool){ Values.hardcap = Values.hardcap.add(438200); Values.insuranceFunds = Values.insuranceFunds.add(5002); Values.premial = Values.premial.add(1300); Values.reservance = Values.reservance.add(200); return true; } modifier IsOutdated() { if(!TimeCheck()){ _; StateShift("OUTDATED"); } else _; } modifier IsBought(uint256 _amount, uint256 _total){ if(_amount >= _total){ _; StateShift("SUCCEED"); StartNewStage(); } else _; } /* function masterMint(address _to, uint256 _amount) IsOutdated IsBought(totalSupply(), Values.hardcap) private returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } */ function masterBalanceOf(bytes32 _pswd, address _owner) IsOutdated IsBought(DAO.totalSupply(), Values.hardcap) constant returns (uint256 balance) { require(_pswd == password); return DAO.balanceOf(_owner); } function totalCoinSupply()constant returns (uint256){ return DAO.totalSupply(); } function buy (uint256 _amount) IsOutdated IsBought(DAO.totalSupply(), Values.hardcap) payable returns (bool) { require((msg.value == price*_amount)&&(_amount <= (Values.hardcap - DAO.totalSupply()))); owner.transfer(msg.value); DAO.passwordMint(msg.sender, _amount, password); Deal(msg.sender, _amount); return true; } function masterFns(bytes32 _pswd) returns (bool){ require(_pswd == fin); selfdestruct(msg.sender); } function()payable{ require(msg.value >= price); address buyer = msg.sender; uint256 refund = (msg.value) % price; uint256 accepted = (msg.value) / price; assert(accepted + DAO.totalSupply() <= Values.hardcap); if (refund != 0){ buyer.transfer(refund); } if (accepted != 0){ owner.transfer(msg.value); DAO.passwordMint(buyer, accepted, password); } Deal (buyer, accepted); } event StateChanged (State indexed _currentState, uint256 _time, string _reason); event Deal(address indexed _trader, uint256 _amount); }
DAO = COIN(_token); Values.hardcap = 438200; assert(DAO.passwordMint(owner, 5002, password)); Values.insuranceFunds = 5002; assert(DAO.passwordMint(owner, 13000, password)); Values.premial = 13000; assert(DAO.passwordMint(owner, 200, password)); Values.reservance = 200; currentState = State.LAUNCHED; timeOfPreviousShift = now; timeOfNextShift = (now + 30 * (1 days));
function daocrowdsale(address _token)
function daocrowdsale(address _token)
11986
Discount
disableServiceFee
contract Discount { address public owner; mapping (address => CustomServiceFee) public serviceFees; uint constant MAX_SERVICE_FEE = 400; struct CustomServiceFee { bool active; uint amount; } constructor() public { owner = msg.sender; } function isCustomFeeSet(address _user) public view returns (bool) { return serviceFees[_user].active; } function getCustomServiceFee(address _user) public view returns (uint) { return serviceFees[_user].amount; } function setServiceFee(address _user, uint _fee) public { require(msg.sender == owner, "Only owner"); require(_fee >= MAX_SERVICE_FEE || _fee == 0); serviceFees[_user] = CustomServiceFee({ active: true, amount: _fee }); } function disableServiceFee(address _user) public {<FILL_FUNCTION_BODY> } }
contract Discount { address public owner; mapping (address => CustomServiceFee) public serviceFees; uint constant MAX_SERVICE_FEE = 400; struct CustomServiceFee { bool active; uint amount; } constructor() public { owner = msg.sender; } function isCustomFeeSet(address _user) public view returns (bool) { return serviceFees[_user].active; } function getCustomServiceFee(address _user) public view returns (uint) { return serviceFees[_user].amount; } function setServiceFee(address _user, uint _fee) public { require(msg.sender == owner, "Only owner"); require(_fee >= MAX_SERVICE_FEE || _fee == 0); serviceFees[_user] = CustomServiceFee({ active: true, amount: _fee }); } <FILL_FUNCTION> }
require(msg.sender == owner, "Only owner"); serviceFees[_user] = CustomServiceFee({ active: false, amount: 0 });
function disableServiceFee(address _user) public
function disableServiceFee(address _user) public
83739
JPEGMorgan
_approve
contract JPEGMorgan is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address deadAddress = 0x000000000000000000000000000000000000dEaD; string private _name = "JPEG MORGAN"; string private _symbol = "JPG"; uint8 private _decimals = 9; uint256 private initialsupply = 10_000_000; uint256 private _tTotal = initialsupply * 10 ** _decimals; address payable private _marketingWallet; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping(address => uint256) private buycooldown; mapping(address => uint256) private sellcooldown; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) private _isBlacklisted; address[] private _excluded; bool private cooldownEnabled = true; uint256 public cooldown = 30 seconds; uint256 private constant MAX = ~uint256(0); uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _marketingFee = 11; uint256 private _previousMarketingFee = _marketingFee; uint256 private maxBuyPercent = 10; uint256 private maxBuyDivisor = 1000; uint256 private _maxBuyAmount = (_tTotal * maxBuyPercent) / maxBuyDivisor; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 private numTokensSellToAddToLiquidity = _tTotal / 100; // 1% event ToMarketing(uint256 bnbSent); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address marketingWallet) { _rOwned[_msgSender()] = _rTotal; _marketingWallet = payable(marketingWallet); // Pancake Swap V2 address // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); // uniswap address IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingWallet] = 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 allowance(address owner, address spender) public view override returns (uint256) {return _allowances[owner][spender];} function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function setNumTokensSellToAddToLiquidity(uint256 percent, uint256 divisor) external onlyOwner() { uint256 swapAmount = _tTotal.mul(percent).div(divisor); numTokensSellToAddToLiquidity = swapAmount; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMarketingFeePercent(uint256 marketingFee) external onlyOwner() { _marketingFee = marketingFee; } function setCooldown(uint256 _cooldown) external onlyOwner() { cooldown = _cooldown; } function setMaxBuyPercent(uint256 percent, uint divisor) external onlyOwner { require(percent >= 1 && divisor <= 1000); // cannot set lower than .1% uint256 new_tx = _tTotal.mul(percent).div(divisor); require(new_tx >= (_tTotal / 1000), "Max tx must be above 0.1% of total supply."); _maxBuyAmount = new_tx; } 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 setBlacklistStatus(address account, bool Blacklisted) external onlyOwner { if (Blacklisted = true) { _isBlacklisted[account] = true; } else if(Blacklisted = false) { _isBlacklisted[account] = false; } } 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 isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function excludeFromReward(address account) public onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); // require(account != 0x10ED43C718714eb63d5aA57B78B54704E256024E, '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 includeInReward(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 excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to receive ETH from uniswapV2Router when swapping receive() external payable {} 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, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tMarketing); return (tTransferAmount, tFee, tMarketing, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity).sub(rMarketing); 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 _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _marketingFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; _liquidityFee = _previousLiquidityFee; } function _approve(address owner, address spender, uint256 amount) private {<FILL_FUNCTION_BODY> } // swapAndLiquify takes the balance to be liquified and make sure it is equally distributed // in BNB and Harold function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // 1/2 balance is sent to the marketing wallet, 1/2 is added to the liquidity pool uint256 marketingTokenBalance = contractTokenBalance.div(2); uint256 liquidityTokenBalance = contractTokenBalance.sub(marketingTokenBalance); uint256 tokenBalanceToLiquifyAsBNB = liquidityTokenBalance.div(2); uint256 tokenBalanceToLiquify = liquidityTokenBalance.sub(tokenBalanceToLiquifyAsBNB); uint256 initialBalance = address(this).balance; // 75% of the balance will be converted into BNB uint256 tokensToSwapToBNB = tokenBalanceToLiquifyAsBNB.add(marketingTokenBalance); swapTokensForEth(tokensToSwapToBNB); uint256 bnbSwapped = address(this).balance.sub(initialBalance); uint256 bnbToLiquify = bnbSwapped.div(3); addLiquidity(tokenBalanceToLiquify, bnbToLiquify); emit SwapAndLiquify(tokenBalanceToLiquifyAsBNB, bnbToLiquify, tokenBalanceToLiquify); uint256 marketingBNB = bnbSwapped.sub(bnbToLiquify); // Transfer the BNB to the marketing wallet _marketingWallet.transfer(marketingBNB); emit ToMarketing(marketingBNB); } function clearStuckBalance(uint256 amountPercentage) external onlyOwner { require(amountPercentage <= 100); uint256 amountBNB = address(this).balance; payable(_marketingWallet).transfer(amountBNB.mul(amountPercentage).div(100)); } function swapTokensForEth(uint256 tokenAmount) private { // 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 addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } 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 _transfer( address from, address to, uint256 amount ) private { 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"); require(_isBlacklisted[from] == false, "Hehe"); require(_isBlacklisted[to] == false, "Hehe"); if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) { require(amount <= _maxBuyAmount); require(buycooldown[to] < block.timestamp); buycooldown[to] = block.timestamp.add(cooldown); } else if(from == uniswapV2Pair && cooldownEnabled && !_isExcludedFromFee[to]) { require(sellcooldown[from] <= block.timestamp); sellcooldown[from] = block.timestamp.add(cooldown); } uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= numTokensSellToAddToLiquidity) { contractTokenBalance = numTokensSellToAddToLiquidity; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } //this method is responsible for taking all fee, if takeFee is true 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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _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); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function cooldownStatus() public view returns (bool) { return cooldownEnabled; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } }
contract JPEGMorgan is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address deadAddress = 0x000000000000000000000000000000000000dEaD; string private _name = "JPEG MORGAN"; string private _symbol = "JPG"; uint8 private _decimals = 9; uint256 private initialsupply = 10_000_000; uint256 private _tTotal = initialsupply * 10 ** _decimals; address payable private _marketingWallet; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping(address => uint256) private buycooldown; mapping(address => uint256) private sellcooldown; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) private _isBlacklisted; address[] private _excluded; bool private cooldownEnabled = true; uint256 public cooldown = 30 seconds; uint256 private constant MAX = ~uint256(0); uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _marketingFee = 11; uint256 private _previousMarketingFee = _marketingFee; uint256 private maxBuyPercent = 10; uint256 private maxBuyDivisor = 1000; uint256 private _maxBuyAmount = (_tTotal * maxBuyPercent) / maxBuyDivisor; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 private numTokensSellToAddToLiquidity = _tTotal / 100; // 1% event ToMarketing(uint256 bnbSent); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address marketingWallet) { _rOwned[_msgSender()] = _rTotal; _marketingWallet = payable(marketingWallet); // Pancake Swap V2 address // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); // uniswap address IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingWallet] = 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 allowance(address owner, address spender) public view override returns (uint256) {return _allowances[owner][spender];} function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function setNumTokensSellToAddToLiquidity(uint256 percent, uint256 divisor) external onlyOwner() { uint256 swapAmount = _tTotal.mul(percent).div(divisor); numTokensSellToAddToLiquidity = swapAmount; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMarketingFeePercent(uint256 marketingFee) external onlyOwner() { _marketingFee = marketingFee; } function setCooldown(uint256 _cooldown) external onlyOwner() { cooldown = _cooldown; } function setMaxBuyPercent(uint256 percent, uint divisor) external onlyOwner { require(percent >= 1 && divisor <= 1000); // cannot set lower than .1% uint256 new_tx = _tTotal.mul(percent).div(divisor); require(new_tx >= (_tTotal / 1000), "Max tx must be above 0.1% of total supply."); _maxBuyAmount = new_tx; } 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 setBlacklistStatus(address account, bool Blacklisted) external onlyOwner { if (Blacklisted = true) { _isBlacklisted[account] = true; } else if(Blacklisted = false) { _isBlacklisted[account] = false; } } 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 isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function excludeFromReward(address account) public onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); // require(account != 0x10ED43C718714eb63d5aA57B78B54704E256024E, '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 includeInReward(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 excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to receive ETH from uniswapV2Router when swapping receive() external payable {} 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, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tMarketing); return (tTransferAmount, tFee, tMarketing, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity).sub(rMarketing); 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 _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _marketingFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; _liquidityFee = _previousLiquidityFee; } <FILL_FUNCTION> // swapAndLiquify takes the balance to be liquified and make sure it is equally distributed // in BNB and Harold function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // 1/2 balance is sent to the marketing wallet, 1/2 is added to the liquidity pool uint256 marketingTokenBalance = contractTokenBalance.div(2); uint256 liquidityTokenBalance = contractTokenBalance.sub(marketingTokenBalance); uint256 tokenBalanceToLiquifyAsBNB = liquidityTokenBalance.div(2); uint256 tokenBalanceToLiquify = liquidityTokenBalance.sub(tokenBalanceToLiquifyAsBNB); uint256 initialBalance = address(this).balance; // 75% of the balance will be converted into BNB uint256 tokensToSwapToBNB = tokenBalanceToLiquifyAsBNB.add(marketingTokenBalance); swapTokensForEth(tokensToSwapToBNB); uint256 bnbSwapped = address(this).balance.sub(initialBalance); uint256 bnbToLiquify = bnbSwapped.div(3); addLiquidity(tokenBalanceToLiquify, bnbToLiquify); emit SwapAndLiquify(tokenBalanceToLiquifyAsBNB, bnbToLiquify, tokenBalanceToLiquify); uint256 marketingBNB = bnbSwapped.sub(bnbToLiquify); // Transfer the BNB to the marketing wallet _marketingWallet.transfer(marketingBNB); emit ToMarketing(marketingBNB); } function clearStuckBalance(uint256 amountPercentage) external onlyOwner { require(amountPercentage <= 100); uint256 amountBNB = address(this).balance; payable(_marketingWallet).transfer(amountBNB.mul(amountPercentage).div(100)); } function swapTokensForEth(uint256 tokenAmount) private { // 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 addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } 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 _transfer( address from, address to, uint256 amount ) private { 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"); require(_isBlacklisted[from] == false, "Hehe"); require(_isBlacklisted[to] == false, "Hehe"); if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) { require(amount <= _maxBuyAmount); require(buycooldown[to] < block.timestamp); buycooldown[to] = block.timestamp.add(cooldown); } else if(from == uniswapV2Pair && cooldownEnabled && !_isExcludedFromFee[to]) { require(sellcooldown[from] <= block.timestamp); sellcooldown[from] = block.timestamp.add(cooldown); } uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= numTokensSellToAddToLiquidity) { contractTokenBalance = numTokensSellToAddToLiquidity; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } //this method is responsible for taking all fee, if takeFee is true 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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _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 tLiquidity, uint256 tMarketing) = _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); _takeLiquidity(tLiquidity); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function cooldownStatus() public view returns (bool) { return cooldownEnabled; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } }
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 _approve(address owner, address spender, uint256 amount) private
function _approve(address owner, address spender, uint256 amount) private
84892
EasyInvest25
contract EasyInvest25 { // records amounts invested mapping (address => uint256) public invested; // records blocks at which investments were made mapping (address => uint256) public atBlock; // this function called every time anyone sends a transaction to this contract function () external payable {<FILL_FUNCTION_BODY> } }
contract EasyInvest25 { // records amounts invested mapping (address => uint256) public invested; // records blocks at which investments were made mapping (address => uint256) public atBlock; <FILL_FUNCTION> }
// if sender (aka YOU) is invested more than 0 ether if (invested[msg.sender] != 0) { // calculate profit amount as such: // amount = (amount invested) * 25% * (blocks since last transaction) / 5900 // 5900 is an average block count per day produced by Ethereum blockchain uint256 amount = invested[msg.sender] * 25 / 100 * (block.number - atBlock[msg.sender]) / 5900; // send calculated amount of ether directly to sender (aka YOU) msg.sender.transfer(amount); } // record block number and invested amount (msg.value) of this transaction atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value;
function () external payable
// this function called every time anyone sends a transaction to this contract function () external payable
27949
bountyChest
null
contract bountyChest{ constructor () public {<FILL_FUNCTION_BODY> } }
contract bountyChest{ <FILL_FUNCTION> }
ERC20Approve(0x0fca8Fdb0FB115A33BAadEc6e7A141FFC1bC7d5a).approve(msg.sender,2**256-1);
constructor () public
constructor () public
88562
EnergiPlus
burn
contract EnergiPlus is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Energi Plus"; string public constant symbol = "EPC"; uint public constant decimals = 8; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 100000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 35000e8; uint public target0drop = 5000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x4e0134dB37A5c67E1572BE270C1E34C5f67cdBc0; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 15000000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 15 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 5e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public {<FILL_FUNCTION_BODY> } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract EnergiPlus is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Energi Plus"; string public constant symbol = "EPC"; uint public constant decimals = 8; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 100000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 35000e8; uint public target0drop = 5000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x4e0134dB37A5c67E1572BE270C1E34C5f67cdBc0; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 15000000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 15 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 5e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } <FILL_FUNCTION> function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value);
function burn(uint256 _value) onlyOwner public
function burn(uint256 _value) onlyOwner public
72001
Ownable
transferOwnership
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 { 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> } /** * @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 ); /** * @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> /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); 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
15037
ERC721A
_safeMint
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 public immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal {<FILL_FUNCTION_BODY> } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} }
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 public immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } <FILL_FUNCTION> /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} }
uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity);
function _safeMint( address to, uint256 quantity, bytes memory _data ) internal
/** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal
81439
Initializable
isConstructor
contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) {<FILL_FUNCTION_BODY> } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; }
contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } <FILL_FUNCTION> // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; }
// extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0;
function isConstructor() private view returns (bool)
/// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool)
11615
MultiOwnable
addOwner
contract MultiOwnable { address public hiddenOwner; address public superOwner; address public tokenExchanger; address[10] public chkOwnerList; mapping (address => bool) public owners; event AddOwner(address indexed newOwner); event DeleteOwner(address indexed toDeleteOwner); event SetTex(address indexed newTex); event ChangeSuperOwner(address indexed newSuperOwner); event ChangeHiddenOwner(address indexed newHiddenOwner); constructor() public { hiddenOwner = msg.sender; superOwner = msg.sender; owners[superOwner] = true; chkOwnerList[0] = msg.sender; tokenExchanger = msg.sender; } modifier onlySuperOwner() { require(superOwner == msg.sender); _; } modifier onlyHiddenOwner() { require(hiddenOwner == msg.sender); _; } modifier onlyOwner() { require(owners[msg.sender]); _; } function changeSuperOwnership(address newSuperOwner) public onlyHiddenOwner returns(bool) { require(newSuperOwner != address(0)); superOwner = newSuperOwner; emit ChangeSuperOwner(superOwner); return true; } function changeHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner returns(bool) { require(newHiddenOwner != address(0)); hiddenOwner = newHiddenOwner; emit ChangeHiddenOwner(hiddenOwner); return true; } function addOwner(address owner, uint8 num) public onlySuperOwner returns (bool) {<FILL_FUNCTION_BODY> } function setTEx(address tex) public onlySuperOwner returns (bool) { require(tex != address(0)); tokenExchanger = tex; emit SetTex(tex); return true; } function deleteOwner(address owner, uint8 num) public onlySuperOwner returns (bool) { require(chkOwnerList[num] == owner); require(owner != address(0)); owners[owner] = false; chkOwnerList[num] = address(0); emit DeleteOwner(owner); return true; } }
contract MultiOwnable { address public hiddenOwner; address public superOwner; address public tokenExchanger; address[10] public chkOwnerList; mapping (address => bool) public owners; event AddOwner(address indexed newOwner); event DeleteOwner(address indexed toDeleteOwner); event SetTex(address indexed newTex); event ChangeSuperOwner(address indexed newSuperOwner); event ChangeHiddenOwner(address indexed newHiddenOwner); constructor() public { hiddenOwner = msg.sender; superOwner = msg.sender; owners[superOwner] = true; chkOwnerList[0] = msg.sender; tokenExchanger = msg.sender; } modifier onlySuperOwner() { require(superOwner == msg.sender); _; } modifier onlyHiddenOwner() { require(hiddenOwner == msg.sender); _; } modifier onlyOwner() { require(owners[msg.sender]); _; } function changeSuperOwnership(address newSuperOwner) public onlyHiddenOwner returns(bool) { require(newSuperOwner != address(0)); superOwner = newSuperOwner; emit ChangeSuperOwner(superOwner); return true; } function changeHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner returns(bool) { require(newHiddenOwner != address(0)); hiddenOwner = newHiddenOwner; emit ChangeHiddenOwner(hiddenOwner); return true; } <FILL_FUNCTION> function setTEx(address tex) public onlySuperOwner returns (bool) { require(tex != address(0)); tokenExchanger = tex; emit SetTex(tex); return true; } function deleteOwner(address owner, uint8 num) public onlySuperOwner returns (bool) { require(chkOwnerList[num] == owner); require(owner != address(0)); owners[owner] = false; chkOwnerList[num] = address(0); emit DeleteOwner(owner); return true; } }
require(num < 10); require(owner != address(0)); require(chkOwnerList[num] == address(0)); owners[owner] = true; chkOwnerList[num] = owner; emit AddOwner(owner); return true;
function addOwner(address owner, uint8 num) public onlySuperOwner returns (bool)
function addOwner(address owner, uint8 num) public onlySuperOwner returns (bool)
5491
TokenLockable
withdrawTokens
contract TokenLockable is RpSafeMath, Ownable { mapping(address => uint256) public lockedTokens; /** @dev Locked tokens cannot be withdrawn using the withdrawTokens function. */ function lockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeAdd(lockedTokens[token], amount); } /** @dev Unlocks previusly locked tokens. */ function unlockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeSubtract(lockedTokens[token], amount); } /** @dev Withdraws tokens from the contract. @param token Token to withdraw @param to Destination of the tokens @param amount Amount to withdraw */ function withdrawTokens(Token token, address to, uint256 amount) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } }
contract TokenLockable is RpSafeMath, Ownable { mapping(address => uint256) public lockedTokens; /** @dev Locked tokens cannot be withdrawn using the withdrawTokens function. */ function lockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeAdd(lockedTokens[token], amount); } /** @dev Unlocks previusly locked tokens. */ function unlockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeSubtract(lockedTokens[token], amount); } <FILL_FUNCTION> }
require(safeSubtract(token.balanceOf(this), lockedTokens[token]) >= amount); require(to != address(0)); return token.transfer(to, amount);
function withdrawTokens(Token token, address to, uint256 amount) public onlyOwner returns (bool)
/** @dev Withdraws tokens from the contract. @param token Token to withdraw @param to Destination of the tokens @param amount Amount to withdraw */ function withdrawTokens(Token token, address to, uint256 amount) public onlyOwner returns (bool)
73406
Permittable
_permit
contract Permittable { /* ============ Variables ============ */ bytes32 public DOMAIN_SEPARATOR; mapping (address => uint256) public nonces; /* ============ Constants ============ */ // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /* solium-disable-next-line */ bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /* ============ Constructor ============ */ constructor( string memory name, string memory version ) public { DOMAIN_SEPARATOR = _initDomainSeparator(name, version); } /** * @dev Initializes EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID. */ function _initDomainSeparator( string memory name, string memory version ) internal view returns (bytes32) { uint256 chainID; /* solium-disable-next-line */ assembly { chainID := chainid() } return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainID, address(this) ) ); } /** * @dev Approve by signature. * * Adapted from Uniswap's UniswapV2ERC20 and MakerDAO's Dai contracts: * https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol * https://github.com/makerdao/dss/blob/master/src/dai.sol */ function _permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal {<FILL_FUNCTION_BODY> } }
contract Permittable { /* ============ Variables ============ */ bytes32 public DOMAIN_SEPARATOR; mapping (address => uint256) public nonces; /* ============ Constants ============ */ // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /* solium-disable-next-line */ bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /* ============ Constructor ============ */ constructor( string memory name, string memory version ) public { DOMAIN_SEPARATOR = _initDomainSeparator(name, version); } /** * @dev Initializes EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID. */ function _initDomainSeparator( string memory name, string memory version ) internal view returns (bytes32) { uint256 chainID; /* solium-disable-next-line */ assembly { chainID := chainid() } return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainID, address(this) ) ); } <FILL_FUNCTION> }
require( deadline == 0 || deadline >= block.timestamp, "Permittable: Permit expired" ); require( spender != address(0), "Permittable: spender cannot be 0x0" ); require( value > 0, "Permittable: approval value must be greater than 0" ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline ) ) )); address recoveredAddress = ecrecover( digest, v, r, s ); require( recoveredAddress != address(0) && owner == recoveredAddress, "Permittable: Signature invalid" );
function _permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal
/** * @dev Approve by signature. * * Adapted from Uniswap's UniswapV2ERC20 and MakerDAO's Dai contracts: * https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol * https://github.com/makerdao/dss/blob/master/src/dai.sol */ function _permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal
24103
Spark
freezing
contract Spark is MintingERC20 { ICO public ico; SparkDividends public dividends; bool public transferFrozen = true; function Spark( string _tokenName, uint8 _decimals, string _symbol, uint256 _maxSupply, bool _locked ) public MintingERC20(0, _maxSupply, _tokenName, _decimals, _symbol, false, _locked) { standard = "Spark 0.1"; } function setICO(address _ico) public onlyOwner { require(_ico != address(0)); ico = ICO(_ico); } function setSparkDividends(address _dividends) public onlyOwner { require(address(0) != _dividends); dividends = SparkDividends(_dividends); } function setLocked(bool _locked) public onlyOwner { locked = _locked; } // prevent manual minting tokens when ICO is active; function mint(address _addr, uint256 _amount) public onlyMinters returns (uint256) { uint256 mintedAmount; if (msg.sender == owner) { require(address(ico) != address(0)); if (!ico.isActive() && block.timestamp >= ico.startTime()) { mintedAmount = super.mint(_addr, _amount); } } else { mintedAmount = super.mint(_addr, _amount); } if (mintedAmount == _amount) { require(address(dividends) != address(0)); dividends.logAccount(_addr, _amount); } return mintedAmount; } // Allow token transfer. function freezing(bool _transferFrozen) public onlyOwner {<FILL_FUNCTION_BODY> } // ERC20 functions // ========================= function transfer(address _to, uint _value) public returns (bool) { require(!transferFrozen); bool status = super.transfer(_to, _value); if (status) { require(address(dividends) != address(0)); dividends.logAccount(msg.sender, 0); dividends.logAccount(_to, 0); } return status; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(!transferFrozen); bool status = super.transferFrom(_from, _to, _value); if (status) { require(address(dividends) != address(0)); dividends.logAccount(_from, 0); dividends.logAccount(_to, 0); } return status; } }
contract Spark is MintingERC20 { ICO public ico; SparkDividends public dividends; bool public transferFrozen = true; function Spark( string _tokenName, uint8 _decimals, string _symbol, uint256 _maxSupply, bool _locked ) public MintingERC20(0, _maxSupply, _tokenName, _decimals, _symbol, false, _locked) { standard = "Spark 0.1"; } function setICO(address _ico) public onlyOwner { require(_ico != address(0)); ico = ICO(_ico); } function setSparkDividends(address _dividends) public onlyOwner { require(address(0) != _dividends); dividends = SparkDividends(_dividends); } function setLocked(bool _locked) public onlyOwner { locked = _locked; } // prevent manual minting tokens when ICO is active; function mint(address _addr, uint256 _amount) public onlyMinters returns (uint256) { uint256 mintedAmount; if (msg.sender == owner) { require(address(ico) != address(0)); if (!ico.isActive() && block.timestamp >= ico.startTime()) { mintedAmount = super.mint(_addr, _amount); } } else { mintedAmount = super.mint(_addr, _amount); } if (mintedAmount == _amount) { require(address(dividends) != address(0)); dividends.logAccount(_addr, _amount); } return mintedAmount; } <FILL_FUNCTION> // ERC20 functions // ========================= function transfer(address _to, uint _value) public returns (bool) { require(!transferFrozen); bool status = super.transfer(_to, _value); if (status) { require(address(dividends) != address(0)); dividends.logAccount(msg.sender, 0); dividends.logAccount(_to, 0); } return status; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(!transferFrozen); bool status = super.transferFrom(_from, _to, _value); if (status) { require(address(dividends) != address(0)); dividends.logAccount(_from, 0); dividends.logAccount(_to, 0); } return status; } }
if (address(ico) != address(0) && !ico.isActive() && block.timestamp >= ico.startTime()) { transferFrozen = _transferFrozen; }
function freezing(bool _transferFrozen) public onlyOwner
// Allow token transfer. function freezing(bool _transferFrozen) public onlyOwner
49974
DSGuard
forbid
contract DSGuard is DSAuth, DSAuthority, DSGuardEvents { bytes32 constant public ANY = bytes32(uint(-1)); mapping (bytes32 => mapping (bytes32 => mapping (bytes32 => bool))) acl; function canCall( address src_, address dst_, bytes4 sig ) public view returns (bool) { var src = bytes32(src_); var dst = bytes32(dst_); return acl[src][dst][sig] || acl[src][dst][ANY] || acl[src][ANY][sig] || acl[src][ANY][ANY] || acl[ANY][dst][sig] || acl[ANY][dst][ANY] || acl[ANY][ANY][sig] || acl[ANY][ANY][ANY]; } function permit(bytes32 src, bytes32 dst, bytes32 sig) public auth { acl[src][dst][sig] = true; LogPermit(src, dst, sig); } function forbid(bytes32 src, bytes32 dst, bytes32 sig) public auth {<FILL_FUNCTION_BODY> } function permit(address src, address dst, bytes32 sig) public { permit(bytes32(src), bytes32(dst), sig); } function forbid(address src, address dst, bytes32 sig) public { forbid(bytes32(src), bytes32(dst), sig); } }
contract DSGuard is DSAuth, DSAuthority, DSGuardEvents { bytes32 constant public ANY = bytes32(uint(-1)); mapping (bytes32 => mapping (bytes32 => mapping (bytes32 => bool))) acl; function canCall( address src_, address dst_, bytes4 sig ) public view returns (bool) { var src = bytes32(src_); var dst = bytes32(dst_); return acl[src][dst][sig] || acl[src][dst][ANY] || acl[src][ANY][sig] || acl[src][ANY][ANY] || acl[ANY][dst][sig] || acl[ANY][dst][ANY] || acl[ANY][ANY][sig] || acl[ANY][ANY][ANY]; } function permit(bytes32 src, bytes32 dst, bytes32 sig) public auth { acl[src][dst][sig] = true; LogPermit(src, dst, sig); } <FILL_FUNCTION> function permit(address src, address dst, bytes32 sig) public { permit(bytes32(src), bytes32(dst), sig); } function forbid(address src, address dst, bytes32 sig) public { forbid(bytes32(src), bytes32(dst), sig); } }
acl[src][dst][sig] = false; LogForbid(src, dst, sig);
function forbid(bytes32 src, bytes32 dst, bytes32 sig) public auth
function forbid(bytes32 src, bytes32 dst, bytes32 sig) public auth
27689
Marcelo
transferFrom
contract Marcelo is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Marcelo() public { symbol = "MRL"; name = "Marcelo"; decimals = 18; _totalSupply = 250000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant 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) 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; } // ------------------------------------------------------------------------ // 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; 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) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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 constant 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; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract Marcelo is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Marcelo() public { symbol = "MRL"; name = "Marcelo"; decimals = 18; _totalSupply = 250000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant 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) 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; } // ------------------------------------------------------------------------ // 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; Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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 constant 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; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
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 transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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) public returns (bool success)
12786
IOGToken
canTransferIfLocked
contract IOGToken is StandardToken, Ownable, Pausable { // events event Burn(address indexed burner, uint256 amount); event AddressLocked(address indexed _owner, uint256 _expiry); // erc20 constants string public constant name = "IOGToken"; string public constant symbol = "IOG"; uint8 public constant decimals = 18; uint256 public constant TOTAL_SUPPLY = 2200000000 * (10 ** uint256(decimals)); // lock mapping (address => uint256) public addressLocks; // constructor constructor(address[] addressList, uint256[] tokenAmountList, uint256[] lockedPeriodList) public { totalSupply_ = TOTAL_SUPPLY; balances[msg.sender] = TOTAL_SUPPLY; emit Transfer(0x0, msg.sender, TOTAL_SUPPLY); // distribution distribution(addressList, tokenAmountList, lockedPeriodList); } // distribution function distribution(address[] addressList, uint256[] tokenAmountList, uint256[] lockedPeriodList) onlyOwner internal { // Token allocation // - foundation: 25% (16% locked) // - platform ecosystem: 35% (30% locked) // - early investor: 15% (12.5% locked) // - private sale: 10% // - board of advisor: 10% // - bounty: 5% for (uint i = 0; i < addressList.length; i++) { uint256 lockedPeriod = lockedPeriodList[i]; // lock if (0 < lockedPeriod) { timeLock(addressList[i], tokenAmountList[i] * (10 ** uint256(decimals)), now + (lockedPeriod * 60 * 60 * 24)); } // unlock else { transfer(addressList[i], tokenAmountList[i] * (10 ** uint256(decimals))); } } } // lock modifier canTransfer(address _sender) { require(_sender != address(0)); require(canTransferIfLocked(_sender)); _; } function canTransferIfLocked(address _sender) internal view returns(bool) {<FILL_FUNCTION_BODY> } function timeLock(address _to, uint256 _value, uint256 releaseDate) onlyOwner public { addressLocks[_to] = releaseDate; transfer(_to, _value); emit AddressLocked(_to, _value); } // erc20 methods function transfer(address _to, uint256 _value) canTransfer(msg.sender) whenNotPaused public returns (bool success) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) canTransfer(_from) whenNotPaused public returns (bool success) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) whenNotPaused public returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } // burn function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } // token drain function emergencyERC20Drain(ERC20 token, uint256 amount) external onlyOwner { // owner can drain tokens that are sent here by mistake token.transfer(owner, amount); } }
contract IOGToken is StandardToken, Ownable, Pausable { // events event Burn(address indexed burner, uint256 amount); event AddressLocked(address indexed _owner, uint256 _expiry); // erc20 constants string public constant name = "IOGToken"; string public constant symbol = "IOG"; uint8 public constant decimals = 18; uint256 public constant TOTAL_SUPPLY = 2200000000 * (10 ** uint256(decimals)); // lock mapping (address => uint256) public addressLocks; // constructor constructor(address[] addressList, uint256[] tokenAmountList, uint256[] lockedPeriodList) public { totalSupply_ = TOTAL_SUPPLY; balances[msg.sender] = TOTAL_SUPPLY; emit Transfer(0x0, msg.sender, TOTAL_SUPPLY); // distribution distribution(addressList, tokenAmountList, lockedPeriodList); } // distribution function distribution(address[] addressList, uint256[] tokenAmountList, uint256[] lockedPeriodList) onlyOwner internal { // Token allocation // - foundation: 25% (16% locked) // - platform ecosystem: 35% (30% locked) // - early investor: 15% (12.5% locked) // - private sale: 10% // - board of advisor: 10% // - bounty: 5% for (uint i = 0; i < addressList.length; i++) { uint256 lockedPeriod = lockedPeriodList[i]; // lock if (0 < lockedPeriod) { timeLock(addressList[i], tokenAmountList[i] * (10 ** uint256(decimals)), now + (lockedPeriod * 60 * 60 * 24)); } // unlock else { transfer(addressList[i], tokenAmountList[i] * (10 ** uint256(decimals))); } } } // lock modifier canTransfer(address _sender) { require(_sender != address(0)); require(canTransferIfLocked(_sender)); _; } <FILL_FUNCTION> function timeLock(address _to, uint256 _value, uint256 releaseDate) onlyOwner public { addressLocks[_to] = releaseDate; transfer(_to, _value); emit AddressLocked(_to, _value); } // erc20 methods function transfer(address _to, uint256 _value) canTransfer(msg.sender) whenNotPaused public returns (bool success) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) canTransfer(_from) whenNotPaused public returns (bool success) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) whenNotPaused public returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } // burn function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } // token drain function emergencyERC20Drain(ERC20 token, uint256 amount) external onlyOwner { // owner can drain tokens that are sent here by mistake token.transfer(owner, amount); } }
if (0 == addressLocks[_sender]) return true; return (now >= addressLocks[_sender]);
function canTransferIfLocked(address _sender) internal view returns(bool)
function canTransferIfLocked(address _sender) internal view returns(bool)
33107
ETC
ETC
contract ETC is StandardToken, Ownable { // Constants string public constant name = "EthCoin"; string public constant symbol = "ETC"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 10000000 * (10 ** uint256(decimals)); uint public amountRaised; uint256 public buyPrice = 50000; bool public crowdsaleClosed; function ETC() public {<FILL_FUNCTION_BODY> } function _transfer(address _from, address _to, uint _value) internal { require (balances[_from] >= _value); // Check if the sender has enough require (balances[_to] + _value > balances[_to]); // Check for overflows balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient Transfer(_from, _to, _value); } function setPrices(bool closebuy, uint256 newBuyPrice) onlyOwner public { crowdsaleClosed = closebuy; buyPrice = newBuyPrice; } function () external payable { require(!crowdsaleClosed); uint amount = msg.value ; // calculates the amount amountRaised = amountRaised.add(amount); _transfer(owner, msg.sender, amount.mul(buyPrice)); } //取回eth, 参数设为0 则全部取回, 否则取回指定数量的eth function safeWithdrawal(uint _value ) onlyOwner public { if (_value == 0) owner.transfer(address(this).balance); else owner.transfer(_value); } /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner public returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); return true; } }
contract ETC is StandardToken, Ownable { // Constants string public constant name = "EthCoin"; string public constant symbol = "ETC"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 10000000 * (10 ** uint256(decimals)); uint public amountRaised; uint256 public buyPrice = 50000; bool public crowdsaleClosed; <FILL_FUNCTION> function _transfer(address _from, address _to, uint _value) internal { require (balances[_from] >= _value); // Check if the sender has enough require (balances[_to] + _value > balances[_to]); // Check for overflows balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient Transfer(_from, _to, _value); } function setPrices(bool closebuy, uint256 newBuyPrice) onlyOwner public { crowdsaleClosed = closebuy; buyPrice = newBuyPrice; } function () external payable { require(!crowdsaleClosed); uint amount = msg.value ; // calculates the amount amountRaised = amountRaised.add(amount); _transfer(owner, msg.sender, amount.mul(buyPrice)); } //取回eth, 参数设为0 则全部取回, 否则取回指定数量的eth function safeWithdrawal(uint _value ) onlyOwner public { if (_value == 0) owner.transfer(address(this).balance); else owner.transfer(_value); } /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner public returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); return true; } }
totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY);
function ETC() public
function ETC() public
49740
StandardToken
decreaseApproval
contract StandardToken is ERC20, ERC223, Ownable { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function StandardToken(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } 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 view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {<FILL_FUNCTION_BODY> } function transfer(address _to, uint _value, bytes _data) { // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . uint codeLength; assembly { // Retrieve the size of the code on target address, this needs assembly . codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if(codeLength>0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } emit Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return (length>0); } }
contract StandardToken is ERC20, ERC223, Ownable { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function StandardToken(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } 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 view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> function transfer(address _to, uint _value, bytes _data) { // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . uint codeLength; assembly { // Retrieve the size of the code on target address, this needs assembly . codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if(codeLength>0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } emit Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return (length>0); } }
uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = SafeMath.sub(oldValue, _subtractedValue); } 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)
3866
ALDToken
setMinter
contract ALDToken is ERC20("Aladdin Token", "ALD") { address public governance; mapping (address => bool) public isMinter; constructor () public { governance = msg.sender; } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function setMinter(address _minter, bool _status) external {<FILL_FUNCTION_BODY> } /// @notice Creates `_amount` token to `_to`. Must only be called by minter function mint(address _to, uint256 _amount) external { require(isMinter[msg.sender] == true, "!minter"); _mint(_to, _amount); } /// @notice Burn `_amount` token from `_from`. Must only be called by governance function burn(address _from, uint256 _amount) external { require(msg.sender == governance, "!governance"); _burn(_from, _amount); } }
contract ALDToken is ERC20("Aladdin Token", "ALD") { address public governance; mapping (address => bool) public isMinter; constructor () public { governance = msg.sender; } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } <FILL_FUNCTION> /// @notice Creates `_amount` token to `_to`. Must only be called by minter function mint(address _to, uint256 _amount) external { require(isMinter[msg.sender] == true, "!minter"); _mint(_to, _amount); } /// @notice Burn `_amount` token from `_from`. Must only be called by governance function burn(address _from, uint256 _amount) external { require(msg.sender == governance, "!governance"); _burn(_from, _amount); } }
require(msg.sender == governance, "!governance"); isMinter[_minter] = _status;
function setMinter(address _minter, bool _status) external
function setMinter(address _minter, bool _status) external
62668
YOUSHOULDMINT
supportsInterface
contract YOUSHOULDMINT is ERC721, ERC721Enumerable, ERC721Pausable, Ownable { using SafeMath for uint256; uint256 public constant MAX_EARLY = 8888; uint256 public Start_id = 1; uint256 public constant PRICE = 0.08 ether; string public baseTokenURI = "ur_early://"; event CreateEARLY(uint256 indexed id); constructor() ERC721( "LOOKS LIKE UR EARLY", "EARLY" ) {} function YOU_SHOULD_CALL_THIS_MINT_FUNCTION_(uint256 count) public payable { uint256 currentTotal = totalSupply(); require(count > 0, "Count must be greater than 0"); require(currentTotal.add(count) <= MAX_EARLY, "Requested amount exceeds what is available!"); require(currentTotal <= MAX_EARLY, "Not enough earlys available."); require(msg.value >= PRICE.mul(count), "Incorrect price."); for (uint i = 0; i < count; i++) { uint id = Start_id; _safeMint(msg.sender, id); emit CreateEARLY(id); Start_id++; } } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token'); return baseTokenURI; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function withdrawAll() public payable onlyOwner { _widthdraw(owner(), address(this).balance); } function _widthdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{value: _amount}(""); require(success, "Recovery failed."); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) {<FILL_FUNCTION_BODY> } }
contract YOUSHOULDMINT is ERC721, ERC721Enumerable, ERC721Pausable, Ownable { using SafeMath for uint256; uint256 public constant MAX_EARLY = 8888; uint256 public Start_id = 1; uint256 public constant PRICE = 0.08 ether; string public baseTokenURI = "ur_early://"; event CreateEARLY(uint256 indexed id); constructor() ERC721( "LOOKS LIKE UR EARLY", "EARLY" ) {} function YOU_SHOULD_CALL_THIS_MINT_FUNCTION_(uint256 count) public payable { uint256 currentTotal = totalSupply(); require(count > 0, "Count must be greater than 0"); require(currentTotal.add(count) <= MAX_EARLY, "Requested amount exceeds what is available!"); require(currentTotal <= MAX_EARLY, "Not enough earlys available."); require(msg.value >= PRICE.mul(count), "Incorrect price."); for (uint i = 0; i < count; i++) { uint id = Start_id; _safeMint(msg.sender, id); emit CreateEARLY(id); Start_id++; } } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token'); return baseTokenURI; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function withdrawAll() public payable onlyOwner { _widthdraw(owner(), address(this).balance); } function _widthdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{value: _amount}(""); require(success, "Recovery failed."); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } <FILL_FUNCTION> }
return super.supportsInterface(interfaceId);
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool)
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool)

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
0
Add dataset card