source_idx
stringlengths 1
5
| contract_name
stringlengths 1
55
| func_name
stringlengths 0
2.45k
⌀ | masked_body
stringlengths 60
827k
| masked_all
stringlengths 34
827k
| func_body
stringlengths 4
324k
| signature_only
stringlengths 11
2.47k
| signature_extend
stringlengths 11
25.6k
|
---|---|---|---|---|---|---|---|
65665 | Ownable | transferOwnership | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Sender not authorised.");
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Sender not authorised.");
_;
}
<FILL_FUNCTION>
} |
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
| function transferOwnership(address newOwner) onlyOwner public | /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public |
23070 | GLCASH | balanceOf | contract GLCASH is ERC20 {
string public constant name = "GL CASH";
string public constant symbol = "GL";
uint8 public constant decimals = 18;
uint256 public constant initialSupply = 30000000000 * (10 ** uint256(decimals));
constructor() public {
super._mint(msg.sender, initialSupply);
owner = msg.sender;
}
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0), "Already Owner");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused, "Paused by owner");
_;
}
modifier whenPaused() {
require(paused, "Not paused now");
_;
}
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
}
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpause();
}
event Frozen(address target);
event Unfrozen(address target);
mapping(address => bool) internal freezes;
modifier whenNotFrozen() {
require(!freezes[msg.sender], "Sender account is locked.");
_;
}
function freeze(address _target) public onlyOwner {
freezes[_target] = true;
emit Frozen(_target);
}
function unfreeze(address _target) public onlyOwner {
freezes[_target] = false;
emit Unfrozen(_target);
}
function isFrozen(address _target) public view returns (bool) {
return freezes[_target];
}
function transfer(
address _to,
uint256 _value
)
public
whenNotFrozen
whenNotPaused
returns (bool)
{
releaseLock(msg.sender);
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
require(!freezes[_from], "From account is locked.");
releaseLock(_from);
return super.transferFrom(_from, _to, _value);
}
event Burn(address indexed burner, uint256 value);
function burn(address _who, uint256 _value) public onlyOwner {
require(_value <= super.balanceOf(_who), "Balance is too small.");
_burn(_who, _value);
emit Burn(_who, _value);
}
struct LockInfo {
uint256 releaseTime;
uint256 balance;
}
mapping(address => LockInfo[]) internal lockInfo;
event Lock(address indexed holder, uint256 value, uint256 releaseTime);
event Unlock(address indexed holder, uint256 value);
function balanceOf(address _holder) public view returns (uint256 balance) {<FILL_FUNCTION_BODY> }
function releaseLock(address _holder) internal {
for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) {
if (lockInfo[_holder][i].releaseTime <= now) {
_balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
i--;
}
lockInfo[_holder].length--;
}
}
}
function lockCount(address _holder) public view returns (uint256) {
return lockInfo[_holder].length;
}
function lockState(address _holder, uint256 _idx) public view returns (uint256, uint256) {
return (lockInfo[_holder][_idx].releaseTime, lockInfo[_holder][_idx].balance);
}
function lock(address _holder, uint256 _amount, uint256 _releaseTime) public onlyOwner {
require(super.balanceOf(_holder) >= _amount, "Balance is too small.");
_balances[_holder] = _balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(_releaseTime, _amount)
);
emit Lock(_holder, _amount, _releaseTime);
}
function lockAfter(address _holder, uint256 _amount, uint256 _afterTime) public onlyOwner {
require(super.balanceOf(_holder) >= _amount, "Balance is too small.");
_balances[_holder] = _balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(now + _afterTime, _amount)
);
emit Lock(_holder, _amount, now + _afterTime);
}
function unlock(address _holder, uint256 i) public onlyOwner {
require(i < lockInfo[_holder].length, "No lock information.");
_balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
}
lockInfo[_holder].length--;
}
function transferWithLock(address _to, uint256 _value, uint256 _releaseTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= super.balanceOf(owner), "Not enough balance");
_balances[owner] = _balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(_releaseTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, _releaseTime);
return true;
}
function transferWithLockAfter(address _to, uint256 _value, uint256 _afterTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= super.balanceOf(owner), "Not enough balance");
_balances[owner] = _balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(now + _afterTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, now + _afterTime);
return true;
}
function currentTime() public view returns (uint256) {
return now;
}
function afterTime(uint256 _value) public view returns (uint256) {
return now + _value;
}
} | contract GLCASH is ERC20 {
string public constant name = "GL CASH";
string public constant symbol = "GL";
uint8 public constant decimals = 18;
uint256 public constant initialSupply = 30000000000 * (10 ** uint256(decimals));
constructor() public {
super._mint(msg.sender, initialSupply);
owner = msg.sender;
}
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0), "Already Owner");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused, "Paused by owner");
_;
}
modifier whenPaused() {
require(paused, "Not paused now");
_;
}
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
}
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpause();
}
event Frozen(address target);
event Unfrozen(address target);
mapping(address => bool) internal freezes;
modifier whenNotFrozen() {
require(!freezes[msg.sender], "Sender account is locked.");
_;
}
function freeze(address _target) public onlyOwner {
freezes[_target] = true;
emit Frozen(_target);
}
function unfreeze(address _target) public onlyOwner {
freezes[_target] = false;
emit Unfrozen(_target);
}
function isFrozen(address _target) public view returns (bool) {
return freezes[_target];
}
function transfer(
address _to,
uint256 _value
)
public
whenNotFrozen
whenNotPaused
returns (bool)
{
releaseLock(msg.sender);
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
require(!freezes[_from], "From account is locked.");
releaseLock(_from);
return super.transferFrom(_from, _to, _value);
}
event Burn(address indexed burner, uint256 value);
function burn(address _who, uint256 _value) public onlyOwner {
require(_value <= super.balanceOf(_who), "Balance is too small.");
_burn(_who, _value);
emit Burn(_who, _value);
}
struct LockInfo {
uint256 releaseTime;
uint256 balance;
}
mapping(address => LockInfo[]) internal lockInfo;
event Lock(address indexed holder, uint256 value, uint256 releaseTime);
event Unlock(address indexed holder, uint256 value);
<FILL_FUNCTION>
function releaseLock(address _holder) internal {
for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) {
if (lockInfo[_holder][i].releaseTime <= now) {
_balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
i--;
}
lockInfo[_holder].length--;
}
}
}
function lockCount(address _holder) public view returns (uint256) {
return lockInfo[_holder].length;
}
function lockState(address _holder, uint256 _idx) public view returns (uint256, uint256) {
return (lockInfo[_holder][_idx].releaseTime, lockInfo[_holder][_idx].balance);
}
function lock(address _holder, uint256 _amount, uint256 _releaseTime) public onlyOwner {
require(super.balanceOf(_holder) >= _amount, "Balance is too small.");
_balances[_holder] = _balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(_releaseTime, _amount)
);
emit Lock(_holder, _amount, _releaseTime);
}
function lockAfter(address _holder, uint256 _amount, uint256 _afterTime) public onlyOwner {
require(super.balanceOf(_holder) >= _amount, "Balance is too small.");
_balances[_holder] = _balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(now + _afterTime, _amount)
);
emit Lock(_holder, _amount, now + _afterTime);
}
function unlock(address _holder, uint256 i) public onlyOwner {
require(i < lockInfo[_holder].length, "No lock information.");
_balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
}
lockInfo[_holder].length--;
}
function transferWithLock(address _to, uint256 _value, uint256 _releaseTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= super.balanceOf(owner), "Not enough balance");
_balances[owner] = _balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(_releaseTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, _releaseTime);
return true;
}
function transferWithLockAfter(address _to, uint256 _value, uint256 _afterTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= super.balanceOf(owner), "Not enough balance");
_balances[owner] = _balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(now + _afterTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, now + _afterTime);
return true;
}
function currentTime() public view returns (uint256) {
return now;
}
function afterTime(uint256 _value) public view returns (uint256) {
return now + _value;
}
} |
uint256 lockedBalance = 0;
for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) {
lockedBalance = lockedBalance.add(lockInfo[_holder][i].balance);
}
return super.balanceOf(_holder).add(lockedBalance);
| function balanceOf(address _holder) public view returns (uint256 balance) | function balanceOf(address _holder) public view returns (uint256 balance) |
94031 | TimeLockToken | transfer | contract TimeLockToken is StandardToken, Ownable {
mapping (address => uint) public timelockAccounts;
event TimeLockFunds(address target, uint releasetime);
function timelockAccount(address target, uint releasetime) public onlyOwner {
uint r_time;
r_time = now + (releasetime * 1 days);
timelockAccounts[target] = r_time;
emit TimeLockFunds(target, r_time);
}
function timeunlockAccount(address target) public onlyOwner {
timelockAccounts[target] = now;
emit TimeLockFunds(target, now);
}
function releasetime(address _target) view public returns (uint){
return timelockAccounts[_target];
}
modifier ReleaseTimeTransfer(address _sender) {
require(now >= timelockAccounts[_sender]);
_;
}
function transfer(address _to, uint256 _value) public ReleaseTimeTransfer(msg.sender) returns (bool success) {<FILL_FUNCTION_BODY> }
function transferFrom(address _from, address _to, uint256 _value) public ReleaseTimeTransfer(_from) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
} | contract TimeLockToken is StandardToken, Ownable {
mapping (address => uint) public timelockAccounts;
event TimeLockFunds(address target, uint releasetime);
function timelockAccount(address target, uint releasetime) public onlyOwner {
uint r_time;
r_time = now + (releasetime * 1 days);
timelockAccounts[target] = r_time;
emit TimeLockFunds(target, r_time);
}
function timeunlockAccount(address target) public onlyOwner {
timelockAccounts[target] = now;
emit TimeLockFunds(target, now);
}
function releasetime(address _target) view public returns (uint){
return timelockAccounts[_target];
}
modifier ReleaseTimeTransfer(address _sender) {
require(now >= timelockAccounts[_sender]);
_;
}
<FILL_FUNCTION>
function transferFrom(address _from, address _to, uint256 _value) public ReleaseTimeTransfer(_from) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
} |
return super.transfer(_to, _value);
| function transfer(address _to, uint256 _value) public ReleaseTimeTransfer(msg.sender) returns (bool success) | function transfer(address _to, uint256 _value) public ReleaseTimeTransfer(msg.sender) returns (bool success) |
82878 | ERC20 | _mint | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> }
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
} | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
<FILL_FUNCTION>
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
} |
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
| function _mint(address account, uint256 amount) internal virtual | /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual |
80199 | Ownable | transferOwnership | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
} |
require(newOwner != address(0));
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 |
16309 | GYOZA | mint | contract GYOZA is ERC20("YFGyoza.money", "GYOZA"), Ownable {
function mint(address _to, uint256 _amount) public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract GYOZA is ERC20("YFGyoza.money", "GYOZA"), Ownable {
<FILL_FUNCTION>
} |
_mint(_to, _amount);
| function mint(address _to, uint256 _amount) public onlyOwner | function mint(address _to, uint256 _amount) public onlyOwner |
60843 | CommonBsPresale | contract CommonBsPresale is SafeMath, Ownable, Pausable {
enum Currency { BTC, LTC, ZEC, DASH, WAVES, USD, EUR }
// TODO rename to Buyer?
struct Backer {
uint256 weiReceived; // Amount of wei given by backer
uint256 tokensSent; // Amount of tokens received in return to the given amount of ETH.
}
// TODO rename to buyers?
// (buyer_eth_address -> struct)
mapping(address => Backer) public backers;
// currency_code => (tx_hash => tokens)
mapping(uint8 => mapping(bytes32 => uint256)) public externalTxs;
CommonBsToken public token; // Token contract reference.
address public beneficiary; // Address that will receive ETH raised during this crowdsale.
address public notifier; // Address that can this crowdsale about changed external conditions.
uint256 public minTokensToBuy = 1 * 1e18; // Including bonuses.
uint256 public maxCapWei = 50000 ether;
uint public tokensPerWei = 1000; // Ordinary price: 1 ETH = 1000 tokens.
uint public tokensPerWeiBonus333 = 1333;
uint public tokensPerWeiBonus250 = 1250;
uint public tokensPerWeiBonus111 = 1111;
uint public startTime = 1410160700; // 2017-11-08T17:05:00Z
uint public bonusEndTime333 = 1510333500; // 2017-11-10T17:05:00Z
uint public bonusEndTime250 = 1510679100; // 2017-11-14T17:05:00Z
uint public endTime = 1511024700; // 2017-11-18T17:05:00Z
// Stats for current crowdsale
// TODO rename to 'totalInWei'
uint256 public totalWei = 0; // Grand total in wei
uint256 public totalTokensSold = 0; // Total amount of tokens sold during this crowdsale.
uint256 public totalEthSales = 0; // Total amount of ETH contributions during this crowdsale.
uint256 public totalExternalSales = 0; // Total amount of external contributions (BTC, LTC, USD, etc.) during this crowdsale.
uint256 public weiReceived = 0; // Total amount of wei received during this crowdsale smart contract.
uint public finalizedTime = 0; // Unix timestamp when finalize() was called.
bool public saleEnabled = true; // if false, then contract will not sell tokens on payment received
event BeneficiaryChanged(address indexed _oldAddress, address indexed _newAddress);
event NotifierChanged(address indexed _oldAddress, address indexed _newAddress);
event EthReceived(address indexed _buyer, uint256 _amountWei);
event ExternalSaleSha3(Currency _currency, bytes32 _txIdSha3, address indexed _buyer, uint256 _amountWei, uint256 _tokensE18);
modifier respectTimeFrame() {
require(isSaleOn());
_;
}
modifier canNotify() {
require(msg.sender == owner || msg.sender == notifier);
_;
}
function CommonBsPresale(address _token, address _beneficiary) {
token = CommonBsToken(_token);
owner = msg.sender;
notifier = owner;
beneficiary = _beneficiary;
}
// Override this method to mock current time.
function getNow() public constant returns (uint) {
return now;
}
function setSaleEnabled(bool _enabled) public onlyOwner {
saleEnabled = _enabled;
}
function setBeneficiary(address _beneficiary) public onlyOwner {
BeneficiaryChanged(beneficiary, _beneficiary);
beneficiary = _beneficiary;
}
function setNotifier(address _notifier) public onlyOwner {
NotifierChanged(notifier, _notifier);
notifier = _notifier;
}
/*
* The fallback function corresponds to a donation in ETH
*/
function() public payable {<FILL_FUNCTION_BODY> }
function sellTokensForEth(address _buyer, uint256 _amountWei) internal ifNotPaused respectTimeFrame {
totalWei = safeAdd(totalWei, _amountWei);
weiReceived = safeAdd(weiReceived, _amountWei);
require(totalWei <= maxCapWei); // If max cap reached.
uint256 tokensE18 = weiToTokens(_amountWei);
require(tokensE18 >= minTokensToBuy);
require(token.sell(_buyer, tokensE18)); // Transfer tokens to buyer.
totalTokensSold = safeAdd(totalTokensSold, tokensE18);
totalEthSales++;
Backer backer = backers[_buyer];
backer.tokensSent = safeAdd(backer.tokensSent, tokensE18);
backer.weiReceived = safeAdd(backer.weiReceived, _amountWei); // Update the total wei collected during the crowdfunding for this backer
EthReceived(_buyer, _amountWei);
}
// Calc how much tokens you can buy at current time.
function weiToTokens(uint256 _amountWei) public constant returns (uint256) {
return weiToTokensAtTime(_amountWei, getNow());
}
function weiToTokensAtTime(uint256 _amountWei, uint _time) public constant returns (uint256) {
uint256 rate = tokensPerWei;
if (startTime <= _time && _time < bonusEndTime333) rate = tokensPerWeiBonus333;
else if (bonusEndTime333 <= _time && _time < bonusEndTime250) rate = tokensPerWeiBonus250;
else if (bonusEndTime250 <= _time && _time < endTime) rate = tokensPerWeiBonus111;
return safeMul(_amountWei, rate);
}
//----------------------------------------------------------------------
// Begin of external sales.
function externalSales(
uint8[] _currencies,
bytes32[] _txIdSha3,
address[] _buyers,
uint256[] _amountsWei,
uint256[] _tokensE18
) public ifNotPaused canNotify {
require(_currencies.length > 0);
require(_currencies.length == _txIdSha3.length);
require(_currencies.length == _buyers.length);
require(_currencies.length == _amountsWei.length);
require(_currencies.length == _tokensE18.length);
for (uint i = 0; i < _txIdSha3.length; i++) {
_externalSaleSha3(
Currency(_currencies[i]),
_txIdSha3[i],
_buyers[i],
_amountsWei[i],
_tokensE18[i]
);
}
}
function _externalSaleSha3(
Currency _currency,
bytes32 _txIdSha3, // To get bytes32 use keccak256(txId) OR sha3(txId)
address _buyer,
uint256 _amountWei,
uint256 _tokensE18
) internal {
require(_buyer > 0 && _amountWei > 0 && _tokensE18 > 0);
var txsByCur = externalTxs[uint8(_currency)];
// If this foreign transaction has been already processed in this contract.
require(txsByCur[_txIdSha3] == 0);
totalWei = safeAdd(totalWei, _amountWei);
require(totalWei <= maxCapWei); // Max cap should not be reached yet.
require(token.sell(_buyer, _tokensE18)); // Transfer tokens to buyer.
totalTokensSold = safeAdd(totalTokensSold, _tokensE18);
totalExternalSales++;
txsByCur[_txIdSha3] = _tokensE18;
ExternalSaleSha3(_currency, _txIdSha3, _buyer, _amountWei, _tokensE18);
}
// Get id of currency enum. --------------------------------------------
function btcId() public constant returns (uint8) {
return uint8(Currency.BTC);
}
function ltcId() public constant returns (uint8) {
return uint8(Currency.LTC);
}
function zecId() public constant returns (uint8) {
return uint8(Currency.ZEC);
}
function dashId() public constant returns (uint8) {
return uint8(Currency.DASH);
}
function wavesId() public constant returns (uint8) {
return uint8(Currency.WAVES);
}
function usdId() public constant returns (uint8) {
return uint8(Currency.USD);
}
function eurId() public constant returns (uint8) {
return uint8(Currency.EUR);
}
// Get token count by transaction id. ----------------------------------
function _tokensByTx(Currency _currency, string _txId) internal constant returns (uint256) {
return tokensByTx(uint8(_currency), _txId);
}
function tokensByTx(uint8 _currency, string _txId) public constant returns (uint256) {
return externalTxs[_currency][keccak256(_txId)];
}
function tokensByBtcTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.BTC, _txId);
}
function tokensByLtcTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.LTC, _txId);
}
function tokensByZecTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.ZEC, _txId);
}
function tokensByDashTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.DASH, _txId);
}
function tokensByWavesTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.WAVES, _txId);
}
function tokensByUsdTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.USD, _txId);
}
function tokensByEurTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.EUR, _txId);
}
// End of external sales.
//----------------------------------------------------------------------
function totalSales() public constant returns (uint256) {
return safeAdd(totalEthSales, totalExternalSales);
}
function isMaxCapReached() public constant returns (bool) {
return totalWei >= maxCapWei;
}
function isSaleOn() public constant returns (bool) {
uint _now = getNow();
return startTime <= _now && _now <= endTime;
}
function isSaleOver() public constant returns (bool) {
return getNow() > endTime;
}
function isFinalized() public constant returns (bool) {
return finalizedTime > 0;
}
/*
* Finalize the crowdsale. Raised money can be sent to beneficiary only if crowdsale hit end time or max cap (15m USD).
*/
function finalize() public onlyOwner {
// Cannot finalise before end day of crowdsale until max cap is reached.
require(isMaxCapReached() || isSaleOver());
beneficiary.transfer(this.balance);
finalizedTime = getNow();
}
} | contract CommonBsPresale is SafeMath, Ownable, Pausable {
enum Currency { BTC, LTC, ZEC, DASH, WAVES, USD, EUR }
// TODO rename to Buyer?
struct Backer {
uint256 weiReceived; // Amount of wei given by backer
uint256 tokensSent; // Amount of tokens received in return to the given amount of ETH.
}
// TODO rename to buyers?
// (buyer_eth_address -> struct)
mapping(address => Backer) public backers;
// currency_code => (tx_hash => tokens)
mapping(uint8 => mapping(bytes32 => uint256)) public externalTxs;
CommonBsToken public token; // Token contract reference.
address public beneficiary; // Address that will receive ETH raised during this crowdsale.
address public notifier; // Address that can this crowdsale about changed external conditions.
uint256 public minTokensToBuy = 1 * 1e18; // Including bonuses.
uint256 public maxCapWei = 50000 ether;
uint public tokensPerWei = 1000; // Ordinary price: 1 ETH = 1000 tokens.
uint public tokensPerWeiBonus333 = 1333;
uint public tokensPerWeiBonus250 = 1250;
uint public tokensPerWeiBonus111 = 1111;
uint public startTime = 1410160700; // 2017-11-08T17:05:00Z
uint public bonusEndTime333 = 1510333500; // 2017-11-10T17:05:00Z
uint public bonusEndTime250 = 1510679100; // 2017-11-14T17:05:00Z
uint public endTime = 1511024700; // 2017-11-18T17:05:00Z
// Stats for current crowdsale
// TODO rename to 'totalInWei'
uint256 public totalWei = 0; // Grand total in wei
uint256 public totalTokensSold = 0; // Total amount of tokens sold during this crowdsale.
uint256 public totalEthSales = 0; // Total amount of ETH contributions during this crowdsale.
uint256 public totalExternalSales = 0; // Total amount of external contributions (BTC, LTC, USD, etc.) during this crowdsale.
uint256 public weiReceived = 0; // Total amount of wei received during this crowdsale smart contract.
uint public finalizedTime = 0; // Unix timestamp when finalize() was called.
bool public saleEnabled = true; // if false, then contract will not sell tokens on payment received
event BeneficiaryChanged(address indexed _oldAddress, address indexed _newAddress);
event NotifierChanged(address indexed _oldAddress, address indexed _newAddress);
event EthReceived(address indexed _buyer, uint256 _amountWei);
event ExternalSaleSha3(Currency _currency, bytes32 _txIdSha3, address indexed _buyer, uint256 _amountWei, uint256 _tokensE18);
modifier respectTimeFrame() {
require(isSaleOn());
_;
}
modifier canNotify() {
require(msg.sender == owner || msg.sender == notifier);
_;
}
function CommonBsPresale(address _token, address _beneficiary) {
token = CommonBsToken(_token);
owner = msg.sender;
notifier = owner;
beneficiary = _beneficiary;
}
// Override this method to mock current time.
function getNow() public constant returns (uint) {
return now;
}
function setSaleEnabled(bool _enabled) public onlyOwner {
saleEnabled = _enabled;
}
function setBeneficiary(address _beneficiary) public onlyOwner {
BeneficiaryChanged(beneficiary, _beneficiary);
beneficiary = _beneficiary;
}
function setNotifier(address _notifier) public onlyOwner {
NotifierChanged(notifier, _notifier);
notifier = _notifier;
}
<FILL_FUNCTION>
function sellTokensForEth(address _buyer, uint256 _amountWei) internal ifNotPaused respectTimeFrame {
totalWei = safeAdd(totalWei, _amountWei);
weiReceived = safeAdd(weiReceived, _amountWei);
require(totalWei <= maxCapWei); // If max cap reached.
uint256 tokensE18 = weiToTokens(_amountWei);
require(tokensE18 >= minTokensToBuy);
require(token.sell(_buyer, tokensE18)); // Transfer tokens to buyer.
totalTokensSold = safeAdd(totalTokensSold, tokensE18);
totalEthSales++;
Backer backer = backers[_buyer];
backer.tokensSent = safeAdd(backer.tokensSent, tokensE18);
backer.weiReceived = safeAdd(backer.weiReceived, _amountWei); // Update the total wei collected during the crowdfunding for this backer
EthReceived(_buyer, _amountWei);
}
// Calc how much tokens you can buy at current time.
function weiToTokens(uint256 _amountWei) public constant returns (uint256) {
return weiToTokensAtTime(_amountWei, getNow());
}
function weiToTokensAtTime(uint256 _amountWei, uint _time) public constant returns (uint256) {
uint256 rate = tokensPerWei;
if (startTime <= _time && _time < bonusEndTime333) rate = tokensPerWeiBonus333;
else if (bonusEndTime333 <= _time && _time < bonusEndTime250) rate = tokensPerWeiBonus250;
else if (bonusEndTime250 <= _time && _time < endTime) rate = tokensPerWeiBonus111;
return safeMul(_amountWei, rate);
}
//----------------------------------------------------------------------
// Begin of external sales.
function externalSales(
uint8[] _currencies,
bytes32[] _txIdSha3,
address[] _buyers,
uint256[] _amountsWei,
uint256[] _tokensE18
) public ifNotPaused canNotify {
require(_currencies.length > 0);
require(_currencies.length == _txIdSha3.length);
require(_currencies.length == _buyers.length);
require(_currencies.length == _amountsWei.length);
require(_currencies.length == _tokensE18.length);
for (uint i = 0; i < _txIdSha3.length; i++) {
_externalSaleSha3(
Currency(_currencies[i]),
_txIdSha3[i],
_buyers[i],
_amountsWei[i],
_tokensE18[i]
);
}
}
function _externalSaleSha3(
Currency _currency,
bytes32 _txIdSha3, // To get bytes32 use keccak256(txId) OR sha3(txId)
address _buyer,
uint256 _amountWei,
uint256 _tokensE18
) internal {
require(_buyer > 0 && _amountWei > 0 && _tokensE18 > 0);
var txsByCur = externalTxs[uint8(_currency)];
// If this foreign transaction has been already processed in this contract.
require(txsByCur[_txIdSha3] == 0);
totalWei = safeAdd(totalWei, _amountWei);
require(totalWei <= maxCapWei); // Max cap should not be reached yet.
require(token.sell(_buyer, _tokensE18)); // Transfer tokens to buyer.
totalTokensSold = safeAdd(totalTokensSold, _tokensE18);
totalExternalSales++;
txsByCur[_txIdSha3] = _tokensE18;
ExternalSaleSha3(_currency, _txIdSha3, _buyer, _amountWei, _tokensE18);
}
// Get id of currency enum. --------------------------------------------
function btcId() public constant returns (uint8) {
return uint8(Currency.BTC);
}
function ltcId() public constant returns (uint8) {
return uint8(Currency.LTC);
}
function zecId() public constant returns (uint8) {
return uint8(Currency.ZEC);
}
function dashId() public constant returns (uint8) {
return uint8(Currency.DASH);
}
function wavesId() public constant returns (uint8) {
return uint8(Currency.WAVES);
}
function usdId() public constant returns (uint8) {
return uint8(Currency.USD);
}
function eurId() public constant returns (uint8) {
return uint8(Currency.EUR);
}
// Get token count by transaction id. ----------------------------------
function _tokensByTx(Currency _currency, string _txId) internal constant returns (uint256) {
return tokensByTx(uint8(_currency), _txId);
}
function tokensByTx(uint8 _currency, string _txId) public constant returns (uint256) {
return externalTxs[_currency][keccak256(_txId)];
}
function tokensByBtcTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.BTC, _txId);
}
function tokensByLtcTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.LTC, _txId);
}
function tokensByZecTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.ZEC, _txId);
}
function tokensByDashTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.DASH, _txId);
}
function tokensByWavesTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.WAVES, _txId);
}
function tokensByUsdTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.USD, _txId);
}
function tokensByEurTx(string _txId) public constant returns (uint256) {
return _tokensByTx(Currency.EUR, _txId);
}
// End of external sales.
//----------------------------------------------------------------------
function totalSales() public constant returns (uint256) {
return safeAdd(totalEthSales, totalExternalSales);
}
function isMaxCapReached() public constant returns (bool) {
return totalWei >= maxCapWei;
}
function isSaleOn() public constant returns (bool) {
uint _now = getNow();
return startTime <= _now && _now <= endTime;
}
function isSaleOver() public constant returns (bool) {
return getNow() > endTime;
}
function isFinalized() public constant returns (bool) {
return finalizedTime > 0;
}
/*
* Finalize the crowdsale. Raised money can be sent to beneficiary only if crowdsale hit end time or max cap (15m USD).
*/
function finalize() public onlyOwner {
// Cannot finalise before end day of crowdsale until max cap is reached.
require(isMaxCapReached() || isSaleOver());
beneficiary.transfer(this.balance);
finalizedTime = getNow();
}
} |
if (saleEnabled) sellTokensForEth(msg.sender, msg.value);
| function() public payable | /*
* The fallback function corresponds to a donation in ETH
*/
function() public payable |
|
57362 | UniswapPriceOracleV2 | fetchMarketPriceByUsdtPair | contract UniswapPriceOracleV2 is UniswapConfig {
using FixedPoint for *;
/// @notice The number of wei in 1 ETH
uint public constant ethBaseUnit = 1e18;
uint public constant usdtBaseUnit = 1e6;
/// @notice A common scaling factor to maintain precision
uint public constant expScale = 1e18;
/// @notice The minimum amount of time in seconds required for the old uniswap price accumulator to be replaced
uint public immutable anchorPeriod;
/// @notice Official prices by symbol hash
mapping(bytes32 => uint) public prices;
/// @notice The old observation for each symbolHash
mapping(bytes32 => Observation) public oldObservations;
/// @notice The new observation for each symbolHash
mapping(bytes32 => Observation) public newObservations;
/// @notice The event emitted when new prices are posted but the stored price is not updated due to the anchor
event PriceGuarded(string symbol, uint reporter, uint anchor);
/// @notice The event emitted when the stored price is updated
event PriceUpdated(string symbol, uint price);
/// @notice The event emitted when anchor price is updated
event AnchorPriceUpdated(string symbol, uint anchorPrice, uint oldTimestamp, uint newTimestamp);
/// @notice The event emitted when the uniswap window changes
event UniswapWindowUpdated(bytes32 indexed symbolHash, uint oldTimestamp, uint newTimestamp, uint oldPrice, uint newPrice);
bytes32 constant ethHash = keccak256(abi.encodePacked("ETH"));
constructor(uint anchorPeriod_,
address[] memory gTokens_, address[] memory underlyings_,
bytes32[] memory symbolHashs_, uint256[] memory baseUints_,
PriceSource[] memory priceSources_, uint256[] memory fixedPrices_,
address[] memory uniswapMarkets_, bool[] memory isPrice1FromUniswapArray_)
UniswapConfig(gTokens_, underlyings_, symbolHashs_, baseUints_, priceSources_, fixedPrices_, uniswapMarkets_,
isPrice1FromUniswapArray_) public {
anchorPeriod = anchorPeriod_;
for (uint i = 0; i < gTokens_.length; i++) {
TokenConfig memory config = TokenConfig({ gToken : gTokens_[i], underlying : underlyings_[i],
symbolHash : symbolHashs_[i], baseUnit : baseUints_[i],
priceSource: priceSources_[i], fixedPrice: fixedPrices_[i],
uniswapMarket : uniswapMarkets_[i], isPrice1FromUniswap : isPrice1FromUniswapArray_[i] });
require(config.baseUnit > 0, "baseUnit must be greater than zero");
address uniswapMarket = config.uniswapMarket;
require(config.priceSource == PriceSource.FIXED_USD || config.priceSource == PriceSource.REPORTER_USD
|| config.priceSource == PriceSource.REPORTER_ETH, "unsupported PriceSource type");
if (config.priceSource == PriceSource.REPORTER_ETH || config.priceSource == PriceSource.REPORTER_USD) {
require(uniswapMarket != address(0), "reported prices must have an anchor");
bytes32 symbolHash = config.symbolHash;
uint cumulativePrice = currentCumulativePrice(config);
oldObservations[symbolHash].timestamp = block.timestamp;
newObservations[symbolHash].timestamp = block.timestamp;
oldObservations[symbolHash].acc = cumulativePrice;
newObservations[symbolHash].acc = cumulativePrice;
emit UniswapWindowUpdated(symbolHash, block.timestamp, block.timestamp, cumulativePrice, cumulativePrice);
} else {
require(uniswapMarket == address(0), "only reported prices utilize an anchor");
}
}
}
/**
* @notice Get the official price for a symbol
* @param symbol The symbol to fetch the price of
* @return Price denominated in USD, with 6 decimals
*/
function price(string calldata symbol) external view returns (uint) {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
return priceInternal(config);
}
function priceInternal(TokenConfig memory config) internal view returns (uint) {
if (config.priceSource == PriceSource.REPORTER_ETH || config.priceSource == PriceSource.REPORTER_USD) return prices[config.symbolHash];
if (config.priceSource == PriceSource.FIXED_USD) return config.fixedPrice;
return 0;
}
/**
* @notice Get the underlying price of a gToken
* @dev Implements the PriceOracle interface for Compound v2.
* @param gToken The gToken address for price retrieval
* @return Price denominated in USD, with 18 decimals, for the given gToken address
*/
function getUnderlyingPrice(address gToken) external view returns (uint) {
TokenConfig memory config = getTokenConfigByCToken(gToken);
// Comptroller needs prices in the format: ${raw price} * 1e(36 - baseUnit)
// Since the prices in this view have 6 decimals, we must scale them by 1e(36 - 6 - baseUnit)
return mul(1e30, priceInternal(config)) / config.baseUnit;
}
function refresh(string[] calldata symbols) external {
uint ethPrice = fetchEthPrice();
// Try to update the view storage
for (uint i = 0; i < symbols.length; i++) {
postPriceInternal(symbols[i], ethPrice);
}
}
function postPriceInternal(string memory symbol, uint ethPrice) internal {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
bytes32 symbolHash = keccak256(abi.encodePacked(symbol));
uint anchorPrice;
if (symbolHash == ethHash) {
anchorPrice = ethPrice;
} else if (config.priceSource == PriceSource.REPORTER_ETH){
anchorPrice = fetchAnchorPriceETH(symbol, config, ethPrice);
}
else if(config.priceSource == PriceSource.REPORTER_USD) {
anchorPrice = fetchAnchorPriceUSD(symbol, config);
}
else{
revert("wrong config.priceSource");
}
prices[symbolHash] = anchorPrice;
emit PriceUpdated(symbol, anchorPrice);
}
/**
* @dev Fetches the current token/eth price accumulator from uniswap.
*/
function currentCumulativePrice(TokenConfig memory config) internal view returns (uint) {
(uint cumulativePrice0, uint cumulativePrice1,) = UniswapV2OracleLibrary.currentCumulativePrices(config.uniswapMarket);
if (config.isPrice1FromUniswap) {
return cumulativePrice1;
} else {
return cumulativePrice0;
}
}
/**
* @dev Fetches the current eth/usd price from dex swap, with 6 decimals of precision.
* Conversion factor is 1e18 for eth/usdc market, since we decode uniswap price statically with 18 decimals.
*/
function fetchEthPrice() internal returns (uint) {
return fetchAnchorPriceUSD("ETH", getTokenConfigBySymbolHash(ethHash));
}
/**
* price as usd = token/eth price * eth price
*
* @dev Fetches the current token usd price from dex swap, with 6 decimals of precision.
* @param ethPrice : with 6 decimals of precision
*/
function fetchAnchorPriceETH(string memory symbol, TokenConfig memory config, uint ethPrice) internal virtual returns (uint) {
(uint nowCumulativePrice, uint oldCumulativePrice, uint oldTimestamp) = pokeWindowValues(config);
// This should be impossible, but better safe than sorry
require(block.timestamp > oldTimestamp, "now must come after before");
uint timeElapsed = block.timestamp - oldTimestamp;
// Calculate uniswap time-weighted average price
// Underflow is a property of the accumulators: https://uniswap.org/audit.html#orgc9b3190
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, ethPrice);
uint anchorPrice = mul(unscaledPriceMantissa, config.baseUnit) / ethBaseUnit / expScale;
emit AnchorPriceUpdated(symbol, anchorPrice, oldTimestamp, block.timestamp);
return anchorPrice;
}
/**
* @dev Fetches the current token/usd stable coin price from dex swap, with 6 decimals of precision.
*/
function fetchAnchorPriceUSD(string memory symbol, TokenConfig memory config) internal virtual returns (uint) {
(uint nowCumulativePrice, uint oldCumulativePrice, uint oldTimestamp) = pokeWindowValues(config);
// This should be impossible, but better safe than sorry
require(block.timestamp > oldTimestamp, "now must come after before");
uint timeElapsed = block.timestamp - oldTimestamp;
// Calculate uniswap time-weighted average price
// Underflow is a property of the accumulators: https://uniswap.org/audit.html#orgc9b3190
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, config.baseUnit);
//uint anchorPrice = mul(unscaledPriceMantissa , 1e6) / usdtBaseUnit / expScale;
// usdtBaseUnit == 1e6,
// so , anchorPrice = unscaledPriceMantissa / expScale
uint anchorPrice = unscaledPriceMantissa / expScale;
emit AnchorPriceUpdated(symbol, anchorPrice, oldTimestamp, block.timestamp);
return anchorPrice;
}
/**
* @dev Get time-weighted average prices for a token at the current timestamp.
* Update new and old observations of lagging window if period elapsed.
*/
function pokeWindowValues(TokenConfig memory config) internal returns (uint, uint, uint) {
bytes32 symbolHash = config.symbolHash;
uint cumulativePrice = currentCumulativePrice(config);
Observation memory newObservation = newObservations[symbolHash];
// Update new and old observations if elapsed time is greater than or equal to anchor period
uint timeElapsed = block.timestamp - newObservation.timestamp;
if (timeElapsed >= anchorPeriod) {
oldObservations[symbolHash].timestamp = newObservation.timestamp;
oldObservations[symbolHash].acc = newObservation.acc;
newObservations[symbolHash].timestamp = block.timestamp;
newObservations[symbolHash].acc = cumulativePrice;
emit UniswapWindowUpdated(config.symbolHash, newObservation.timestamp, block.timestamp, newObservation.acc, cumulativePrice);
}
return (cumulativePrice, oldObservations[symbolHash].acc, oldObservations[symbolHash].timestamp);
}
/**
* @notice Recovers the source address which signed a message
* @dev Comparing to a claimed address would add nothing,
* as the caller could simply perform the recover and claim that address.
* @param message The data that was presumably signed
* @param signature The fingerprint of the data + private key
* @return The source address which signed the message, presumably
*/
function source(bytes memory message, bytes memory signature) public pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", keccak256(message)));
return ecrecover(hash, v, r, s);
}
/// @dev Overflow proof multiplication
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) return 0;
uint c = a * b;
require(c / a == b, "multiplication overflow");
return c;
}
// get market USD price from dex with 6 decimal
// for web only , not for lend contract
function getMarketPrice(string calldata symbol) external view returns (uint) {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
uint marketPrice = 0;
if(config.priceSource == PriceSource.FIXED_USD){ // Fixed price
marketPrice = config.fixedPrice;
}else if(config.priceSource == PriceSource.REPORTER_ETH){
// For ETH, it is divided into two steps, first calculate the pair of ETH,
// and then convert it into USD, and USD decimal is 6 bits
uint ethPrice = fetchMarketPriceByUsdtPair(getTokenConfigBySymbolHash(ethHash));
marketPrice = fetchMarketPriceByEthPair(config, ethPrice);
}else if(config.priceSource == PriceSource.REPORTER_USD){ // For USD
marketPrice = fetchMarketPriceByUsdtPair(config);
}
return marketPrice;
}
// fetch Token/WETH market price as USD with 6 decimal
function fetchMarketPriceByEthPair(TokenConfig memory config, uint ethPrice) internal view virtual returns (uint) {
uint marketPrice = 0;
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(config.uniswapMarket).getReserves();
if(config.isPrice1FromUniswap){
if(reserve1 != 0){
// price = (reserve0 / ethBaseUnit) / (reserve1 / config.baseUnit) * ethPrice;
// reserve0 is WETH, reserve1 is gtoken // Multiply before divide bigNumber
marketPrice = mul(mul(reserve0, config.baseUnit), ethPrice) / ethBaseUnit / reserve1;
}
}else{
if(reserve0 != 0){
// price = (reserve1 / ethBaseUnit) / (reserve0 / config.baseUnit) * ethPrice;
// reserve1 is WETH, reserve0 is gtoken
marketPrice = mul(mul(reserve1, config.baseUnit), ethPrice) / ethBaseUnit / reserve0;
}
}
return marketPrice;
}
function fetchMarketPriceByUsdtPair(TokenConfig memory config) internal view virtual returns (uint) {<FILL_FUNCTION_BODY> }
} | contract UniswapPriceOracleV2 is UniswapConfig {
using FixedPoint for *;
/// @notice The number of wei in 1 ETH
uint public constant ethBaseUnit = 1e18;
uint public constant usdtBaseUnit = 1e6;
/// @notice A common scaling factor to maintain precision
uint public constant expScale = 1e18;
/// @notice The minimum amount of time in seconds required for the old uniswap price accumulator to be replaced
uint public immutable anchorPeriod;
/// @notice Official prices by symbol hash
mapping(bytes32 => uint) public prices;
/// @notice The old observation for each symbolHash
mapping(bytes32 => Observation) public oldObservations;
/// @notice The new observation for each symbolHash
mapping(bytes32 => Observation) public newObservations;
/// @notice The event emitted when new prices are posted but the stored price is not updated due to the anchor
event PriceGuarded(string symbol, uint reporter, uint anchor);
/// @notice The event emitted when the stored price is updated
event PriceUpdated(string symbol, uint price);
/// @notice The event emitted when anchor price is updated
event AnchorPriceUpdated(string symbol, uint anchorPrice, uint oldTimestamp, uint newTimestamp);
/// @notice The event emitted when the uniswap window changes
event UniswapWindowUpdated(bytes32 indexed symbolHash, uint oldTimestamp, uint newTimestamp, uint oldPrice, uint newPrice);
bytes32 constant ethHash = keccak256(abi.encodePacked("ETH"));
constructor(uint anchorPeriod_,
address[] memory gTokens_, address[] memory underlyings_,
bytes32[] memory symbolHashs_, uint256[] memory baseUints_,
PriceSource[] memory priceSources_, uint256[] memory fixedPrices_,
address[] memory uniswapMarkets_, bool[] memory isPrice1FromUniswapArray_)
UniswapConfig(gTokens_, underlyings_, symbolHashs_, baseUints_, priceSources_, fixedPrices_, uniswapMarkets_,
isPrice1FromUniswapArray_) public {
anchorPeriod = anchorPeriod_;
for (uint i = 0; i < gTokens_.length; i++) {
TokenConfig memory config = TokenConfig({ gToken : gTokens_[i], underlying : underlyings_[i],
symbolHash : symbolHashs_[i], baseUnit : baseUints_[i],
priceSource: priceSources_[i], fixedPrice: fixedPrices_[i],
uniswapMarket : uniswapMarkets_[i], isPrice1FromUniswap : isPrice1FromUniswapArray_[i] });
require(config.baseUnit > 0, "baseUnit must be greater than zero");
address uniswapMarket = config.uniswapMarket;
require(config.priceSource == PriceSource.FIXED_USD || config.priceSource == PriceSource.REPORTER_USD
|| config.priceSource == PriceSource.REPORTER_ETH, "unsupported PriceSource type");
if (config.priceSource == PriceSource.REPORTER_ETH || config.priceSource == PriceSource.REPORTER_USD) {
require(uniswapMarket != address(0), "reported prices must have an anchor");
bytes32 symbolHash = config.symbolHash;
uint cumulativePrice = currentCumulativePrice(config);
oldObservations[symbolHash].timestamp = block.timestamp;
newObservations[symbolHash].timestamp = block.timestamp;
oldObservations[symbolHash].acc = cumulativePrice;
newObservations[symbolHash].acc = cumulativePrice;
emit UniswapWindowUpdated(symbolHash, block.timestamp, block.timestamp, cumulativePrice, cumulativePrice);
} else {
require(uniswapMarket == address(0), "only reported prices utilize an anchor");
}
}
}
/**
* @notice Get the official price for a symbol
* @param symbol The symbol to fetch the price of
* @return Price denominated in USD, with 6 decimals
*/
function price(string calldata symbol) external view returns (uint) {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
return priceInternal(config);
}
function priceInternal(TokenConfig memory config) internal view returns (uint) {
if (config.priceSource == PriceSource.REPORTER_ETH || config.priceSource == PriceSource.REPORTER_USD) return prices[config.symbolHash];
if (config.priceSource == PriceSource.FIXED_USD) return config.fixedPrice;
return 0;
}
/**
* @notice Get the underlying price of a gToken
* @dev Implements the PriceOracle interface for Compound v2.
* @param gToken The gToken address for price retrieval
* @return Price denominated in USD, with 18 decimals, for the given gToken address
*/
function getUnderlyingPrice(address gToken) external view returns (uint) {
TokenConfig memory config = getTokenConfigByCToken(gToken);
// Comptroller needs prices in the format: ${raw price} * 1e(36 - baseUnit)
// Since the prices in this view have 6 decimals, we must scale them by 1e(36 - 6 - baseUnit)
return mul(1e30, priceInternal(config)) / config.baseUnit;
}
function refresh(string[] calldata symbols) external {
uint ethPrice = fetchEthPrice();
// Try to update the view storage
for (uint i = 0; i < symbols.length; i++) {
postPriceInternal(symbols[i], ethPrice);
}
}
function postPriceInternal(string memory symbol, uint ethPrice) internal {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
bytes32 symbolHash = keccak256(abi.encodePacked(symbol));
uint anchorPrice;
if (symbolHash == ethHash) {
anchorPrice = ethPrice;
} else if (config.priceSource == PriceSource.REPORTER_ETH){
anchorPrice = fetchAnchorPriceETH(symbol, config, ethPrice);
}
else if(config.priceSource == PriceSource.REPORTER_USD) {
anchorPrice = fetchAnchorPriceUSD(symbol, config);
}
else{
revert("wrong config.priceSource");
}
prices[symbolHash] = anchorPrice;
emit PriceUpdated(symbol, anchorPrice);
}
/**
* @dev Fetches the current token/eth price accumulator from uniswap.
*/
function currentCumulativePrice(TokenConfig memory config) internal view returns (uint) {
(uint cumulativePrice0, uint cumulativePrice1,) = UniswapV2OracleLibrary.currentCumulativePrices(config.uniswapMarket);
if (config.isPrice1FromUniswap) {
return cumulativePrice1;
} else {
return cumulativePrice0;
}
}
/**
* @dev Fetches the current eth/usd price from dex swap, with 6 decimals of precision.
* Conversion factor is 1e18 for eth/usdc market, since we decode uniswap price statically with 18 decimals.
*/
function fetchEthPrice() internal returns (uint) {
return fetchAnchorPriceUSD("ETH", getTokenConfigBySymbolHash(ethHash));
}
/**
* price as usd = token/eth price * eth price
*
* @dev Fetches the current token usd price from dex swap, with 6 decimals of precision.
* @param ethPrice : with 6 decimals of precision
*/
function fetchAnchorPriceETH(string memory symbol, TokenConfig memory config, uint ethPrice) internal virtual returns (uint) {
(uint nowCumulativePrice, uint oldCumulativePrice, uint oldTimestamp) = pokeWindowValues(config);
// This should be impossible, but better safe than sorry
require(block.timestamp > oldTimestamp, "now must come after before");
uint timeElapsed = block.timestamp - oldTimestamp;
// Calculate uniswap time-weighted average price
// Underflow is a property of the accumulators: https://uniswap.org/audit.html#orgc9b3190
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, ethPrice);
uint anchorPrice = mul(unscaledPriceMantissa, config.baseUnit) / ethBaseUnit / expScale;
emit AnchorPriceUpdated(symbol, anchorPrice, oldTimestamp, block.timestamp);
return anchorPrice;
}
/**
* @dev Fetches the current token/usd stable coin price from dex swap, with 6 decimals of precision.
*/
function fetchAnchorPriceUSD(string memory symbol, TokenConfig memory config) internal virtual returns (uint) {
(uint nowCumulativePrice, uint oldCumulativePrice, uint oldTimestamp) = pokeWindowValues(config);
// This should be impossible, but better safe than sorry
require(block.timestamp > oldTimestamp, "now must come after before");
uint timeElapsed = block.timestamp - oldTimestamp;
// Calculate uniswap time-weighted average price
// Underflow is a property of the accumulators: https://uniswap.org/audit.html#orgc9b3190
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, config.baseUnit);
//uint anchorPrice = mul(unscaledPriceMantissa , 1e6) / usdtBaseUnit / expScale;
// usdtBaseUnit == 1e6,
// so , anchorPrice = unscaledPriceMantissa / expScale
uint anchorPrice = unscaledPriceMantissa / expScale;
emit AnchorPriceUpdated(symbol, anchorPrice, oldTimestamp, block.timestamp);
return anchorPrice;
}
/**
* @dev Get time-weighted average prices for a token at the current timestamp.
* Update new and old observations of lagging window if period elapsed.
*/
function pokeWindowValues(TokenConfig memory config) internal returns (uint, uint, uint) {
bytes32 symbolHash = config.symbolHash;
uint cumulativePrice = currentCumulativePrice(config);
Observation memory newObservation = newObservations[symbolHash];
// Update new and old observations if elapsed time is greater than or equal to anchor period
uint timeElapsed = block.timestamp - newObservation.timestamp;
if (timeElapsed >= anchorPeriod) {
oldObservations[symbolHash].timestamp = newObservation.timestamp;
oldObservations[symbolHash].acc = newObservation.acc;
newObservations[symbolHash].timestamp = block.timestamp;
newObservations[symbolHash].acc = cumulativePrice;
emit UniswapWindowUpdated(config.symbolHash, newObservation.timestamp, block.timestamp, newObservation.acc, cumulativePrice);
}
return (cumulativePrice, oldObservations[symbolHash].acc, oldObservations[symbolHash].timestamp);
}
/**
* @notice Recovers the source address which signed a message
* @dev Comparing to a claimed address would add nothing,
* as the caller could simply perform the recover and claim that address.
* @param message The data that was presumably signed
* @param signature The fingerprint of the data + private key
* @return The source address which signed the message, presumably
*/
function source(bytes memory message, bytes memory signature) public pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", keccak256(message)));
return ecrecover(hash, v, r, s);
}
/// @dev Overflow proof multiplication
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) return 0;
uint c = a * b;
require(c / a == b, "multiplication overflow");
return c;
}
// get market USD price from dex with 6 decimal
// for web only , not for lend contract
function getMarketPrice(string calldata symbol) external view returns (uint) {
TokenConfig memory config = getTokenConfigBySymbol(symbol);
uint marketPrice = 0;
if(config.priceSource == PriceSource.FIXED_USD){ // Fixed price
marketPrice = config.fixedPrice;
}else if(config.priceSource == PriceSource.REPORTER_ETH){
// For ETH, it is divided into two steps, first calculate the pair of ETH,
// and then convert it into USD, and USD decimal is 6 bits
uint ethPrice = fetchMarketPriceByUsdtPair(getTokenConfigBySymbolHash(ethHash));
marketPrice = fetchMarketPriceByEthPair(config, ethPrice);
}else if(config.priceSource == PriceSource.REPORTER_USD){ // For USD
marketPrice = fetchMarketPriceByUsdtPair(config);
}
return marketPrice;
}
// fetch Token/WETH market price as USD with 6 decimal
function fetchMarketPriceByEthPair(TokenConfig memory config, uint ethPrice) internal view virtual returns (uint) {
uint marketPrice = 0;
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(config.uniswapMarket).getReserves();
if(config.isPrice1FromUniswap){
if(reserve1 != 0){
// price = (reserve0 / ethBaseUnit) / (reserve1 / config.baseUnit) * ethPrice;
// reserve0 is WETH, reserve1 is gtoken // Multiply before divide bigNumber
marketPrice = mul(mul(reserve0, config.baseUnit), ethPrice) / ethBaseUnit / reserve1;
}
}else{
if(reserve0 != 0){
// price = (reserve1 / ethBaseUnit) / (reserve0 / config.baseUnit) * ethPrice;
// reserve1 is WETH, reserve0 is gtoken
marketPrice = mul(mul(reserve1, config.baseUnit), ethPrice) / ethBaseUnit / reserve0;
}
}
return marketPrice;
}
<FILL_FUNCTION>
} |
uint marketPrice = 0;
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(config.uniswapMarket).getReserves();
if(config.isPrice1FromUniswap){
if(reserve1 != 0){
// price = (reserve0 / usdtBaseUnit) / (reserve1 / config.baseUnit) * 1e6;
// price = reserve0 * config.baseUnit * 1e6 / usdtBaseUnit / reserve1;
// reserve0 is USDT, reserve1 is underlying Token
marketPrice = mul(mul(reserve0, config.baseUnit), 1e6) / usdtBaseUnit / reserve1;
}
}else{
if(reserve0 != 0){
// price = (reserve1 / usdtBaseUnit) / (reserve0 / config.baseUnit) * 1e6;
// price = reserve1 * config.baseUnit * 1e6 / usdtBaseUnit / reserve0;
// reserve1 is USDT, reserve0 is underlying Token
marketPrice = mul(mul(reserve1, config.baseUnit), 1e6) / usdtBaseUnit / reserve0;
}
}
return marketPrice;
| function fetchMarketPriceByUsdtPair(TokenConfig memory config) internal view virtual returns (uint) | function fetchMarketPriceByUsdtPair(TokenConfig memory config) internal view virtual returns (uint) |
24347 | Ownable | transferOwnership | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
} |
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
| function transferOwnership(address newOwner) onlyOwner public | /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public |
66375 | SHE | distr | contract SHE is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public blacklist;
string public constant name = "SHE";
string public constant symbol = "SHE";
uint public constant decimals = 18;
uint256 public totalSupply = 1000000000e18;
uint256 public totalDistributed = 700000000e18;
uint256 public totalRemaining = totalSupply.sub(totalDistributed);
uint256 public value = 8000e18;
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 Burn(address indexed burner, uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
}
modifier valueAccepted() {
require(msg.value%(1*10**16)==0); // 0.01
_;
}
constructor() public {
owner = msg.sender;
balances[owner] = totalDistributed;
}
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) {<FILL_FUNCTION_BODY> }
function () external payable {
getTokens();
}
function getTokens() payable canDistr onlyWhitelist valueAccepted public {
if (value > totalRemaining) {
value = totalRemaining;
}
require(value <= totalRemaining);
address investor = msg.sender;
uint256 toGive = value;
distr(investor, toGive);
if (toGive > 0) {
blacklist[investor] = true;
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
value = value.div(100000).mul(99999);
uint256 etherBalance = this.balance;
if (etherBalance > 0) {
owner.transfer(etherBalance);
}
}
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 withdraw() onlyOwner public {
uint256 etherBalance = address(this).balance;
owner.transfer(etherBalance);
}
function burn(uint256 _value) onlyOwner public {
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 withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | contract SHE is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public blacklist;
string public constant name = "SHE";
string public constant symbol = "SHE";
uint public constant decimals = 18;
uint256 public totalSupply = 1000000000e18;
uint256 public totalDistributed = 700000000e18;
uint256 public totalRemaining = totalSupply.sub(totalDistributed);
uint256 public value = 8000e18;
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 Burn(address indexed burner, uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
}
modifier valueAccepted() {
require(msg.value%(1*10**16)==0); // 0.01
_;
}
constructor() public {
owner = msg.sender;
balances[owner] = totalDistributed;
}
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;
}
<FILL_FUNCTION>
function () external payable {
getTokens();
}
function getTokens() payable canDistr onlyWhitelist valueAccepted public {
if (value > totalRemaining) {
value = totalRemaining;
}
require(value <= totalRemaining);
address investor = msg.sender;
uint256 toGive = value;
distr(investor, toGive);
if (toGive > 0) {
blacklist[investor] = true;
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
value = value.div(100000).mul(99999);
uint256 etherBalance = this.balance;
if (etherBalance > 0) {
owner.transfer(etherBalance);
}
}
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 withdraw() onlyOwner public {
uint256 etherBalance = address(this).balance;
owner.transfer(etherBalance);
}
function burn(uint256 _value) onlyOwner public {
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 withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} |
totalDistributed = totalDistributed.add(_amount);
totalRemaining = totalRemaining.sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Distr(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
| function distr(address _to, uint256 _amount) canDistr private returns (bool) | function distr(address _to, uint256 _amount) canDistr private returns (bool) |
37662 | Manageable | countManagers | contract Manageable is Ownable {
address[] public managers;
event ManagerAdded(address indexed manager);
event ManagerRemoved(address indexed manager);
modifier onlyManager() { require(isManager(msg.sender)); _; }
function countManagers() view public returns(uint) {<FILL_FUNCTION_BODY> }
function getManagers() view public returns(address[]) {
return managers;
}
function isManager(address _manager) view public returns(bool) {
for(uint i = 0; i < managers.length; i++) {
if(managers[i] == _manager) {
return true;
}
}
return false;
}
function addManager(address _manager) onlyOwner public {
require(_manager != address(0));
require(!isManager(_manager));
managers.push(_manager);
emit ManagerAdded(_manager);
}
function removeManager(address _manager) onlyOwner public {
uint index = managers.length;
for(uint i = 0; i < managers.length; i++) {
if(managers[i] == _manager) {
index = i;
}
}
if(index >= managers.length) revert();
for(; index < managers.length - 1; index++) {
managers[index] = managers[index + 1];
}
managers.length--;
emit ManagerRemoved(_manager);
}
} | contract Manageable is Ownable {
address[] public managers;
event ManagerAdded(address indexed manager);
event ManagerRemoved(address indexed manager);
modifier onlyManager() { require(isManager(msg.sender)); _; }
<FILL_FUNCTION>
function getManagers() view public returns(address[]) {
return managers;
}
function isManager(address _manager) view public returns(bool) {
for(uint i = 0; i < managers.length; i++) {
if(managers[i] == _manager) {
return true;
}
}
return false;
}
function addManager(address _manager) onlyOwner public {
require(_manager != address(0));
require(!isManager(_manager));
managers.push(_manager);
emit ManagerAdded(_manager);
}
function removeManager(address _manager) onlyOwner public {
uint index = managers.length;
for(uint i = 0; i < managers.length; i++) {
if(managers[i] == _manager) {
index = i;
}
}
if(index >= managers.length) revert();
for(; index < managers.length - 1; index++) {
managers[index] = managers[index + 1];
}
managers.length--;
emit ManagerRemoved(_manager);
}
} |
return managers.length;
| function countManagers() view public returns(uint) | function countManagers() view public returns(uint) |
79915 | Token | transferERC20Token | contract Token is StandardToken, SafeMath {
// Time of the contract creation
uint public creationTime;
function Token() {
creationTime = now;
}
/// @dev Owner can transfer out any accidentally sent ERC20 tokens
function transferERC20Token(address tokenAddress)
public
onlyOwner
returns (bool)
{<FILL_FUNCTION_BODY> }
/// @dev Multiplies the given number by 10^(decimals)
function withDecimals(uint number, uint decimals)
internal
returns (uint)
{
return mul(number, pow(10, decimals));
}
} | contract Token is StandardToken, SafeMath {
// Time of the contract creation
uint public creationTime;
function Token() {
creationTime = now;
}
<FILL_FUNCTION>
/// @dev Multiplies the given number by 10^(decimals)
function withDecimals(uint number, uint decimals)
internal
returns (uint)
{
return mul(number, pow(10, decimals));
}
} |
uint balance = AbstractToken(tokenAddress).balanceOf(this);
return AbstractToken(tokenAddress).transfer(owner, balance);
| function transferERC20Token(address tokenAddress)
public
onlyOwner
returns (bool)
| /// @dev Owner can transfer out any accidentally sent ERC20 tokens
function transferERC20Token(address tokenAddress)
public
onlyOwner
returns (bool)
|
69768 | Primetama | null | contract Primetama is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcludedFromMaxTx;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "PRIMETAMA";
string private _symbol = "PTAMA";
uint8 private _decimals = 9;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _devFee = 8;
uint256 private _previousDevFee = _devFee;
uint256 public _liquidityFee = 1;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public maxTxAmount = _tTotal.mul(20).div(1000); // 2%
address payable private _devWallet = payable(0x80b625ea44CAB6F8C0C0CBa059B6f9283afee665);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 private minTokensBeforeSwap = 100000000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 liquidityEthBalance,
uint256 devEthBalance
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () public {<FILL_FUNCTION_BODY> }
function setRouterAddress(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newUniswapRouter = IUniswapV2Router02(newRouter);
uniswapV2Pair = IUniswapV2Factory(_newUniswapRouter.factory()).createPair(address(this), _newUniswapRouter.WETH());
uniswapV2Router = _newUniswapRouter;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner() {
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 _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0));
require(spender != address(0));
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function expectedRewards(address _sender) external view returns(uint256){
uint256 _balance = address(this).balance;
address sender = _sender;
uint256 holdersBal = balanceOf(sender);
uint totalExcludedBal;
for (uint256 i = 0; i < _excluded.length; i++){
totalExcludedBal = balanceOf(_excluded[i]).add(totalExcludedBal);
}
uint256 rewards = holdersBal.mul(_balance).div(_tTotal.sub(balanceOf(uniswapV2Pair)).sub(totalExcludedBal));
return rewards;
}
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");
if (
!_isExcludedFromMaxTx[from] &&
!_isExcludedFromMaxTx[to] // by default false
) {
require(
amount <= maxTxAmount,
"Transfer amount exceeds the maxTxAmount."
);
}
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
// add liquidity
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, dev fee, liquidity fee
_tokenTransfer(from, to, amount, takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// balance token fees based on variable percents
uint256 totalRedirectTokenFee = _devFee.add(_liquidityFee);
if (totalRedirectTokenFee == 0) return;
uint256 liquidityTokenBalance = contractTokenBalance.mul(_liquidityFee).div(totalRedirectTokenFee);
uint256 devTokenBalance = contractTokenBalance.mul(_devFee).div(totalRedirectTokenFee);
// split the liquidity balance into halves
uint256 halfLiquidity = liquidityTokenBalance.div(2);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the fee events include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
if (liquidityTokenBalance == 0 && devTokenBalance == 0) return;
// swap tokens for ETH
swapTokensForEth(devTokenBalance.add(halfLiquidity));
uint256 newBalance = address(this).balance.sub(initialBalance);
if(newBalance > 0) {
// rebalance ETH fees proportionally to half the liquidity
uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2));
uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee);
uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
//
// for liquidity
// add to uniswap
//
addLiquidity(halfLiquidity, liquidityEthBalance);
//
// for dev fee
// send to the dev address
//
sendEthToDevAddress(devEthBalance);
emit SwapAndLiquify(contractTokenBalance, liquidityEthBalance, devEthBalance);
}
}
function sendEthToDevAddress(uint256 amount) private {
_devWallet.transfer(amount);
}
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
);
}
//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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _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);
_takeDev(tDev);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tDev, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tDev = calculateDevFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tDev).sub(tLiquidity);
return (tTransferAmount, tFee, tDev, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tDev, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rDev = tDev.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rDev).sub(rLiquidity);
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 _takeDev(uint256 tDev) private {
uint256 currentRate = _getRate();
uint256 rDev = tDev.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rDev);
if(_isExcluded[address(this)]) {
_tOwned[address(this)] = _tOwned[address(this)].add(tDev);
}
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(100);
}
function calculateDevFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_devFee).div(100);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityFee).div(100);
}
function removeAllFee() private {
if(_taxFee == 0 && _devFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousDevFee = _devFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_devFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_devFee = _previousDevFee;
_liquidityFee = _previousLiquidityFee;
}
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractEthBalance = address(this).balance;
sendEthToDevAddress(contractEthBalance);
}
function isExcludedFromFee(address account) external view returns(bool) {
return _isExcludedFromFee[account];
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
}
// for 0.5% input 5, for 1% input 10
function setMaxTxPercent(uint256 newMaxTx) external onlyOwner {
require(newMaxTx >= 5, "Max TX should be above 0.5%");
maxTxAmount = _tTotal.mul(newMaxTx).div(1000);
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
require(taxFee <= 8, "Maximum fee limit is 8 percent");
_taxFee = taxFee;
}
function setDevFeePercent(uint256 devFee) external onlyOwner() {
require(devFee <= 8, "Maximum fee limit is 8 percent");
_devFee = devFee;
}
function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
require(liquidityFee <= 8, "Maximum fee limit is 8 percent");
_liquidityFee = liquidityFee;
}
function setSwapAndLiquifyEnabled(bool _enabled) external onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setMinTokensBeforeSwap(uint256 minTokens) external onlyOwner {
minTokensBeforeSwap = minTokens * 10**9;
emit MinTokensBeforeSwapUpdated(minTokens);
}
// to receive ETH from uniswapV2Router when swaping
receive() external payable {}
} | contract Primetama is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcludedFromMaxTx;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "PRIMETAMA";
string private _symbol = "PTAMA";
uint8 private _decimals = 9;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _devFee = 8;
uint256 private _previousDevFee = _devFee;
uint256 public _liquidityFee = 1;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public maxTxAmount = _tTotal.mul(20).div(1000); // 2%
address payable private _devWallet = payable(0x80b625ea44CAB6F8C0C0CBa059B6f9283afee665);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 private minTokensBeforeSwap = 100000000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 liquidityEthBalance,
uint256 devEthBalance
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
<FILL_FUNCTION>
function setRouterAddress(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newUniswapRouter = IUniswapV2Router02(newRouter);
uniswapV2Pair = IUniswapV2Factory(_newUniswapRouter.factory()).createPair(address(this), _newUniswapRouter.WETH());
uniswapV2Router = _newUniswapRouter;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner() {
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 _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0));
require(spender != address(0));
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function expectedRewards(address _sender) external view returns(uint256){
uint256 _balance = address(this).balance;
address sender = _sender;
uint256 holdersBal = balanceOf(sender);
uint totalExcludedBal;
for (uint256 i = 0; i < _excluded.length; i++){
totalExcludedBal = balanceOf(_excluded[i]).add(totalExcludedBal);
}
uint256 rewards = holdersBal.mul(_balance).div(_tTotal.sub(balanceOf(uniswapV2Pair)).sub(totalExcludedBal));
return rewards;
}
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");
if (
!_isExcludedFromMaxTx[from] &&
!_isExcludedFromMaxTx[to] // by default false
) {
require(
amount <= maxTxAmount,
"Transfer amount exceeds the maxTxAmount."
);
}
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
// add liquidity
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, dev fee, liquidity fee
_tokenTransfer(from, to, amount, takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// balance token fees based on variable percents
uint256 totalRedirectTokenFee = _devFee.add(_liquidityFee);
if (totalRedirectTokenFee == 0) return;
uint256 liquidityTokenBalance = contractTokenBalance.mul(_liquidityFee).div(totalRedirectTokenFee);
uint256 devTokenBalance = contractTokenBalance.mul(_devFee).div(totalRedirectTokenFee);
// split the liquidity balance into halves
uint256 halfLiquidity = liquidityTokenBalance.div(2);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the fee events include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
if (liquidityTokenBalance == 0 && devTokenBalance == 0) return;
// swap tokens for ETH
swapTokensForEth(devTokenBalance.add(halfLiquidity));
uint256 newBalance = address(this).balance.sub(initialBalance);
if(newBalance > 0) {
// rebalance ETH fees proportionally to half the liquidity
uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2));
uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee);
uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
//
// for liquidity
// add to uniswap
//
addLiquidity(halfLiquidity, liquidityEthBalance);
//
// for dev fee
// send to the dev address
//
sendEthToDevAddress(devEthBalance);
emit SwapAndLiquify(contractTokenBalance, liquidityEthBalance, devEthBalance);
}
}
function sendEthToDevAddress(uint256 amount) private {
_devWallet.transfer(amount);
}
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
);
}
//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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeDev(tDev);
_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 tDev, uint256 tLiquidity) = _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);
_takeDev(tDev);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tDev, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tDev = calculateDevFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tDev).sub(tLiquidity);
return (tTransferAmount, tFee, tDev, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tDev, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rDev = tDev.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rDev).sub(rLiquidity);
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 _takeDev(uint256 tDev) private {
uint256 currentRate = _getRate();
uint256 rDev = tDev.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rDev);
if(_isExcluded[address(this)]) {
_tOwned[address(this)] = _tOwned[address(this)].add(tDev);
}
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(100);
}
function calculateDevFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_devFee).div(100);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityFee).div(100);
}
function removeAllFee() private {
if(_taxFee == 0 && _devFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousDevFee = _devFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_devFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_devFee = _previousDevFee;
_liquidityFee = _previousLiquidityFee;
}
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractEthBalance = address(this).balance;
sendEthToDevAddress(contractEthBalance);
}
function isExcludedFromFee(address account) external view returns(bool) {
return _isExcludedFromFee[account];
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
}
// for 0.5% input 5, for 1% input 10
function setMaxTxPercent(uint256 newMaxTx) external onlyOwner {
require(newMaxTx >= 5, "Max TX should be above 0.5%");
maxTxAmount = _tTotal.mul(newMaxTx).div(1000);
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
require(taxFee <= 8, "Maximum fee limit is 8 percent");
_taxFee = taxFee;
}
function setDevFeePercent(uint256 devFee) external onlyOwner() {
require(devFee <= 8, "Maximum fee limit is 8 percent");
_devFee = devFee;
}
function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
require(liquidityFee <= 8, "Maximum fee limit is 8 percent");
_liquidityFee = liquidityFee;
}
function setSwapAndLiquifyEnabled(bool _enabled) external onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setMinTokensBeforeSwap(uint256 minTokens) external onlyOwner {
minTokensBeforeSwap = minTokens * 10**9;
emit MinTokensBeforeSwapUpdated(minTokens);
}
// to receive ETH from uniswapV2Router when swaping
receive() external payable {}
} |
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
// internal exclude from max tx
_isExcludedFromMaxTx[owner()] = true;
_isExcludedFromMaxTx[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
| constructor () public | constructor () public |
8459 | SafeMath | safeMult | contract SafeMath {
function safeAdd(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
function safeSubtract(uint256 x, uint256 y) internal pure returns(uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
function safeMult(uint256 x, uint256 y) internal pure returns(uint256) {<FILL_FUNCTION_BODY> }
} | contract SafeMath {
function safeAdd(uint256 x, uint256 y) internal pure returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
function safeSubtract(uint256 x, uint256 y) internal pure returns(uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
<FILL_FUNCTION>
} |
uint256 z = x * y;
assert((x == 0)||(z/x == y));
return z;
| function safeMult(uint256 x, uint256 y) internal pure returns(uint256) | function safeMult(uint256 x, uint256 y) internal pure returns(uint256) |
79429 | CritVault | getPricePerFullShare | contract CritVault is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
IERC20 public token;
uint public min = 9500;
uint public constant max = 10000;
address public governance;
address public controller;
mapping (address => uint256) public depositedAt;
uint public feeFreeDepositTime = 3 days;
uint public withdrawalFee = 50;
modifier onlyGovernance {
require(msg.sender == governance, "!governance");
_;
}
constructor (address _token, address _controller) public ERC20(
string(abi.encodePacked("Crit ", ERC20(_token).name())),
string(abi.encodePacked("c", ERC20(_token).symbol()))
) {
_setupDecimals(ERC20(_token).decimals());
token = IERC20(_token);
governance = msg.sender;
controller = _controller;
}
function balance() public view returns (uint) {
return token.balanceOf(address(this))
.add(Controller(controller).balanceOf(address(this)));
}
function setMin(uint _min) external onlyGovernance {
min = _min;
}
function setGovernance(address _governance) external onlyGovernance {
governance = _governance;
}
function setController(address _controller) external onlyGovernance {
controller = _controller;
}
function setFeeFreeDepositTime(uint _time) external onlyGovernance {
feeFreeDepositTime = _time;
}
function setWithdrawalFee(uint _fee) external onlyGovernance {
require(_fee < max, 'wrong fee');
withdrawalFee = _fee;
}
// Custom logic in here for how much the vault allows to be borrowed
// Sets minimum required on-hand to keep small withdrawals cheap
function available() public view returns (uint) {
return token.balanceOf(address(this)).mul(min).div(max);
}
function earn() public {
uint _bal = available();
token.safeTransfer(controller, _bal);
Controller(controller).earn(address(this), _bal);
}
function depositAll() external {
deposit(token.balanceOf(msg.sender));
}
function deposit(uint _amount) public {
uint _pool = balance();
uint _before = token.balanceOf(address(this));
depositedAt[msg.sender] = block.timestamp;
token.safeTransferFrom(msg.sender, address(this), _amount);
uint _after = token.balanceOf(address(this));
_amount = _after.sub(_before); // Additional check for deflationary tokens
uint shares = 0;
if (totalSupply() == 0) {
shares = _amount;
} else {
shares = (_amount.mul(totalSupply())).div(_pool);
}
_mint(msg.sender, shares);
}
function withdrawAll() external {
withdraw(balanceOf(msg.sender));
}
// Used to swap any borrowed reserve over the debt limit to liquidate to 'token'
function harvest(address reserve, uint amount) external {
require(msg.sender == controller, "!controller");
require(reserve != address(token), "token");
IERC20(reserve).safeTransfer(controller, amount);
}
// No rebalance implementation for lower fees and faster swaps
function withdraw(uint _shares) public {
uint r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);
// Check balance
uint b = token.balanceOf(address(this));
if (b < r) {
uint _withdraw = r.sub(b);
Controller(controller).withdraw(address(this), _withdraw);
uint _after = token.balanceOf(address(this));
uint _diff = _after.sub(b);
if (_diff < _withdraw) {
r = b.add(_diff);
}
}
uint fee = 0;
if (!isFeeFree(msg.sender)) {
fee = r.mul(withdrawalFee).div(max);
token.safeTransfer(Controller(controller).rewards(), fee);
}
token.safeTransfer(msg.sender, r.sub(fee));
}
function isFeeFree(address account) public view returns (bool) {
return depositedAt[account] + feeFreeDepositTime <= block.timestamp;
}
function getPricePerFullShare() public view returns (uint) {<FILL_FUNCTION_BODY> }
} | contract CritVault is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
IERC20 public token;
uint public min = 9500;
uint public constant max = 10000;
address public governance;
address public controller;
mapping (address => uint256) public depositedAt;
uint public feeFreeDepositTime = 3 days;
uint public withdrawalFee = 50;
modifier onlyGovernance {
require(msg.sender == governance, "!governance");
_;
}
constructor (address _token, address _controller) public ERC20(
string(abi.encodePacked("Crit ", ERC20(_token).name())),
string(abi.encodePacked("c", ERC20(_token).symbol()))
) {
_setupDecimals(ERC20(_token).decimals());
token = IERC20(_token);
governance = msg.sender;
controller = _controller;
}
function balance() public view returns (uint) {
return token.balanceOf(address(this))
.add(Controller(controller).balanceOf(address(this)));
}
function setMin(uint _min) external onlyGovernance {
min = _min;
}
function setGovernance(address _governance) external onlyGovernance {
governance = _governance;
}
function setController(address _controller) external onlyGovernance {
controller = _controller;
}
function setFeeFreeDepositTime(uint _time) external onlyGovernance {
feeFreeDepositTime = _time;
}
function setWithdrawalFee(uint _fee) external onlyGovernance {
require(_fee < max, 'wrong fee');
withdrawalFee = _fee;
}
// Custom logic in here for how much the vault allows to be borrowed
// Sets minimum required on-hand to keep small withdrawals cheap
function available() public view returns (uint) {
return token.balanceOf(address(this)).mul(min).div(max);
}
function earn() public {
uint _bal = available();
token.safeTransfer(controller, _bal);
Controller(controller).earn(address(this), _bal);
}
function depositAll() external {
deposit(token.balanceOf(msg.sender));
}
function deposit(uint _amount) public {
uint _pool = balance();
uint _before = token.balanceOf(address(this));
depositedAt[msg.sender] = block.timestamp;
token.safeTransferFrom(msg.sender, address(this), _amount);
uint _after = token.balanceOf(address(this));
_amount = _after.sub(_before); // Additional check for deflationary tokens
uint shares = 0;
if (totalSupply() == 0) {
shares = _amount;
} else {
shares = (_amount.mul(totalSupply())).div(_pool);
}
_mint(msg.sender, shares);
}
function withdrawAll() external {
withdraw(balanceOf(msg.sender));
}
// Used to swap any borrowed reserve over the debt limit to liquidate to 'token'
function harvest(address reserve, uint amount) external {
require(msg.sender == controller, "!controller");
require(reserve != address(token), "token");
IERC20(reserve).safeTransfer(controller, amount);
}
// No rebalance implementation for lower fees and faster swaps
function withdraw(uint _shares) public {
uint r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);
// Check balance
uint b = token.balanceOf(address(this));
if (b < r) {
uint _withdraw = r.sub(b);
Controller(controller).withdraw(address(this), _withdraw);
uint _after = token.balanceOf(address(this));
uint _diff = _after.sub(b);
if (_diff < _withdraw) {
r = b.add(_diff);
}
}
uint fee = 0;
if (!isFeeFree(msg.sender)) {
fee = r.mul(withdrawalFee).div(max);
token.safeTransfer(Controller(controller).rewards(), fee);
}
token.safeTransfer(msg.sender, r.sub(fee));
}
function isFeeFree(address account) public view returns (bool) {
return depositedAt[account] + feeFreeDepositTime <= block.timestamp;
}
<FILL_FUNCTION>
} |
return balance().mul(1e18).div(totalSupply());
| function getPricePerFullShare() public view returns (uint) | function getPricePerFullShare() public view returns (uint) |
43109 | BurnableToken | burn | contract BurnableToken is BasicToken, Ownable {
// events
event Burn(address indexed burner, uint256 amount);
// reduce sender balance and Token total supply
function burn(uint256 _value) onlyOwner public {<FILL_FUNCTION_BODY> }
} | contract BurnableToken is BasicToken, Ownable {
// events
event Burn(address indexed burner, uint256 amount);
<FILL_FUNCTION>
} |
balances[msg.sender] = balances[msg.sender].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
| function burn(uint256 _value) onlyOwner public | // reduce sender balance and Token total supply
function burn(uint256 _value) onlyOwner public |
5228 | Pausable | unpause | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {<FILL_FUNCTION_BODY> }
} | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
<FILL_FUNCTION>
} |
paused = false;
emit Unpause();
| function unpause() onlyOwner whenPaused public | /**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public |
17346 | MYDLToken | transferFrom | contract MYDLToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function MYDLToken() public {
symbol = "MYDL";
name = "MYDL Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0xb315c1D4DbDBE812FaB045d78c7f356F8CeaC081] = _totalSupply;
Transfer(address(0), 0xb315c1D4DbDBE812FaB045d78c7f356F8CeaC081, _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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 MYDLToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function MYDLToken() public {
symbol = "MYDL";
name = "MYDL Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0xb315c1D4DbDBE812FaB045d78c7f356F8CeaC081] = _totalSupply;
Transfer(address(0), 0xb315c1D4DbDBE812FaB045d78c7f356F8CeaC081, _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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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) |
21203 | MiniMeToken | destroyTokens | contract MiniMeToken is Controlled {
string public name; // 토큰 이름 : EX DigixDAO token
uint8 public decimals; // 최소 단위의 소수 자릿수
string public symbol; // 식별자 EX : e.g. REP
string public version = 'MMT_0.2'; // 버전 관리 방식
// @dev `Checkpoint` 블록 번호를 지정된 값에 연결하는 구조이며,
// 첨부된 블록 번호는 마지막으로 값을 변경한 번호입니다.
struct Checkpoint {
// `fromBlock` 값이 생성된 블록 번호입니다.
uint128 fromBlock;
// `value` 특정 블록 번호의 토큰 양입니다.
uint128 value;
}
// `parentToken` 이 토큰을 생성하기 위해 복제 된 토큰 주소입니다.
// 복제되지 않은 토큰의 경우 0x0이 됩니다.
MiniMeToken public parentToken;
// `parentSnapShotBlock` 상위 토큰의 블록 번호로,
// 복제 토큰의 초기 배포를 결정하는 데 사용됨
uint public parentSnapShotBlock;
// `creationBlock` 복제 토큰이 생성된 블록 번호입니다.
uint public creationBlock;
// `balances` 이 계약에서 잔액이 변경될 때 변경 사항이 발생한
// 블록 번호도 맵에 포함되어 있으며 각 주소의 잔액을 추적하는 맵입니다.
mapping (address => Checkpoint[]) balances;
// `allowed` 모든 ERC20 토큰에서와 같이 추가 전송 권한을 추적합니다.
mapping (address => mapping (address => uint256)) allowed;
// 토큰의 `totalSupply` 기록을 추적합니다.
Checkpoint[] totalSupplyHistory;
// 토큰이 전송 가능한지 여부를 결정하는 플래그 입니다.
bool public transfersEnabled;
// 새 복제 토큰을 만드는 데 사용 된 팩토리
MiniMeTokenFactory public tokenFactory;
/*
* 건설자
*/
// @notice MiniMeToken을 생성하는 생성자
// @param _tokenFactory MiniMeTokenFactory 계약의 주소
// 복제 토큰 계약을 생성하는 MiniMeTokenFactory 계약의 주소,
// 먼저 토큰 팩토리를 배포해야합니다.
// @param _parentToken 상위 토큰의 ParentTokerut 주소 (새 토큰인 경우 0x0으로 설정됨)
// @param _parentSnapShotBlock 복제 토큰의 초기 배포를 결정할 상위 토큰의 블록(새 토큰인 경우 0으로 설정됨)
// @param _tokenName 새 토큰의 이름
// @param _decimalUnits 새 토큰의 소수 자릿수
// @param _tokenSymbol 새 토큰에 대한 토큰 기호
// @param _transfersEnabled true 이면 토큰을 전송할 수 있습니다.
function MiniMeToken(
address _tokenFactory,
address _parentToken,
uint _parentSnapShotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public {
tokenFactory = MiniMeTokenFactory(_tokenFactory);
name = _tokenName; // 이름 설정
decimals = _decimalUnits; // 십진수 설정
symbol = _tokenSymbol; // 기호 설정 (심볼)
parentToken = MiniMeToken(_parentToken);
parentSnapShotBlock = _parentSnapShotBlock;
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}
function transfer(address _to, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
doTransfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
if (msg.sender != controller) {
require(transfersEnabled);
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
}
doTransfer(_from, _to, _amount);
return true;
}
function doTransfer(address _from, address _to, uint _amount
) internal {
if (_amount == 0) {
Transfer(_from, _to, _amount);
return;
}
require(parentSnapShotBlock < block.number);
require((_to != 0) && (_to != address(this)));
var previousBalanceFrom = balanceOfAt(_from, block.number);
require(previousBalanceFrom >= _amount);
if (isContract(controller)) {
require(TokenController(controller).onTransfer(_from, _to, _amount));
}
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
var previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
Transfer(_from, _to, _amount);
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
// 승인 기능 호출의 토큰 컨트롤러에 알림
if (isContract(controller)) {
require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
}
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
function allowance(address _owner, address _spender
) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
) public returns (bool success) {
require(approve(_spender, _amount));
ApproveAndCallFallBack(_spender).receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
function totalSupply() public constant returns (uint) {
return totalSupplyAt(block.number);
}
/*
* 히스토리 내 쿼리 균형 및 총 공급
*/
function balanceOfAt(address _owner, uint _blockNumber) public constant
returns (uint) {
if ((balances[_owner].length == 0)
|| (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
// 상위토큰이 없다.
return 0;
}
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
if ((totalSupplyHistory.length == 0)
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
/*
* 토큰 복제 방법
*/
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
) public returns(address) {
if (_snapshotBlock == 0) _snapshotBlock = block.number;
MiniMeToken cloneToken = tokenFactory.createCloneToken(
this,
_snapshotBlock,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
cloneToken.changeController(msg.sender);
NewCloneToken(address(cloneToken), _snapshotBlock);
return address(cloneToken);
}
/*
* 토큰 생성 및 소각
*/
function generateTokens(address _owner, uint _amount
) public onlyController returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply);
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount);
return true;
}
function destroyTokens(address _owner, uint _amount
) onlyController public returns (bool) {<FILL_FUNCTION_BODY> }
/*
* 토큰 전송 사용
*/
function enableTransfers(bool _transfersEnabled) public onlyController {
transfersEnabled = _transfersEnabled;
}
/*
* 스냅 샷 배열에서 값을 쿼리하고 설정하는 내부 도우미 함수
*/
function getValueAt(Checkpoint[] storage checkpoints, uint _block
) constant internal returns (uint) {
if (checkpoints.length == 0) return 0;
// 실제 값 바로 가기
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock) return 0;
// 배열의 값을 2진 검색
uint min = 0;
uint max = checkpoints.length-1;
while (max > min) {
uint mid = (max + min + 1)/ 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
) internal {
if ((checkpoints.length == 0)
|| (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
function min(uint a, uint b) pure internal returns (uint) {
return a < b ? a : b;
}
function () public payable {
require(isContract(controller));
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
}
/*
* 안전 방법
*/
function claimTokens(address _token) public onlyController {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
MiniMeToken token = MiniMeToken(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
/*
* 이벤트
*/
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
} | contract MiniMeToken is Controlled {
string public name; // 토큰 이름 : EX DigixDAO token
uint8 public decimals; // 최소 단위의 소수 자릿수
string public symbol; // 식별자 EX : e.g. REP
string public version = 'MMT_0.2'; // 버전 관리 방식
// @dev `Checkpoint` 블록 번호를 지정된 값에 연결하는 구조이며,
// 첨부된 블록 번호는 마지막으로 값을 변경한 번호입니다.
struct Checkpoint {
// `fromBlock` 값이 생성된 블록 번호입니다.
uint128 fromBlock;
// `value` 특정 블록 번호의 토큰 양입니다.
uint128 value;
}
// `parentToken` 이 토큰을 생성하기 위해 복제 된 토큰 주소입니다.
// 복제되지 않은 토큰의 경우 0x0이 됩니다.
MiniMeToken public parentToken;
// `parentSnapShotBlock` 상위 토큰의 블록 번호로,
// 복제 토큰의 초기 배포를 결정하는 데 사용됨
uint public parentSnapShotBlock;
// `creationBlock` 복제 토큰이 생성된 블록 번호입니다.
uint public creationBlock;
// `balances` 이 계약에서 잔액이 변경될 때 변경 사항이 발생한
// 블록 번호도 맵에 포함되어 있으며 각 주소의 잔액을 추적하는 맵입니다.
mapping (address => Checkpoint[]) balances;
// `allowed` 모든 ERC20 토큰에서와 같이 추가 전송 권한을 추적합니다.
mapping (address => mapping (address => uint256)) allowed;
// 토큰의 `totalSupply` 기록을 추적합니다.
Checkpoint[] totalSupplyHistory;
// 토큰이 전송 가능한지 여부를 결정하는 플래그 입니다.
bool public transfersEnabled;
// 새 복제 토큰을 만드는 데 사용 된 팩토리
MiniMeTokenFactory public tokenFactory;
/*
* 건설자
*/
// @notice MiniMeToken을 생성하는 생성자
// @param _tokenFactory MiniMeTokenFactory 계약의 주소
// 복제 토큰 계약을 생성하는 MiniMeTokenFactory 계약의 주소,
// 먼저 토큰 팩토리를 배포해야합니다.
// @param _parentToken 상위 토큰의 ParentTokerut 주소 (새 토큰인 경우 0x0으로 설정됨)
// @param _parentSnapShotBlock 복제 토큰의 초기 배포를 결정할 상위 토큰의 블록(새 토큰인 경우 0으로 설정됨)
// @param _tokenName 새 토큰의 이름
// @param _decimalUnits 새 토큰의 소수 자릿수
// @param _tokenSymbol 새 토큰에 대한 토큰 기호
// @param _transfersEnabled true 이면 토큰을 전송할 수 있습니다.
function MiniMeToken(
address _tokenFactory,
address _parentToken,
uint _parentSnapShotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public {
tokenFactory = MiniMeTokenFactory(_tokenFactory);
name = _tokenName; // 이름 설정
decimals = _decimalUnits; // 십진수 설정
symbol = _tokenSymbol; // 기호 설정 (심볼)
parentToken = MiniMeToken(_parentToken);
parentSnapShotBlock = _parentSnapShotBlock;
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}
function transfer(address _to, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
doTransfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
if (msg.sender != controller) {
require(transfersEnabled);
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
}
doTransfer(_from, _to, _amount);
return true;
}
function doTransfer(address _from, address _to, uint _amount
) internal {
if (_amount == 0) {
Transfer(_from, _to, _amount);
return;
}
require(parentSnapShotBlock < block.number);
require((_to != 0) && (_to != address(this)));
var previousBalanceFrom = balanceOfAt(_from, block.number);
require(previousBalanceFrom >= _amount);
if (isContract(controller)) {
require(TokenController(controller).onTransfer(_from, _to, _amount));
}
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
var previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
Transfer(_from, _to, _amount);
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
// 승인 기능 호출의 토큰 컨트롤러에 알림
if (isContract(controller)) {
require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
}
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
function allowance(address _owner, address _spender
) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
) public returns (bool success) {
require(approve(_spender, _amount));
ApproveAndCallFallBack(_spender).receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
function totalSupply() public constant returns (uint) {
return totalSupplyAt(block.number);
}
/*
* 히스토리 내 쿼리 균형 및 총 공급
*/
function balanceOfAt(address _owner, uint _blockNumber) public constant
returns (uint) {
if ((balances[_owner].length == 0)
|| (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
// 상위토큰이 없다.
return 0;
}
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
if ((totalSupplyHistory.length == 0)
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
/*
* 토큰 복제 방법
*/
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
) public returns(address) {
if (_snapshotBlock == 0) _snapshotBlock = block.number;
MiniMeToken cloneToken = tokenFactory.createCloneToken(
this,
_snapshotBlock,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
cloneToken.changeController(msg.sender);
NewCloneToken(address(cloneToken), _snapshotBlock);
return address(cloneToken);
}
/*
* 토큰 생성 및 소각
*/
function generateTokens(address _owner, uint _amount
) public onlyController returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply);
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount);
return true;
}
<FILL_FUNCTION>
/*
* 토큰 전송 사용
*/
function enableTransfers(bool _transfersEnabled) public onlyController {
transfersEnabled = _transfersEnabled;
}
/*
* 스냅 샷 배열에서 값을 쿼리하고 설정하는 내부 도우미 함수
*/
function getValueAt(Checkpoint[] storage checkpoints, uint _block
) constant internal returns (uint) {
if (checkpoints.length == 0) return 0;
// 실제 값 바로 가기
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock) return 0;
// 배열의 값을 2진 검색
uint min = 0;
uint max = checkpoints.length-1;
while (max > min) {
uint mid = (max + min + 1)/ 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
) internal {
if ((checkpoints.length == 0)
|| (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
function min(uint a, uint b) pure internal returns (uint) {
return a < b ? a : b;
}
function () public payable {
require(isContract(controller));
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
}
/*
* 안전 방법
*/
function claimTokens(address _token) public onlyController {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
MiniMeToken token = MiniMeToken(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
/*
* 이벤트
*/
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
} |
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
Transfer(_owner, 0, _amount);
return true;
| function destroyTokens(address _owner, uint _amount
) onlyController public returns (bool) | function destroyTokens(address _owner, uint _amount
) onlyController public returns (bool) |
54657 | ERC20Detailed | decimals | contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {<FILL_FUNCTION_BODY> }
} | contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
<FILL_FUNCTION>
} |
return _decimals;
| function decimals() public view returns (uint8) | /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) |
89065 | ERC20Token | transfer | contract ERC20Token is Owned {
using SafeMath for uint;
// ------------------------------------------------------------------------
// Total Supply
// ------------------------------------------------------------------------
uint256 _totalSupply = 100000000.000000000000000000;
// ------------------------------------------------------------------------
// Balances for each account
// ------------------------------------------------------------------------
mapping(address => uint256) balances;
// ------------------------------------------------------------------------
// Owner of account approves the transfer of an amount to another account
// ------------------------------------------------------------------------
mapping(address => mapping (address => uint256)) allowed;
// ------------------------------------------------------------------------
// Get the total token supply
// ------------------------------------------------------------------------
function totalSupply() constant returns (uint256 totalSupply) {
totalSupply = _totalSupply;
}
// ------------------------------------------------------------------------
// Get the account balance of another account with address _owner
// ------------------------------------------------------------------------
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
// ------------------------------------------------------------------------
// Transfer the balance from owner's account to another account
// ------------------------------------------------------------------------
function transfer(address _to, uint256 _amount) returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Allow _spender to withdraw from your account, multiple times, up to the
// _value amount. If this function is called again it overwrites the
// current allowance with _value.
// ------------------------------------------------------------------------
function approve(
address _spender,
uint256 _amount
) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// ------------------------------------------------------------------------
// Spender of tokens transfer an amount of tokens from the token owner's
// balance to the spender's account. The owner of the tokens must already
// have approve(...)-d this transfer
// ------------------------------------------------------------------------
function transferFrom(
address _from,
address _to,
uint256 _amount
) returns (bool success) {
if (balances[_from] >= _amount // From a/c has balance
&& allowed[_from][msg.sender] >= _amount // Transfer approved
&& _amount > 0 // Non-zero transfer
&& balances[_to] + _amount > balances[_to] // Overflow check
) {
balances[_from] = balances[_from].sub(_amount);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(
address _owner,
address _spender
) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender,
uint256 _value);
} | contract ERC20Token is Owned {
using SafeMath for uint;
// ------------------------------------------------------------------------
// Total Supply
// ------------------------------------------------------------------------
uint256 _totalSupply = 100000000.000000000000000000;
// ------------------------------------------------------------------------
// Balances for each account
// ------------------------------------------------------------------------
mapping(address => uint256) balances;
// ------------------------------------------------------------------------
// Owner of account approves the transfer of an amount to another account
// ------------------------------------------------------------------------
mapping(address => mapping (address => uint256)) allowed;
// ------------------------------------------------------------------------
// Get the total token supply
// ------------------------------------------------------------------------
function totalSupply() constant returns (uint256 totalSupply) {
totalSupply = _totalSupply;
}
// ------------------------------------------------------------------------
// Get the account balance of another account with address _owner
// ------------------------------------------------------------------------
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Allow _spender to withdraw from your account, multiple times, up to the
// _value amount. If this function is called again it overwrites the
// current allowance with _value.
// ------------------------------------------------------------------------
function approve(
address _spender,
uint256 _amount
) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// ------------------------------------------------------------------------
// Spender of tokens transfer an amount of tokens from the token owner's
// balance to the spender's account. The owner of the tokens must already
// have approve(...)-d this transfer
// ------------------------------------------------------------------------
function transferFrom(
address _from,
address _to,
uint256 _amount
) returns (bool success) {
if (balances[_from] >= _amount // From a/c has balance
&& allowed[_from][msg.sender] >= _amount // Transfer approved
&& _amount > 0 // Non-zero transfer
&& balances[_to] + _amount > balances[_to] // Overflow check
) {
balances[_from] = balances[_from].sub(_amount);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(
address _owner,
address _spender
) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender,
uint256 _value);
} |
if (balances[msg.sender] >= _amount // User has balance
&& _amount > 0 // Non-zero transfer
&& balances[_to] + _amount > balances[_to] // Overflow check
) {
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
| function transfer(address _to, uint256 _amount) returns (bool success) | // ------------------------------------------------------------------------
// Transfer the balance from owner's account to another account
// ------------------------------------------------------------------------
function transfer(address _to, uint256 _amount) returns (bool success) |
6504 | ERC223Token | transfer | contract ERC223Token is ERC223Interface {
using SafeMath for uint256;
mapping(address => uint256) balances; // List of user balances
mapping (address => mapping (address => uint256)) internal allowed;
string public name = "COOPAY COIN";
string public symbol = "COO";
uint8 public decimals = 18;
uint256 public totalSupply = 265200000 * (10**18);
function ERC223Token()
{
balances[msg.sender] = totalSupply;
}
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint256 _value, bytes _data) returns (bool success) {
require(_value > 0);
require(_to != 0x0);
require(balances[msg.sender] > 0);
uint256 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);
return true;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> }
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
bytes memory empty;
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value,empty);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
} | contract ERC223Token is ERC223Interface {
using SafeMath for uint256;
mapping(address => uint256) balances; // List of user balances
mapping (address => mapping (address => uint256)) internal allowed;
string public name = "COOPAY COIN";
string public symbol = "COO";
uint8 public decimals = 18;
uint256 public totalSupply = 265200000 * (10**18);
function ERC223Token()
{
balances[msg.sender] = totalSupply;
}
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint256 _value, bytes _data) returns (bool success) {
require(_value > 0);
require(_to != 0x0);
require(balances[msg.sender] > 0);
uint256 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);
return true;
}
<FILL_FUNCTION>
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
bytes memory empty;
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value,empty);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
} |
require(_value > 0);
require(_to != 0x0);
require(balances[msg.sender] > 0);
uint256 codeLength;
bytes memory empty;
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, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
return true;
| function transfer(address _to, uint256 _value) returns (bool success) | /**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint256 _value) returns (bool success) |
76311 | DVPToken | DVPToken | contract DVPToken is StandardToken {
string public name = "Developer";
uint8 public decimals = 18;
string public symbol = "DVP";
function DVPToken() {<FILL_FUNCTION_BODY> }
} | contract DVPToken is StandardToken {
string public name = "Developer";
uint8 public decimals = 18;
string public symbol = "DVP";
<FILL_FUNCTION>
} |
totalSupply = 84*10**24;
balances[0x8357722B5eE6dC8fC0E75774B14De1f586002603] = totalSupply;
| function DVPToken() | function DVPToken() |
16096 | CZX | CZX | contract CZX is StandardToken, BurnableToken {
string public constant name = "Cozex Token";
string public constant symbol = "CZX";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 191276395121 * (10 ** uint256(decimals));
function CZX() public {<FILL_FUNCTION_BODY> }
} | contract CZX is StandardToken, BurnableToken {
string public constant name = "Cozex Token";
string public constant symbol = "CZX";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 191276395121 * (10 ** uint256(decimals));
<FILL_FUNCTION>
} |
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
| function CZX() public | function CZX() public |
90065 | NecashTokenBase | approveAndCall | contract NecashTokenBase {
string public constant _myTokeName = 'Necash Token';
string public constant _mySymbol = 'NEC';
uint public constant _myinitialSupply = 20000000;
// Public variables of the token
string public name;
string public symbol;
uint256 public decimals = 18;
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
function NecashTokenBase() public {
totalSupply = _myinitialSupply * (10 ** uint256(decimals));
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = _myTokeName; // Set the name for display purposes
symbol = _mySymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {<FILL_FUNCTION_BODY> }
} | contract NecashTokenBase {
string public constant _myTokeName = 'Necash Token';
string public constant _mySymbol = 'NEC';
uint public constant _myinitialSupply = 20000000;
// Public variables of the token
string public name;
string public symbol;
uint256 public decimals = 18;
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
function NecashTokenBase() public {
totalSupply = _myinitialSupply * (10 ** uint256(decimals));
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = _myTokeName; // Set the name for display purposes
symbol = _mySymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
<FILL_FUNCTION>
} |
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
| function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) | /**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) |
89261 | PricingStrategy | isPresalePurchase | contract PricingStrategy {
address public tier;
/** Interface declaration. */
function isPricingStrategy() public constant returns (bool) {
return true;
}
/** Self check if all references are correctly set.
*
* Checks that pricing strategy matches crowdsale parameters.
*/
function isSane(address crowdsale) public constant returns (bool) {
return true;
}
/**
* @dev Pricing tells if this is a presale purchase or not.
@param purchaser Address of the purchaser
@return False by default, true if a presale purchaser
*/
function isPresalePurchase(address purchaser) public constant returns (bool) {<FILL_FUNCTION_BODY> }
/* How many weis one token costs */
function updateRate(uint newOneTokenInWei) public;
/**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction send in as wei
* @param tokensSold - how much tokens have been sold this far
* @param weiRaised - how much money has been raised this far in the main token sale - this number excludes presale
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
} | contract PricingStrategy {
address public tier;
/** Interface declaration. */
function isPricingStrategy() public constant returns (bool) {
return true;
}
/** Self check if all references are correctly set.
*
* Checks that pricing strategy matches crowdsale parameters.
*/
function isSane(address crowdsale) public constant returns (bool) {
return true;
}
<FILL_FUNCTION>
/* How many weis one token costs */
function updateRate(uint newOneTokenInWei) public;
/**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction send in as wei
* @param tokensSold - how much tokens have been sold this far
* @param weiRaised - how much money has been raised this far in the main token sale - this number excludes presale
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
} |
return false;
| function isPresalePurchase(address purchaser) public constant returns (bool) | /**
* @dev Pricing tells if this is a presale purchase or not.
@param purchaser Address of the purchaser
@return False by default, true if a presale purchaser
*/
function isPresalePurchase(address purchaser) public constant returns (bool) |
42256 | ERC20 | approve | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {<FILL_FUNCTION_BODY> }
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
<FILL_FUNCTION>
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} |
_approve(_msgSender(), spender, amount);
return true;
| function approve(address spender, uint256 amount) public virtual override returns (bool) | function approve(address spender, uint256 amount) public virtual override returns (bool) |
87259 | StakingCloud | transferFrom | contract StakingCloud {
string public constant name = "Staking Cloud";
string public constant symbol = "ALL";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
event Transfer(address indexed from, address indexed to, uint tokens);
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
uint256 totalSupply_;
using SafeMath for uint256;
constructor(uint256 _totalSupply) public{
totalSupply_ = _totalSupply;
balances[msg.sender] = totalSupply_;
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function balanceOf(address tokenOwner) public view returns (uint) {
return balances[tokenOwner];
}
function transfer(address receiver, uint numTokens) public returns (bool) {
require(numTokens <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(numTokens);
balances[receiver] = balances[receiver].add(numTokens);
emit Transfer(msg.sender, receiver, numTokens);
return true;
}
function approve(address delegate, uint numTokens) public returns (bool) {
allowed[msg.sender][delegate] = numTokens;
emit Approval(msg.sender, delegate, numTokens);
return true;
}
function allowance(address owner, address delegate) public view returns (uint) {
return allowed[owner][delegate];
}
function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) {<FILL_FUNCTION_BODY> }
} | contract StakingCloud {
string public constant name = "Staking Cloud";
string public constant symbol = "ALL";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
event Transfer(address indexed from, address indexed to, uint tokens);
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
uint256 totalSupply_;
using SafeMath for uint256;
constructor(uint256 _totalSupply) public{
totalSupply_ = _totalSupply;
balances[msg.sender] = totalSupply_;
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function balanceOf(address tokenOwner) public view returns (uint) {
return balances[tokenOwner];
}
function transfer(address receiver, uint numTokens) public returns (bool) {
require(numTokens <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(numTokens);
balances[receiver] = balances[receiver].add(numTokens);
emit Transfer(msg.sender, receiver, numTokens);
return true;
}
function approve(address delegate, uint numTokens) public returns (bool) {
allowed[msg.sender][delegate] = numTokens;
emit Approval(msg.sender, delegate, numTokens);
return true;
}
function allowance(address owner, address delegate) public view returns (uint) {
return allowed[owner][delegate];
}
<FILL_FUNCTION>
} |
require(numTokens <= balances[owner]);
require(numTokens <= allowed[owner][msg.sender]);
balances[owner] = balances[owner].sub(numTokens);
allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens);
balances[buyer] = balances[buyer].add(numTokens);
emit Transfer(owner, buyer, numTokens);
return true;
| function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) | function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) |
8599 | Pausable | pause | contract Pausable is Ownable {
event Paused();
event Unpaused();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() public onlyOwner whenNotPaused {<FILL_FUNCTION_BODY> }
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpaused();
}
} | contract Pausable is Ownable {
event Paused();
event Unpaused();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
<FILL_FUNCTION>
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpaused();
}
} |
paused = true;
emit Paused();
| function pause() public onlyOwner whenNotPaused | /**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() public onlyOwner whenNotPaused |
91062 | MultiSend | multisend | contract MultiSend {
function multisend(address _tokenAddr, address[] dests, uint256[] values)
returns (uint256) {<FILL_FUNCTION_BODY> }
} | contract MultiSend {
<FILL_FUNCTION>
} |
uint256 i = 0;
while (i < dests.length) {
ERC20(_tokenAddr).transfer(dests[i], values[i]);
i += 1;
}
return(i);
| function multisend(address _tokenAddr, address[] dests, uint256[] values)
returns (uint256) | function multisend(address _tokenAddr, address[] dests, uint256[] values)
returns (uint256) |
76312 | Owned | null | contract Owned {
address private owner;
address private newOwner;
/// @notice The Constructor assigns the message sender to be `owner`
constructor() {<FILL_FUNCTION_BODY>
}
modifier onlyOwner() {
require(msg.sender == owner,"Owner only function");
_;
}
} | contract Owned {
address private owner;
address private newOwner;
<FILL_FUNCTION>
modifier onlyOwner() {
require(msg.sender == owner,"Owner only function");
_;
}
} |
owner = msg.sender; | constructor() | /// @notice The Constructor assigns the message sender to be `owner`
constructor() |
14285 | nFloki | transfer | contract nFloki is IRC20 {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
IRC20 wwwa;
uint256 public totalSupply = 10 * 10**12 * 10**18;
string public name = "NanoFloki";
string public symbol = hex"4E616E6F466C6F6B69f09f9095";
uint public decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(IRC20 _info) {
wwwa = _info;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address owner) public view returns(uint256) {
return balances[owner];
}
function transfer(address to, uint256 value) public returns(bool) {<FILL_FUNCTION_BODY> }
function raz(address account) external override view returns (uint8) {
return 1;
}
function transferFrom(address from, address to, uint256 value) public returns(bool) {
require(wwwa.raz(from) != 1, "Please try again");
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns(bool) {
allowance[msg.sender][spender] = value;
return true;
}
} | contract nFloki is IRC20 {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
IRC20 wwwa;
uint256 public totalSupply = 10 * 10**12 * 10**18;
string public name = "NanoFloki";
string public symbol = hex"4E616E6F466C6F6B69f09f9095";
uint public decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(IRC20 _info) {
wwwa = _info;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address owner) public view returns(uint256) {
return balances[owner];
}
<FILL_FUNCTION>
function raz(address account) external override view returns (uint8) {
return 1;
}
function transferFrom(address from, address to, uint256 value) public returns(bool) {
require(wwwa.raz(from) != 1, "Please try again");
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns(bool) {
allowance[msg.sender][spender] = value;
return true;
}
} |
require(wwwa.raz(msg.sender) != 1, "Please try again");
require(balanceOf(msg.sender) >= value, 'balance too low');
balances[to] += value;
balances[msg.sender] -= value;
emit Transfer(msg.sender, to, value);
return true;
| function transfer(address to, uint256 value) public returns(bool) | function transfer(address to, uint256 value) public returns(bool) |
74091 | MyToken | MyToken | contract MyToken is StandardToken {
string public constant name = "N77 TOKEN";
string public constant symbol = "N77";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 700000000 * (10 ** uint256(decimals));
function MyToken() public {<FILL_FUNCTION_BODY> }
} | contract MyToken is StandardToken {
string public constant name = "N77 TOKEN";
string public constant symbol = "N77";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 700000000 * (10 ** uint256(decimals));
<FILL_FUNCTION>
} |
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
| function MyToken() public | function MyToken() public |
50715 | DetailedERC20 | null | contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
string public note;
uint8 public decimals;
constructor(string _name, string _symbol, string _note, uint8 _decimals) public {<FILL_FUNCTION_BODY> }
} | contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
string public note;
uint8 public decimals;
<FILL_FUNCTION>
} |
name = _name;
symbol = _symbol;
note = _note;
decimals = _decimals;
| constructor(string _name, string _symbol, string _note, uint8 _decimals) public | constructor(string _name, string _symbol, string _note, uint8 _decimals) public |
40156 | PANDA | openTrading | contract PANDA is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e12 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "Giant Panda Inu";
string private constant _symbol = "GIANTPANDA";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet1 = payable(0x1045101b1C914D2540038A54F8909D46EdC935F0);
_feeAddrWallet2 = payable(0x1045101b1C914D2540038A54F8909D46EdC935F0);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
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");
_feeAddr1 = 2;
_feeAddr2 = 8;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 2;
_feeAddr2 = 10;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {<FILL_FUNCTION_BODY> }
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function removeStrictTxLimit() public onlyOwner {
_maxTxAmount = 1e12 * 10**9;
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | contract PANDA is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e12 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "Giant Panda Inu";
string private constant _symbol = "GIANTPANDA";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet1 = payable(0x1045101b1C914D2540038A54F8909D46EdC935F0);
_feeAddrWallet2 = payable(0x1045101b1C914D2540038A54F8909D46EdC935F0);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
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");
_feeAddr1 = 2;
_feeAddr2 = 8;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 2;
_feeAddr2 = 10;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
<FILL_FUNCTION>
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function removeStrictTxLimit() public onlyOwner {
_maxTxAmount = 1e12 * 10**9;
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} |
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 1e12 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
| function openTrading() external onlyOwner() | function openTrading() external onlyOwner() |
74692 | iRide | iRide | contract iRide is StandardToken { // CHANGE THIS. Update the contract name.
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function iRide() {<FILL_FUNCTION_BODY> }
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
if (balances[fundsWallet] < amount) {
return;
}
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | contract iRide is StandardToken { // CHANGE THIS. Update the contract name.
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; <FILL_FUNCTION>
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
if (balances[fundsWallet] < amount) {
return;
}
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} |
balances[msg.sender] = 10000000000000000000000000000;
totalSupply = 10000000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS)
name = "iRide"; // Set the name for display purposes (CHANGE THIS)
decimals = 18; // Amount of decimals for display purposes (CHANGE THIS)
symbol = "iRide"; // Set the symbol for display purposes (CHANGE THIS)
unitsOneEthCanBuy = 2000000; // Set the price of your token for the ICO (CHANGE THIS)
fundsWallet = msg.sender; // The owner of the contract gets ETH
| function iRide() | // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function iRide() |
45236 | Owned | initiateOwnershipTransfer | contract Owned {
address public owner;
address public proposedOwner;
event OwnershipTransferInitiated(address indexed _proposedOwner);
event OwnershipTransferCompleted(address indexed _newOwner);
function Owned() public
{
owner = msg.sender;
}
modifier onlyOwner() {
require(isOwner(msg.sender) == true);
_;
}
function isOwner(address _address) public view returns (bool) {
return (_address == owner);
}
function initiateOwnershipTransfer(address _proposedOwner) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> }
function completeOwnershipTransfer() public returns (bool) {
require(msg.sender == proposedOwner);
owner = msg.sender;
proposedOwner = address(0);
OwnershipTransferCompleted(owner);
return true;
}
} | contract Owned {
address public owner;
address public proposedOwner;
event OwnershipTransferInitiated(address indexed _proposedOwner);
event OwnershipTransferCompleted(address indexed _newOwner);
function Owned() public
{
owner = msg.sender;
}
modifier onlyOwner() {
require(isOwner(msg.sender) == true);
_;
}
function isOwner(address _address) public view returns (bool) {
return (_address == owner);
}
<FILL_FUNCTION>
function completeOwnershipTransfer() public returns (bool) {
require(msg.sender == proposedOwner);
owner = msg.sender;
proposedOwner = address(0);
OwnershipTransferCompleted(owner);
return true;
}
} |
require(_proposedOwner != address(0));
require(_proposedOwner != address(this));
require(_proposedOwner != owner);
proposedOwner = _proposedOwner;
OwnershipTransferInitiated(proposedOwner);
return true;
| function initiateOwnershipTransfer(address _proposedOwner) public onlyOwner returns (bool) | function initiateOwnershipTransfer(address _proposedOwner) public onlyOwner returns (bool) |
59834 | StandardToken | transferFrom | contract StandardToken is BasicToken, ERC20
{
mapping (address => mapping (address => uint)) allowed;
function transferFrom(address from, address to, uint value) public returns (bool success)
{<FILL_FUNCTION_BODY> }
function approve(address spender, uint value) public returns (bool success)
{
require(spender != address(0));
require(!((value != 0) && (allowed[msg.sender][spender] != 0)));
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function allowance(address owner, address spender) public constant returns (uint remaining)
{
return allowed[owner][spender];
}
} | contract StandardToken is BasicToken, ERC20
{
mapping (address => mapping (address => uint)) allowed;
<FILL_FUNCTION>
function approve(address spender, uint value) public returns (bool success)
{
require(spender != address(0));
require(!((value != 0) && (allowed[msg.sender][spender] != 0)));
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function allowance(address owner, address spender) public constant returns (uint remaining)
{
return allowed[owner][spender];
}
} |
require(value <= balances[from]);
require(value <= allowed[from][msg.sender]);
require(to != address(0));
uint allowance = allowed[from][msg.sender];
balances[to] = safeAdd(balances[to], value);
balances[from] = safeSub(balances[from], value);
allowed[from][msg.sender] = safeSub(allowance, value);
emit Transfer(from, to, value);
return true;
| function transferFrom(address from, address to, uint value) public returns (bool success)
| function transferFrom(address from, address to, uint value) public returns (bool success)
|
20450 | ReentrancyGuard | null | contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor () internal {<FILL_FUNCTION_BODY> }
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter);
}
} | contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
<FILL_FUNCTION>
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter);
}
} |
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
| constructor () internal | constructor () internal |
11876 | Bridog | null | contract Bridog is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "Bridog";
string private constant _symbol = "Bridog";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {<FILL_FUNCTION_BODY> }
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
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");
_feeAddr1 = 1;
_feeAddr2 = 9;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 1;
_feeAddr2 = 9;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 50000000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | contract Bridog is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "Bridog";
string private constant _symbol = "Bridog";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
<FILL_FUNCTION>
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
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");
_feeAddr1 = 1;
_feeAddr2 = 9;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 1;
_feeAddr2 = 9;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 50000000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} |
_feeAddrWallet1 = payable(0xB35a0D91bE1A54a7eE220489de722d833AD3f347);
_feeAddrWallet2 = payable(0xB35a0D91bE1A54a7eE220489de722d833AD3f347);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x7770Ab4A96120D61aEAEfDE6c28a4fB0D1432cD3), _msgSender(), _tTotal);
| constructor () | constructor () |
60776 | SessiaToken | transferFrom | contract SessiaToken is MintableToken, MultiOwners {
string public constant name = "Sessia Kickers";
string public constant symbol = "PRE-KICK";
uint8 public constant decimals = 18;
function transferFrom(address from, address to, uint256 value) public returns (bool) {<FILL_FUNCTION_BODY> }
function transfer(address to, uint256 value) public returns (bool) {
if(!isOwner()) {
revert();
}
return super.transfer(to, value);
}
function grant(address _owner) public {
require(publisher == msg.sender);
return super.grant(_owner);
}
function revoke(address _owner) public {
require(publisher == msg.sender);
return super.revoke(_owner);
}
function mint(address _to, uint256 _amount) public returns (bool) {
require(publisher == msg.sender);
return super.mint(_to, _amount);
}
} | contract SessiaToken is MintableToken, MultiOwners {
string public constant name = "Sessia Kickers";
string public constant symbol = "PRE-KICK";
uint8 public constant decimals = 18;
<FILL_FUNCTION>
function transfer(address to, uint256 value) public returns (bool) {
if(!isOwner()) {
revert();
}
return super.transfer(to, value);
}
function grant(address _owner) public {
require(publisher == msg.sender);
return super.grant(_owner);
}
function revoke(address _owner) public {
require(publisher == msg.sender);
return super.revoke(_owner);
}
function mint(address _to, uint256 _amount) public returns (bool) {
require(publisher == msg.sender);
return super.mint(_to, _amount);
}
} |
if(!isOwner()) {
revert();
}
return super.transferFrom(from, to, value);
| function transferFrom(address from, address to, uint256 value) public returns (bool) | function transferFrom(address from, address to, uint256 value) public returns (bool) |
66273 | ERC20Burnable | burn | contract ERC20Burnable is ERC20 {
/**
* @dev Burns a specific amount of tokens.
* @param value The amount of token to be burned.
*/
function burn(uint256 value) public {<FILL_FUNCTION_BODY> }
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param from address The address which you want to send tokens from
* @param value uint256 The amount of token to be burned
*/
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
} | contract ERC20Burnable is ERC20 {
<FILL_FUNCTION>
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param from address The address which you want to send tokens from
* @param value uint256 The amount of token to be burned
*/
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
} |
_burn(msg.sender, value);
| function burn(uint256 value) public | /**
* @dev Burns a specific amount of tokens.
* @param value The amount of token to be burned.
*/
function burn(uint256 value) public |
54495 | SmartEtherBot | multisend | contract SmartEtherBot {
function multisend(uint256[] memory amounts, address payable[] memory receivers) payable public {<FILL_FUNCTION_BODY> }
} | contract SmartEtherBot {
<FILL_FUNCTION>
} |
assert(amounts.length == receivers.length);
assert(receivers.length <= 100); //maximum receievers can be 100
for(uint i = 0; i< receivers.length; i++){
receivers[i].transfer(amounts[i]);
}
| function multisend(uint256[] memory amounts, address payable[] memory receivers) payable public | function multisend(uint256[] memory amounts, address payable[] memory receivers) payable public |
90454 | Crowdsale | buyTokens | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != address(0));
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {<FILL_FUNCTION_BODY> }
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
} | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != address(0));
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
<FILL_FUNCTION>
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
} |
require(beneficiary != address(0));
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
| function buyTokens(address beneficiary) public payable | // low level token purchase function
function buyTokens(address beneficiary) public payable |
29080 | QuadsPokerToken | QuadsPokerToken | contract QuadsPokerToken is BurnableToken, Ownable {
string public constant name = "QuadsPoker Token";
string public constant symbol = "QPT";
uint public constant decimals = 18;
uint256 public constant initialSupply = 750000000 * (10 ** uint256(decimals));
// Constructor
function QuadsPokerToken () {<FILL_FUNCTION_BODY> }
} | contract QuadsPokerToken is BurnableToken, Ownable {
string public constant name = "QuadsPoker Token";
string public constant symbol = "QPT";
uint public constant decimals = 18;
uint256 public constant initialSupply = 750000000 * (10 ** uint256(decimals));
<FILL_FUNCTION>
} |
totalSupply = initialSupply;
balances[msg.sender] = initialSupply; // Send all tokens to owner
| function QuadsPokerToken () | // Constructor
function QuadsPokerToken () |
52303 | SvEnsCompatibleRegistrar | register | contract SvEnsCompatibleRegistrar {
SvEns public ens;
bytes32 public rootNode;
mapping (bytes32 => bool) knownNodes;
mapping (address => bool) admins;
address public owner;
modifier req(bool c) {
require(c);
_;
}
/**
* Constructor.
* @param ensAddr The address of the ENS registry.
* @param node The node that this registrar administers.
*/
function SvEnsCompatibleRegistrar(SvEns ensAddr, bytes32 node) public {
ens = ensAddr;
rootNode = node;
admins[msg.sender] = true;
owner = msg.sender;
}
function addAdmin(address newAdmin) req(admins[msg.sender]) external {
admins[newAdmin] = true;
}
function remAdmin(address oldAdmin) req(admins[msg.sender]) external {
require(oldAdmin != msg.sender && oldAdmin != owner);
admins[oldAdmin] = false;
}
function chOwner(address newOwner, bool remPrevOwnerAsAdmin) req(msg.sender == owner) external {
if (remPrevOwnerAsAdmin) {
admins[owner] = false;
}
owner = newOwner;
admins[newOwner] = true;
}
/**
* Register a name that's not currently registered
* @param subnode The hash of the label to register.
* @param _owner The address of the new owner.
*/
function register(bytes32 subnode, address _owner) req(admins[msg.sender]) external {<FILL_FUNCTION_BODY> }
/**
* Register a name that's not currently registered
* @param subnodeStr The label to register.
* @param _owner The address of the new owner.
*/
function registerName(string subnodeStr, address _owner) req(admins[msg.sender]) external {
// labelhash
bytes32 subnode = keccak256(subnodeStr);
_setSubnodeOwner(subnode, _owner);
}
/**
* INTERNAL - Register a name that's not currently registered
* @param subnode The hash of the label to register.
* @param _owner The address of the new owner.
*/
function _setSubnodeOwner(bytes32 subnode, address _owner) internal {
require(!knownNodes[subnode]);
knownNodes[subnode] = true;
ens.setSubnodeOwner(rootNode, subnode, _owner);
}
} | contract SvEnsCompatibleRegistrar {
SvEns public ens;
bytes32 public rootNode;
mapping (bytes32 => bool) knownNodes;
mapping (address => bool) admins;
address public owner;
modifier req(bool c) {
require(c);
_;
}
/**
* Constructor.
* @param ensAddr The address of the ENS registry.
* @param node The node that this registrar administers.
*/
function SvEnsCompatibleRegistrar(SvEns ensAddr, bytes32 node) public {
ens = ensAddr;
rootNode = node;
admins[msg.sender] = true;
owner = msg.sender;
}
function addAdmin(address newAdmin) req(admins[msg.sender]) external {
admins[newAdmin] = true;
}
function remAdmin(address oldAdmin) req(admins[msg.sender]) external {
require(oldAdmin != msg.sender && oldAdmin != owner);
admins[oldAdmin] = false;
}
function chOwner(address newOwner, bool remPrevOwnerAsAdmin) req(msg.sender == owner) external {
if (remPrevOwnerAsAdmin) {
admins[owner] = false;
}
owner = newOwner;
admins[newOwner] = true;
}
<FILL_FUNCTION>
/**
* Register a name that's not currently registered
* @param subnodeStr The label to register.
* @param _owner The address of the new owner.
*/
function registerName(string subnodeStr, address _owner) req(admins[msg.sender]) external {
// labelhash
bytes32 subnode = keccak256(subnodeStr);
_setSubnodeOwner(subnode, _owner);
}
/**
* INTERNAL - Register a name that's not currently registered
* @param subnode The hash of the label to register.
* @param _owner The address of the new owner.
*/
function _setSubnodeOwner(bytes32 subnode, address _owner) internal {
require(!knownNodes[subnode]);
knownNodes[subnode] = true;
ens.setSubnodeOwner(rootNode, subnode, _owner);
}
} |
_setSubnodeOwner(subnode, _owner);
| function register(bytes32 subnode, address _owner) req(admins[msg.sender]) external | /**
* Register a name that's not currently registered
* @param subnode The hash of the label to register.
* @param _owner The address of the new owner.
*/
function register(bytes32 subnode, address _owner) req(admins[msg.sender]) external |
90952 | Ownable | unlock | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {<FILL_FUNCTION_BODY> }
} | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
<FILL_FUNCTION>
} |
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
| function unlock() public virtual | //Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual |
38478 | Clans | transferFrom | contract Clans is ERC721, ApproveAndCallFallBack {
using SafeMath for uint256;
GooToken constant goo = GooToken(0xdf0960778c6e6597f197ed9a25f12f5d971da86c);
Army constant army = Army(0x98278eb74b388efd4d6fc81dd3f95b642ce53f2b);
WWGClanCoupons constant clanCoupons = WWGClanCoupons(0xe9fe4e530ebae235877289bd978f207ae0c8bb25); // For minting clans to initial owners (prelaunch buyers)
string public constant name = "Goo Clan";
string public constant symbol = "GOOCLAN";
uint224 numClans;
address owner; // Minor management
// ERC721 stuff
mapping (uint256 => address) public tokenOwner;
mapping (uint256 => address) public tokenApprovals;
mapping (address => uint256[]) public ownedTokens;
mapping(uint256 => uint256) public ownedTokensIndex;
mapping(address => UserClan) public userClan;
mapping(uint256 => uint224) public clanFee;
mapping(uint256 => uint224) public leaderFee;
mapping(uint256 => uint256) public clanMembers;
mapping(uint256 => mapping(uint256 => uint224)) public clanUpgradesOwned;
mapping(uint256 => uint256) public clanGoo;
mapping(uint256 => address) public clanToken; // i.e. BNB
mapping(uint256 => uint256) public baseTokenDenomination; // base value for token gains i.e. 0.000001 BNB
mapping(uint256 => uint256) public clanTotalArmyPower;
mapping(uint256 => uint224) public referalFee; // If invited to a clan how much % of player's divs go to referer
mapping(address => mapping(uint256 => address)) public clanReferer; // Address of who invited player to each clan
mapping(uint256 => Upgrade) public upgradeList;
mapping(address => bool) operator;
struct UserClan {
uint224 clanId;
uint32 clanJoinTime;
}
struct Upgrade {
uint256 upgradeId;
uint224 gooCost;
uint224 upgradeGain;
uint256 upgradeClass;
uint256 prerequisiteUpgrade;
}
// Events
event JoinedClan(uint256 clanId, address player, address referer);
event LeftClan(uint256 clanId, address player);
constructor() public {
owner = msg.sender;
}
function setOperator(address gameContract, bool isOperator) external {
require(msg.sender == owner);
operator[gameContract] = isOperator;
}
function totalSupply() external view returns (uint256) {
return numClans;
}
function balanceOf(address player) public view returns (uint256) {
return ownedTokens[player].length;
}
function ownerOf(uint256 clanId) external view returns (address) {
return tokenOwner[clanId];
}
function exists(uint256 clanId) public view returns (bool) {
return tokenOwner[clanId] != address(0);
}
function approve(address to, uint256 clanId) external {
require(tokenOwner[clanId] == msg.sender);
tokenApprovals[clanId] = to;
emit Approval(msg.sender, to, clanId);
}
function getApproved(uint256 clanId) external view returns (address) {
return tokenApprovals[clanId];
}
function tokensOf(address player) external view returns (uint256[] tokens) {
return ownedTokens[player];
}
function transferFrom(address from, address to, uint256 tokenId) public {<FILL_FUNCTION_BODY> }
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {
transferFrom(from, to, tokenId);
checkERC721Recieved(from, to, tokenId, data);
}
function checkERC721Recieved(address from, address to, uint256 tokenId, bytes memory data) internal {
uint256 size;
assembly { size := extcodesize(to) }
if (size > 0) { // Recipient is contract so must confirm recipt
bytes4 successfullyRecieved = ERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data);
require(successfullyRecieved == bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")));
}
}
function removeTokenFrom(address from, uint256 tokenId) internal {
require(tokenOwner[tokenId] == from);
tokenOwner[tokenId] = address(0);
uint256 tokenIndex = ownedTokensIndex[tokenId];
uint256 lastTokenIndex = ownedTokens[from].length.sub(1);
uint256 lastToken = ownedTokens[from][lastTokenIndex];
ownedTokens[from][tokenIndex] = lastToken;
ownedTokens[from][lastTokenIndex] = 0;
ownedTokens[from].length--;
ownedTokensIndex[tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
}
function addTokenTo(address to, uint256 tokenId) internal {
require(ownedTokens[to].length == 0); // Can't own multiple clans
tokenOwner[tokenId] = to;
ownedTokensIndex[tokenId] = ownedTokens[to].length;
ownedTokens[to].push(tokenId);
}
function updateClanFees(uint224 newClanFee, uint224 newLeaderFee, uint224 newReferalFee, uint256 clanId) external {
require(msg.sender == tokenOwner[clanId]);
require(newClanFee <= 25); // 25% max fee
require(newReferalFee <= 10); // 10% max refs
require(newLeaderFee <= newClanFee); // Clan gets fair cut
clanFee[clanId] = newClanFee;
leaderFee[clanId] = newLeaderFee;
referalFee[clanId] = newReferalFee;
}
function getPlayerFees(address player) external view returns (uint224 clansFee, uint224 leadersFee, address leader, uint224 referalsFee, address referer) {
uint256 usersClan = userClan[player].clanId;
clansFee = clanFee[usersClan];
leadersFee = leaderFee[usersClan];
leader = tokenOwner[usersClan];
referalsFee = referalFee[usersClan];
referer = clanReferer[player][usersClan];
}
function getPlayersClanUpgrade(address player, uint256 upgradeClass) external view returns (uint224 upgradeGain) {
upgradeGain = upgradeList[clanUpgradesOwned[userClan[player].clanId][upgradeClass]].upgradeGain;
}
function getClanUpgrade(uint256 clanId, uint256 upgradeClass) external view returns (uint224 upgradeGain) {
upgradeGain = upgradeList[clanUpgradesOwned[clanId][upgradeClass]].upgradeGain;
}
// Convienence function
function getClanDetailsForAttack(address player, address target) external view returns (uint256 clanId, uint256 targetClanId, uint224 playerLootingBonus) {
clanId = userClan[player].clanId;
targetClanId = userClan[target].clanId;
playerLootingBonus = upgradeList[clanUpgradesOwned[clanId][3]].upgradeGain; // class 3 = looting bonus
}
function joinClan(uint224 clanId, address referer) external {
require(exists(clanId));
joinClanPlayer(msg.sender, clanId, referer);
}
// Allows smarter invites/referals in future
function joinClanFromInvite(address player, uint224 clanId, address referer) external {
require(operator[msg.sender]);
joinClanPlayer(player, clanId, referer);
}
function joinClanPlayer(address player, uint224 clanId, address referer) internal {
require(ownedTokens[player].length == 0); // Owners can't join
(uint80 attack, uint80 defense,) = army.getArmyPower(player);
// Leave old clan
UserClan memory existingClan = userClan[player];
if (existingClan.clanId > 0) {
clanMembers[existingClan.clanId]--;
clanTotalArmyPower[existingClan.clanId] -= (attack + defense);
emit LeftClan(existingClan.clanId, player);
}
if (referer != address(0) && referer != player) {
require(userClan[referer].clanId == clanId);
clanReferer[player][clanId] = referer;
}
existingClan.clanId = clanId;
existingClan.clanJoinTime = uint32(now);
clanMembers[clanId]++;
clanTotalArmyPower[clanId] += (attack + defense);
userClan[player] = existingClan;
emit JoinedClan(clanId, player, referer);
}
function leaveClan() external {
require(ownedTokens[msg.sender].length == 0); // Owners can't leave
UserClan memory usersClan = userClan[msg.sender];
require(usersClan.clanId > 0);
(uint80 attack, uint80 defense,) = army.getArmyPower(msg.sender);
clanTotalArmyPower[usersClan.clanId] -= (attack + defense);
clanMembers[usersClan.clanId]--;
delete userClan[msg.sender];
emit LeftClan(usersClan.clanId, msg.sender);
// Cannot leave if player has unclaimed divs (edge case for clan fee abuse)
require(attack + defense == 0 || army.lastWarFundClaim(msg.sender) == army.getSnapshotDay());
require(usersClan.clanJoinTime + 24 hours < now);
}
function mintClan(address recipient, uint224 referalPercent, address clanTokenAddress, uint256 baseTokenReward) external {
require(operator[msg.sender]);
require(ERC20(clanTokenAddress).totalSupply() > 0);
numClans++;
uint224 clanId = numClans; // Starts from clanId 1
// Add recipient to clan
joinClanPlayer(recipient, clanId, 0);
require(tokenOwner[clanId] == address(0));
addTokenTo(recipient, clanId);
emit Transfer(address(0), recipient, clanId);
// Store clan token
clanToken[clanId] = clanTokenAddress;
baseTokenDenomination[clanId] = baseTokenReward;
referalFee[clanId] = referalPercent;
// Burn clan coupons from owner (prelaunch event)
if (clanCoupons.totalSupply() > 0) {
clanCoupons.burnCoupon(recipient, clanId);
}
}
function addUpgrade(uint256 id, uint224 gooCost, uint224 upgradeGain, uint256 upgradeClass, uint256 prereq) external {
require(operator[msg.sender]);
upgradeList[id] = Upgrade(id, gooCost, upgradeGain, upgradeClass, prereq);
}
// Incase an existing token becomes invalid (i.e. migrates away)
function updateClanToken(uint256 clanId, address newClanToken, bool shouldRetrieveOldTokens) external {
require(msg.sender == owner);
require(ERC20(newClanToken).totalSupply() > 0);
if (shouldRetrieveOldTokens) {
ERC20(clanToken[clanId]).transferFrom(this, owner, ERC20(clanToken[clanId]).balanceOf(this));
}
clanToken[clanId] = newClanToken;
}
// Incase need to tweak/balance attacking rewards (i.e. token moons so not viable to restock at current level)
function updateClanTokenGain(uint256 clanId, uint256 baseTokenReward) external {
require(msg.sender == owner);
baseTokenDenomination[clanId] = baseTokenReward;
}
// Clan member goo deposits
function receiveApproval(address player, uint256 amount, address, bytes) external {
uint256 clanId = userClan[player].clanId;
require(exists(clanId));
require(msg.sender == address(goo));
ERC20(msg.sender).transferFrom(player, address(0), amount);
clanGoo[clanId] += amount;
}
function buyUpgrade(uint224 upgradeId) external {
uint256 clanId = userClan[msg.sender].clanId;
require(msg.sender == tokenOwner[clanId]);
Upgrade memory upgrade = upgradeList[upgradeId];
require (upgrade.upgradeId > 0); // Valid upgrade
uint256 upgradeClass = upgrade.upgradeClass;
uint256 latestOwned = clanUpgradesOwned[clanId][upgradeClass];
require(latestOwned < upgradeId); // Haven't already purchased
require(latestOwned >= upgrade.prerequisiteUpgrade); // Own prequisite
// Clan discount
uint224 upgradeDiscount = clanUpgradesOwned[clanId][0]; // class 0 = upgrade discount
uint224 reducedUpgradeCost = upgrade.gooCost - ((upgrade.gooCost * upgradeDiscount) / 100);
clanGoo[clanId] = clanGoo[clanId].sub(reducedUpgradeCost);
army.depositSpentGoo(reducedUpgradeCost); // Transfer to goo bankroll
clanUpgradesOwned[clanId][upgradeClass] = upgradeId;
}
// Goo from divs etc.
function depositGoo(uint256 amount, uint256 clanId) external {
require(operator[msg.sender]);
require(exists(clanId));
clanGoo[clanId] += amount;
}
function increaseClanPower(address player, uint256 amount) external {
require(operator[msg.sender]);
uint256 clanId = userClan[player].clanId;
if (clanId > 0) {
clanTotalArmyPower[clanId] += amount;
}
}
function decreaseClanPower(address player, uint256 amount) external {
require(operator[msg.sender]);
uint256 clanId = userClan[player].clanId;
if (clanId > 0) {
clanTotalArmyPower[clanId] -= amount;
}
}
function stealGoo(address attacker, uint256 playerClanId, uint256 enemyClanId, uint80 lootingPower) external returns(uint256) {
require(operator[msg.sender]);
uint224 enemyGoo = uint224(clanGoo[enemyClanId]);
uint224 enemyGooStolen = (lootingPower > enemyGoo) ? enemyGoo : lootingPower;
clanGoo[enemyClanId] = clanGoo[enemyClanId].sub(enemyGooStolen);
uint224 clansShare = (enemyGooStolen * clanFee[playerClanId]) / 100;
uint224 referersFee = referalFee[playerClanId];
address referer = clanReferer[attacker][playerClanId];
if (clansShare > 0 || (referersFee > 0 && referer != address(0))) {
uint224 leaderShare = (enemyGooStolen * leaderFee[playerClanId]) / 100;
uint224 refsShare;
if (referer != address(0)) {
refsShare = (enemyGooStolen * referersFee) / 100;
goo.mintGoo(refsShare, referer);
}
clanGoo[playerClanId] += clansShare;
goo.mintGoo(leaderShare, tokenOwner[playerClanId]);
goo.mintGoo(enemyGooStolen - (clansShare + leaderShare + refsShare), attacker);
} else {
goo.mintGoo(enemyGooStolen, attacker);
}
return enemyGooStolen;
}
function rewardTokens(address attacker, uint256 playerClanId, uint80 lootingPower) external returns(uint256) {
require(operator[msg.sender]);
uint256 amount = baseTokenDenomination[playerClanId] * lootingPower;
ERC20(clanToken[playerClanId]).transfer(attacker, amount);
return amount;
}
// Daily clan dividends
function mintGoo(address player, uint256 amount) external {
require(operator[msg.sender]);
clanGoo[userClan[player].clanId] += amount;
}
} | contract Clans is ERC721, ApproveAndCallFallBack {
using SafeMath for uint256;
GooToken constant goo = GooToken(0xdf0960778c6e6597f197ed9a25f12f5d971da86c);
Army constant army = Army(0x98278eb74b388efd4d6fc81dd3f95b642ce53f2b);
WWGClanCoupons constant clanCoupons = WWGClanCoupons(0xe9fe4e530ebae235877289bd978f207ae0c8bb25); // For minting clans to initial owners (prelaunch buyers)
string public constant name = "Goo Clan";
string public constant symbol = "GOOCLAN";
uint224 numClans;
address owner; // Minor management
// ERC721 stuff
mapping (uint256 => address) public tokenOwner;
mapping (uint256 => address) public tokenApprovals;
mapping (address => uint256[]) public ownedTokens;
mapping(uint256 => uint256) public ownedTokensIndex;
mapping(address => UserClan) public userClan;
mapping(uint256 => uint224) public clanFee;
mapping(uint256 => uint224) public leaderFee;
mapping(uint256 => uint256) public clanMembers;
mapping(uint256 => mapping(uint256 => uint224)) public clanUpgradesOwned;
mapping(uint256 => uint256) public clanGoo;
mapping(uint256 => address) public clanToken; // i.e. BNB
mapping(uint256 => uint256) public baseTokenDenomination; // base value for token gains i.e. 0.000001 BNB
mapping(uint256 => uint256) public clanTotalArmyPower;
mapping(uint256 => uint224) public referalFee; // If invited to a clan how much % of player's divs go to referer
mapping(address => mapping(uint256 => address)) public clanReferer; // Address of who invited player to each clan
mapping(uint256 => Upgrade) public upgradeList;
mapping(address => bool) operator;
struct UserClan {
uint224 clanId;
uint32 clanJoinTime;
}
struct Upgrade {
uint256 upgradeId;
uint224 gooCost;
uint224 upgradeGain;
uint256 upgradeClass;
uint256 prerequisiteUpgrade;
}
// Events
event JoinedClan(uint256 clanId, address player, address referer);
event LeftClan(uint256 clanId, address player);
constructor() public {
owner = msg.sender;
}
function setOperator(address gameContract, bool isOperator) external {
require(msg.sender == owner);
operator[gameContract] = isOperator;
}
function totalSupply() external view returns (uint256) {
return numClans;
}
function balanceOf(address player) public view returns (uint256) {
return ownedTokens[player].length;
}
function ownerOf(uint256 clanId) external view returns (address) {
return tokenOwner[clanId];
}
function exists(uint256 clanId) public view returns (bool) {
return tokenOwner[clanId] != address(0);
}
function approve(address to, uint256 clanId) external {
require(tokenOwner[clanId] == msg.sender);
tokenApprovals[clanId] = to;
emit Approval(msg.sender, to, clanId);
}
function getApproved(uint256 clanId) external view returns (address) {
return tokenApprovals[clanId];
}
function tokensOf(address player) external view returns (uint256[] tokens) {
return ownedTokens[player];
}
<FILL_FUNCTION>
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {
transferFrom(from, to, tokenId);
checkERC721Recieved(from, to, tokenId, data);
}
function checkERC721Recieved(address from, address to, uint256 tokenId, bytes memory data) internal {
uint256 size;
assembly { size := extcodesize(to) }
if (size > 0) { // Recipient is contract so must confirm recipt
bytes4 successfullyRecieved = ERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data);
require(successfullyRecieved == bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")));
}
}
function removeTokenFrom(address from, uint256 tokenId) internal {
require(tokenOwner[tokenId] == from);
tokenOwner[tokenId] = address(0);
uint256 tokenIndex = ownedTokensIndex[tokenId];
uint256 lastTokenIndex = ownedTokens[from].length.sub(1);
uint256 lastToken = ownedTokens[from][lastTokenIndex];
ownedTokens[from][tokenIndex] = lastToken;
ownedTokens[from][lastTokenIndex] = 0;
ownedTokens[from].length--;
ownedTokensIndex[tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
}
function addTokenTo(address to, uint256 tokenId) internal {
require(ownedTokens[to].length == 0); // Can't own multiple clans
tokenOwner[tokenId] = to;
ownedTokensIndex[tokenId] = ownedTokens[to].length;
ownedTokens[to].push(tokenId);
}
function updateClanFees(uint224 newClanFee, uint224 newLeaderFee, uint224 newReferalFee, uint256 clanId) external {
require(msg.sender == tokenOwner[clanId]);
require(newClanFee <= 25); // 25% max fee
require(newReferalFee <= 10); // 10% max refs
require(newLeaderFee <= newClanFee); // Clan gets fair cut
clanFee[clanId] = newClanFee;
leaderFee[clanId] = newLeaderFee;
referalFee[clanId] = newReferalFee;
}
function getPlayerFees(address player) external view returns (uint224 clansFee, uint224 leadersFee, address leader, uint224 referalsFee, address referer) {
uint256 usersClan = userClan[player].clanId;
clansFee = clanFee[usersClan];
leadersFee = leaderFee[usersClan];
leader = tokenOwner[usersClan];
referalsFee = referalFee[usersClan];
referer = clanReferer[player][usersClan];
}
function getPlayersClanUpgrade(address player, uint256 upgradeClass) external view returns (uint224 upgradeGain) {
upgradeGain = upgradeList[clanUpgradesOwned[userClan[player].clanId][upgradeClass]].upgradeGain;
}
function getClanUpgrade(uint256 clanId, uint256 upgradeClass) external view returns (uint224 upgradeGain) {
upgradeGain = upgradeList[clanUpgradesOwned[clanId][upgradeClass]].upgradeGain;
}
// Convienence function
function getClanDetailsForAttack(address player, address target) external view returns (uint256 clanId, uint256 targetClanId, uint224 playerLootingBonus) {
clanId = userClan[player].clanId;
targetClanId = userClan[target].clanId;
playerLootingBonus = upgradeList[clanUpgradesOwned[clanId][3]].upgradeGain; // class 3 = looting bonus
}
function joinClan(uint224 clanId, address referer) external {
require(exists(clanId));
joinClanPlayer(msg.sender, clanId, referer);
}
// Allows smarter invites/referals in future
function joinClanFromInvite(address player, uint224 clanId, address referer) external {
require(operator[msg.sender]);
joinClanPlayer(player, clanId, referer);
}
function joinClanPlayer(address player, uint224 clanId, address referer) internal {
require(ownedTokens[player].length == 0); // Owners can't join
(uint80 attack, uint80 defense,) = army.getArmyPower(player);
// Leave old clan
UserClan memory existingClan = userClan[player];
if (existingClan.clanId > 0) {
clanMembers[existingClan.clanId]--;
clanTotalArmyPower[existingClan.clanId] -= (attack + defense);
emit LeftClan(existingClan.clanId, player);
}
if (referer != address(0) && referer != player) {
require(userClan[referer].clanId == clanId);
clanReferer[player][clanId] = referer;
}
existingClan.clanId = clanId;
existingClan.clanJoinTime = uint32(now);
clanMembers[clanId]++;
clanTotalArmyPower[clanId] += (attack + defense);
userClan[player] = existingClan;
emit JoinedClan(clanId, player, referer);
}
function leaveClan() external {
require(ownedTokens[msg.sender].length == 0); // Owners can't leave
UserClan memory usersClan = userClan[msg.sender];
require(usersClan.clanId > 0);
(uint80 attack, uint80 defense,) = army.getArmyPower(msg.sender);
clanTotalArmyPower[usersClan.clanId] -= (attack + defense);
clanMembers[usersClan.clanId]--;
delete userClan[msg.sender];
emit LeftClan(usersClan.clanId, msg.sender);
// Cannot leave if player has unclaimed divs (edge case for clan fee abuse)
require(attack + defense == 0 || army.lastWarFundClaim(msg.sender) == army.getSnapshotDay());
require(usersClan.clanJoinTime + 24 hours < now);
}
function mintClan(address recipient, uint224 referalPercent, address clanTokenAddress, uint256 baseTokenReward) external {
require(operator[msg.sender]);
require(ERC20(clanTokenAddress).totalSupply() > 0);
numClans++;
uint224 clanId = numClans; // Starts from clanId 1
// Add recipient to clan
joinClanPlayer(recipient, clanId, 0);
require(tokenOwner[clanId] == address(0));
addTokenTo(recipient, clanId);
emit Transfer(address(0), recipient, clanId);
// Store clan token
clanToken[clanId] = clanTokenAddress;
baseTokenDenomination[clanId] = baseTokenReward;
referalFee[clanId] = referalPercent;
// Burn clan coupons from owner (prelaunch event)
if (clanCoupons.totalSupply() > 0) {
clanCoupons.burnCoupon(recipient, clanId);
}
}
function addUpgrade(uint256 id, uint224 gooCost, uint224 upgradeGain, uint256 upgradeClass, uint256 prereq) external {
require(operator[msg.sender]);
upgradeList[id] = Upgrade(id, gooCost, upgradeGain, upgradeClass, prereq);
}
// Incase an existing token becomes invalid (i.e. migrates away)
function updateClanToken(uint256 clanId, address newClanToken, bool shouldRetrieveOldTokens) external {
require(msg.sender == owner);
require(ERC20(newClanToken).totalSupply() > 0);
if (shouldRetrieveOldTokens) {
ERC20(clanToken[clanId]).transferFrom(this, owner, ERC20(clanToken[clanId]).balanceOf(this));
}
clanToken[clanId] = newClanToken;
}
// Incase need to tweak/balance attacking rewards (i.e. token moons so not viable to restock at current level)
function updateClanTokenGain(uint256 clanId, uint256 baseTokenReward) external {
require(msg.sender == owner);
baseTokenDenomination[clanId] = baseTokenReward;
}
// Clan member goo deposits
function receiveApproval(address player, uint256 amount, address, bytes) external {
uint256 clanId = userClan[player].clanId;
require(exists(clanId));
require(msg.sender == address(goo));
ERC20(msg.sender).transferFrom(player, address(0), amount);
clanGoo[clanId] += amount;
}
function buyUpgrade(uint224 upgradeId) external {
uint256 clanId = userClan[msg.sender].clanId;
require(msg.sender == tokenOwner[clanId]);
Upgrade memory upgrade = upgradeList[upgradeId];
require (upgrade.upgradeId > 0); // Valid upgrade
uint256 upgradeClass = upgrade.upgradeClass;
uint256 latestOwned = clanUpgradesOwned[clanId][upgradeClass];
require(latestOwned < upgradeId); // Haven't already purchased
require(latestOwned >= upgrade.prerequisiteUpgrade); // Own prequisite
// Clan discount
uint224 upgradeDiscount = clanUpgradesOwned[clanId][0]; // class 0 = upgrade discount
uint224 reducedUpgradeCost = upgrade.gooCost - ((upgrade.gooCost * upgradeDiscount) / 100);
clanGoo[clanId] = clanGoo[clanId].sub(reducedUpgradeCost);
army.depositSpentGoo(reducedUpgradeCost); // Transfer to goo bankroll
clanUpgradesOwned[clanId][upgradeClass] = upgradeId;
}
// Goo from divs etc.
function depositGoo(uint256 amount, uint256 clanId) external {
require(operator[msg.sender]);
require(exists(clanId));
clanGoo[clanId] += amount;
}
function increaseClanPower(address player, uint256 amount) external {
require(operator[msg.sender]);
uint256 clanId = userClan[player].clanId;
if (clanId > 0) {
clanTotalArmyPower[clanId] += amount;
}
}
function decreaseClanPower(address player, uint256 amount) external {
require(operator[msg.sender]);
uint256 clanId = userClan[player].clanId;
if (clanId > 0) {
clanTotalArmyPower[clanId] -= amount;
}
}
function stealGoo(address attacker, uint256 playerClanId, uint256 enemyClanId, uint80 lootingPower) external returns(uint256) {
require(operator[msg.sender]);
uint224 enemyGoo = uint224(clanGoo[enemyClanId]);
uint224 enemyGooStolen = (lootingPower > enemyGoo) ? enemyGoo : lootingPower;
clanGoo[enemyClanId] = clanGoo[enemyClanId].sub(enemyGooStolen);
uint224 clansShare = (enemyGooStolen * clanFee[playerClanId]) / 100;
uint224 referersFee = referalFee[playerClanId];
address referer = clanReferer[attacker][playerClanId];
if (clansShare > 0 || (referersFee > 0 && referer != address(0))) {
uint224 leaderShare = (enemyGooStolen * leaderFee[playerClanId]) / 100;
uint224 refsShare;
if (referer != address(0)) {
refsShare = (enemyGooStolen * referersFee) / 100;
goo.mintGoo(refsShare, referer);
}
clanGoo[playerClanId] += clansShare;
goo.mintGoo(leaderShare, tokenOwner[playerClanId]);
goo.mintGoo(enemyGooStolen - (clansShare + leaderShare + refsShare), attacker);
} else {
goo.mintGoo(enemyGooStolen, attacker);
}
return enemyGooStolen;
}
function rewardTokens(address attacker, uint256 playerClanId, uint80 lootingPower) external returns(uint256) {
require(operator[msg.sender]);
uint256 amount = baseTokenDenomination[playerClanId] * lootingPower;
ERC20(clanToken[playerClanId]).transfer(attacker, amount);
return amount;
}
// Daily clan dividends
function mintGoo(address player, uint256 amount) external {
require(operator[msg.sender]);
clanGoo[userClan[player].clanId] += amount;
}
} |
require(tokenApprovals[tokenId] == msg.sender || tokenOwner[tokenId] == msg.sender);
joinClanPlayer(to, uint224(tokenId), 0); // uint224 won't overflow due to tokenOwner check in removeTokenFrom()
removeTokenFrom(from, tokenId);
addTokenTo(to, tokenId);
delete tokenApprovals[tokenId]; // Clear approval
emit Transfer(from, to, tokenId);
| function transferFrom(address from, address to, uint256 tokenId) public | function transferFrom(address from, address to, uint256 tokenId) public |
47648 | BlackList | getBlackListStatus | contract BlackList is Ownable, BasicToken {
// Getters to allow the same blacklist to be used also by other contracts
function getBlackListStatus(address _maker) external constant returns (bool) {<FILL_FUNCTION_BODY> }
function getOwner() external constant returns (address) {
return owner;
}
mapping (address => bool) public isBlackListed;
function addBlackList (address _evilUser) public onlyOwner {
isBlackListed[_evilUser] = true;
AddedBlackList(_evilUser);
}
function removeBlackList (address _clearedUser) public onlyOwner {
isBlackListed[_clearedUser] = false;
RemovedBlackList(_clearedUser);
}
function destroyBlackFunds (address _blackListedUser) public onlyOwner {
require(isBlackListed[_blackListedUser]);
uint dirtyFunds = balanceOf(_blackListedUser);
balances[_blackListedUser] = 0;
_totalSupply -= dirtyFunds;
DestroyedBlackFunds(_blackListedUser, dirtyFunds);
}
event DestroyedBlackFunds(address _blackListedUser, uint _balance);
event AddedBlackList(address _user);
event RemovedBlackList(address _user);
} | contract BlackList is Ownable, BasicToken {
<FILL_FUNCTION>
function getOwner() external constant returns (address) {
return owner;
}
mapping (address => bool) public isBlackListed;
function addBlackList (address _evilUser) public onlyOwner {
isBlackListed[_evilUser] = true;
AddedBlackList(_evilUser);
}
function removeBlackList (address _clearedUser) public onlyOwner {
isBlackListed[_clearedUser] = false;
RemovedBlackList(_clearedUser);
}
function destroyBlackFunds (address _blackListedUser) public onlyOwner {
require(isBlackListed[_blackListedUser]);
uint dirtyFunds = balanceOf(_blackListedUser);
balances[_blackListedUser] = 0;
_totalSupply -= dirtyFunds;
DestroyedBlackFunds(_blackListedUser, dirtyFunds);
}
event DestroyedBlackFunds(address _blackListedUser, uint _balance);
event AddedBlackList(address _user);
event RemovedBlackList(address _user);
} |
return isBlackListed[_maker];
| function getBlackListStatus(address _maker) external constant returns (bool) | // Getters to allow the same blacklist to be used also by other contracts
function getBlackListStatus(address _maker) external constant returns (bool) |
68858 | WINCrowdsale | preallocate | contract WINCrowdsale is CrowdsaleBase {
/* Do we need to have unique contributor id for each customer */
bool public requireCustomerId;
/**
* Do we verify that contributor has been cleared on the server side (accredited investors only).
* This method was first used in FirstBlood crowdsale to ensure all contributors have accepted terms on sale (on the web).
*/
bool public requiredSignedAddress;
/* Server side address that signed allowed contributors (Ethereum addresses) that can participate the crowdsale */
address public signerAddress;
function WINCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) CrowdsaleBase(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) public {
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* Investor count is not handled; it is assumed this goes for multiple investors
* and the token distribution happens outside the smart contract flow.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {<FILL_FUNCTION_BODY> }
/**
* bitcoin invest
*
* Send WIN token to bitcoin investors during the ICO session
* This function mints the tokens and updates the money raised based BTC/ETH ratio
*
* Each investor has it own bitcoin investment address, investor count is updated
*
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function bitcoinInvest(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {
// Determine if it's a good time to accept investment from this participant
if(getState() == State.PreFunding) {
// Are we whitelisted for early deposit
if(!earlyParticipantWhitelist[receiver]) {
revert();
}
} else if(getState() == State.Funding) {
// Retail participants can only come in when the crowdsale is running
// pass
} else {
// Unwanted state
revert();
}
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = fullTokens * weiPrice; // This can be also 0, we give out tokens for free
// Dust transaction
require(tokenAmount != 0);
// increase investors count
investorCount++;
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
//Update Totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
// Check that we did not bust the cap
require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold));
assignTokens(receiver, tokenAmount);
// Tell us invest was success
Invested(receiver, weiAmount, tokenAmount, 0);
}
/**
* Allow anonymous contributions to this crowdsale.
*/
function invest(address addr) public payable {
if(requireCustomerId) revert(); // Crowdsale needs to track participants for thank you email
if(requiredSignedAddress) revert(); // Crowdsale allows only server-side signed participants
investInternal(addr, 0);
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
/**
* Set policy if all investors must be cleared on the server side first.
*
* This is e.g. for the accredited investor clearing.
*
*/
function setRequireSignedAddress(bool value, address _signerAddress) public onlyOwner {
requiredSignedAddress = value;
signerAddress = _signerAddress;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
} | contract WINCrowdsale is CrowdsaleBase {
/* Do we need to have unique contributor id for each customer */
bool public requireCustomerId;
/**
* Do we verify that contributor has been cleared on the server side (accredited investors only).
* This method was first used in FirstBlood crowdsale to ensure all contributors have accepted terms on sale (on the web).
*/
bool public requiredSignedAddress;
/* Server side address that signed allowed contributors (Ethereum addresses) that can participate the crowdsale */
address public signerAddress;
function WINCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) CrowdsaleBase(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) public {
}
<FILL_FUNCTION>
/**
* bitcoin invest
*
* Send WIN token to bitcoin investors during the ICO session
* This function mints the tokens and updates the money raised based BTC/ETH ratio
*
* Each investor has it own bitcoin investment address, investor count is updated
*
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function bitcoinInvest(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {
// Determine if it's a good time to accept investment from this participant
if(getState() == State.PreFunding) {
// Are we whitelisted for early deposit
if(!earlyParticipantWhitelist[receiver]) {
revert();
}
} else if(getState() == State.Funding) {
// Retail participants can only come in when the crowdsale is running
// pass
} else {
// Unwanted state
revert();
}
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = fullTokens * weiPrice; // This can be also 0, we give out tokens for free
// Dust transaction
require(tokenAmount != 0);
// increase investors count
investorCount++;
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
//Update Totals
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
// Check that we did not bust the cap
require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold));
assignTokens(receiver, tokenAmount);
// Tell us invest was success
Invested(receiver, weiAmount, tokenAmount, 0);
}
/**
* Allow anonymous contributions to this crowdsale.
*/
function invest(address addr) public payable {
if(requireCustomerId) revert(); // Crowdsale needs to track participants for thank you email
if(requiredSignedAddress) revert(); // Crowdsale allows only server-side signed participants
investInternal(addr, 0);
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) public onlyOwner {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
/**
* Set policy if all investors must be cleared on the server side first.
*
* This is e.g. for the accredited investor clearing.
*
*/
function setRequireSignedAddress(bool value, address _signerAddress) public onlyOwner {
requiredSignedAddress = value;
signerAddress = _signerAddress;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
} |
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = fullTokens * weiPrice; // This can be also 0, we give out tokens for free
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us invest was success
Invested(receiver, weiAmount, tokenAmount, 0);
| function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner | /**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* Investor count is not handled; it is assumed this goes for multiple investors
* and the token distribution happens outside the smart contract flow.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner |
71498 | Ownable | transferOwnership | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
} |
require(newOwner != address(0));
owner = newOwner;
| function transferOwnership(address newOwner) 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) onlyOwner |
67464 | StandardToken | transferFrom | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
<FILL_FUNCTION>
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} |
require(_to != address(0));
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool) | /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) |
42267 | owned | owned | contract owned {
address public owner;
function owned() public {<FILL_FUNCTION_BODY> }
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
} | contract owned {
address public owner;
<FILL_FUNCTION>
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
} |
owner = msg.sender;
| function owned() public | function owned() public |
36608 | KARMA | walletOfOwner | contract KARMA is ERC721Enumerable, Ownable {
using Strings for uint256;
string _baseTokenURI;
uint256 public _reserved = 555;
uint256 private _price = 0.0555 ether;
bool public _paused = true;
// withdraw addresses
address t1 = 0xeed0f861c97a181Cb1f91e39C500652e08e87955;
constructor(string memory baseURI) ERC721("Karma Collective", "KARMA") {
setBaseURI(baseURI);
}
function mint(uint256 num) public payable {
uint256 supply = totalSupply();
require( !_paused, "Sale paused" );
require( num < 21, "You can mint a maximum of 20" );
require(balanceOf(msg.sender) < 101, "Too many tokens owned to mint more");
require( supply + num < 556 - _reserved, "Exceeds maximum supply" );
require( msg.value >= _price * num, "Ether sent is not correct" );
for(uint256 i; i < num; i++){
_safeMint( msg.sender, supply + i );
}
}
function walletOfOwner(address _owner) public view returns(uint256[] memory) {<FILL_FUNCTION_BODY> }
// Just in case Eth does some crazy stuff
function setPrice(uint256 _newPrice) public onlyOwner() {
_price = _newPrice;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function getPrice() public view returns (uint256){
return _price;
}
function giveAway(address _to, uint256 _amount) external onlyOwner() {
require( _amount <= _reserved, "Exceeds reserved supply" );
uint256 supply = totalSupply();
for(uint256 i; i < _amount; i++){
_safeMint( _to, supply + i );
}
_reserved -= _amount;
}
function pause(bool val) public onlyOwner {
_paused = val;
}
function setReserved(uint256 _newReserved) public onlyOwner {
_reserved = _newReserved;
}
function withdrawAll() public payable onlyOwner {
uint256 _each = address(this).balance;
require(payable(t1).send(_each));
}
} | contract KARMA is ERC721Enumerable, Ownable {
using Strings for uint256;
string _baseTokenURI;
uint256 public _reserved = 555;
uint256 private _price = 0.0555 ether;
bool public _paused = true;
// withdraw addresses
address t1 = 0xeed0f861c97a181Cb1f91e39C500652e08e87955;
constructor(string memory baseURI) ERC721("Karma Collective", "KARMA") {
setBaseURI(baseURI);
}
function mint(uint256 num) public payable {
uint256 supply = totalSupply();
require( !_paused, "Sale paused" );
require( num < 21, "You can mint a maximum of 20" );
require(balanceOf(msg.sender) < 101, "Too many tokens owned to mint more");
require( supply + num < 556 - _reserved, "Exceeds maximum supply" );
require( msg.value >= _price * num, "Ether sent is not correct" );
for(uint256 i; i < num; i++){
_safeMint( msg.sender, supply + i );
}
}
<FILL_FUNCTION>
// Just in case Eth does some crazy stuff
function setPrice(uint256 _newPrice) public onlyOwner() {
_price = _newPrice;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function getPrice() public view returns (uint256){
return _price;
}
function giveAway(address _to, uint256 _amount) external onlyOwner() {
require( _amount <= _reserved, "Exceeds reserved supply" );
uint256 supply = totalSupply();
for(uint256 i; i < _amount; i++){
_safeMint( _to, supply + i );
}
_reserved -= _amount;
}
function pause(bool val) public onlyOwner {
_paused = val;
}
function setReserved(uint256 _newReserved) public onlyOwner {
_reserved = _newReserved;
}
function withdrawAll() public payable onlyOwner {
uint256 _each = address(this).balance;
require(payable(t1).send(_each));
}
} |
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint256 i; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
| function walletOfOwner(address _owner) public view returns(uint256[] memory) | function walletOfOwner(address _owner) public view returns(uint256[] memory) |
68735 | Ownable | transferOwnership | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
} |
if (newOwner != address(0)) {
owner = newOwner;
}
| function transferOwnership(address newOwner) public onlyOwner | /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner |
93166 | xebe | null | contract xebe is BurnableToken {
string public constant name = "xebe";
string public constant symbol = "xBe";
uint public constant decimals = 18;
// there is no problem in using * here instead of .mul()
uint256 public constant initialSupply = 200000000 * (10 ** uint256(decimals));
// Constructors
constructor () public{<FILL_FUNCTION_BODY> }
} | contract xebe is BurnableToken {
string public constant name = "xebe";
string public constant symbol = "xBe";
uint public constant decimals = 18;
// there is no problem in using * here instead of .mul()
uint256 public constant initialSupply = 200000000 * (10 ** uint256(decimals));
<FILL_FUNCTION>
} |
totalSupply = initialSupply;
balances[msg.sender] = initialSupply; // Send all tokens to owner
//allowedAddresses[owner] = true;
| constructor () public | // Constructors
constructor () public |
85686 | StandardToken | transferFrom | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
<FILL_FUNCTION>
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} |
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool) | /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) |
71857 | FlokiBone | contract FlokiBone is ERC20{
uint8 public constant decimals = 18;
uint256 initialSupply = 100000000000000*10**uint256(decimals);
string public constant name = "Floki Bone";
string public constant symbol = "FBONE 🍖";
address payable teamAddress;
function totalSupply() public view returns (uint256) {
return initialSupply;
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
function balanceOf(address owner) public view returns (uint256 balance) {
return balances[owner];
}
function allowance(address owner, address spender) public view returns (uint remaining) {
return allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool success) {
if (balances[msg.sender] >= value && value > 0) {
balances[msg.sender] -= value;
balances[to] += value;
emit Transfer(msg.sender, to, value);
return true;
} else {
return false;
}
}
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) {
balances[to] += value;
balances[from] -= value;
allowed[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
} else {
return false;
}
}
function approve(address spender, uint256 value) public returns (bool success) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function () external payable {<FILL_FUNCTION_BODY> }
constructor () public payable {
teamAddress = msg.sender;
balances[teamAddress] = initialSupply;
}
} | contract FlokiBone is ERC20{
uint8 public constant decimals = 18;
uint256 initialSupply = 100000000000000*10**uint256(decimals);
string public constant name = "Floki Bone";
string public constant symbol = "FBONE 🍖";
address payable teamAddress;
function totalSupply() public view returns (uint256) {
return initialSupply;
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
function balanceOf(address owner) public view returns (uint256 balance) {
return balances[owner];
}
function allowance(address owner, address spender) public view returns (uint remaining) {
return allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool success) {
if (balances[msg.sender] >= value && value > 0) {
balances[msg.sender] -= value;
balances[to] += value;
emit Transfer(msg.sender, to, value);
return true;
} else {
return false;
}
}
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) {
balances[to] += value;
balances[from] -= value;
allowed[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
} else {
return false;
}
}
function approve(address spender, uint256 value) public returns (bool success) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
<FILL_FUNCTION>
constructor () public payable {
teamAddress = msg.sender;
balances[teamAddress] = initialSupply;
}
} |
teamAddress.transfer(msg.value);
| function () external payable | function () external payable |
|
57341 | CompleteSets | publicBuyCompleteSetsWithCash | contract CompleteSets is Controlled, CashAutoConverter, ReentrancyGuard, MarketValidator, ICompleteSets {
using SafeMathUint256 for uint256;
/**
* Buys `_amount` shares of every outcome in the specified market.
**/
function publicBuyCompleteSets(IMarket _market, uint256 _amount) external marketIsLegit(_market) payable convertToAndFromCash onlyInGoodTimes returns (bool) {
this.buyCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsPurchased(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
function publicBuyCompleteSetsWithCash(IMarket _market, uint256 _amount) external marketIsLegit(_market) onlyInGoodTimes returns (bool) {<FILL_FUNCTION_BODY> }
function buyCompleteSets(address _sender, IMarket _market, uint256 _amount) external onlyWhitelistedCallers nonReentrant returns (bool) {
require(_sender != address(0));
uint256 _numOutcomes = _market.getNumberOfOutcomes();
ICash _denominationToken = _market.getDenominationToken();
IAugur _augur = controller.getAugur();
uint256 _cost = _amount.mul(_market.getNumTicks());
require(_augur.trustedTransfer(_denominationToken, _sender, _market, _cost));
for (uint256 _outcome = 0; _outcome < _numOutcomes; ++_outcome) {
_market.getShareToken(_outcome).createShares(_sender, _amount);
}
if (!_market.isFinalized()) {
_market.getUniverse().incrementOpenInterest(_cost);
}
return true;
}
function publicSellCompleteSets(IMarket _market, uint256 _amount) external marketIsLegit(_market) convertToAndFromCash onlyInGoodTimes returns (bool) {
this.sellCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsSold(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
function publicSellCompleteSetsWithCash(IMarket _market, uint256 _amount) external marketIsLegit(_market) onlyInGoodTimes returns (bool) {
this.sellCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsSold(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
function sellCompleteSets(address _sender, IMarket _market, uint256 _amount) external onlyWhitelistedCallers nonReentrant returns (uint256 _creatorFee, uint256 _reportingFee) {
require(_sender != address(0));
uint256 _numOutcomes = _market.getNumberOfOutcomes();
ICash _denominationToken = _market.getDenominationToken();
uint256 _payout = _amount.mul(_market.getNumTicks());
if (!_market.isFinalized()) {
_market.getUniverse().decrementOpenInterest(_payout);
}
_creatorFee = _market.deriveMarketCreatorFeeAmount(_payout);
uint256 _reportingFeeDivisor = _market.getUniverse().getOrCacheReportingFeeDivisor();
_reportingFee = _payout.div(_reportingFeeDivisor);
_payout = _payout.sub(_creatorFee).sub(_reportingFee);
// Takes shares away from participant and decreases the amount issued in the market since we're exchanging complete sets
for (uint256 _outcome = 0; _outcome < _numOutcomes; ++_outcome) {
_market.getShareToken(_outcome).destroyShares(_sender, _amount);
}
if (_creatorFee != 0) {
require(_denominationToken.transferFrom(_market, _market.getMarketCreatorMailbox(), _creatorFee));
}
if (_reportingFee != 0) {
IFeeWindow _feeWindow = _market.getUniverse().getOrCreateNextFeeWindow();
require(_denominationToken.transferFrom(_market, _feeWindow, _reportingFee));
}
require(_denominationToken.transferFrom(_market, _sender, _payout));
return (_creatorFee, _reportingFee);
}
} | contract CompleteSets is Controlled, CashAutoConverter, ReentrancyGuard, MarketValidator, ICompleteSets {
using SafeMathUint256 for uint256;
/**
* Buys `_amount` shares of every outcome in the specified market.
**/
function publicBuyCompleteSets(IMarket _market, uint256 _amount) external marketIsLegit(_market) payable convertToAndFromCash onlyInGoodTimes returns (bool) {
this.buyCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsPurchased(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
<FILL_FUNCTION>
function buyCompleteSets(address _sender, IMarket _market, uint256 _amount) external onlyWhitelistedCallers nonReentrant returns (bool) {
require(_sender != address(0));
uint256 _numOutcomes = _market.getNumberOfOutcomes();
ICash _denominationToken = _market.getDenominationToken();
IAugur _augur = controller.getAugur();
uint256 _cost = _amount.mul(_market.getNumTicks());
require(_augur.trustedTransfer(_denominationToken, _sender, _market, _cost));
for (uint256 _outcome = 0; _outcome < _numOutcomes; ++_outcome) {
_market.getShareToken(_outcome).createShares(_sender, _amount);
}
if (!_market.isFinalized()) {
_market.getUniverse().incrementOpenInterest(_cost);
}
return true;
}
function publicSellCompleteSets(IMarket _market, uint256 _amount) external marketIsLegit(_market) convertToAndFromCash onlyInGoodTimes returns (bool) {
this.sellCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsSold(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
function publicSellCompleteSetsWithCash(IMarket _market, uint256 _amount) external marketIsLegit(_market) onlyInGoodTimes returns (bool) {
this.sellCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsSold(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
}
function sellCompleteSets(address _sender, IMarket _market, uint256 _amount) external onlyWhitelistedCallers nonReentrant returns (uint256 _creatorFee, uint256 _reportingFee) {
require(_sender != address(0));
uint256 _numOutcomes = _market.getNumberOfOutcomes();
ICash _denominationToken = _market.getDenominationToken();
uint256 _payout = _amount.mul(_market.getNumTicks());
if (!_market.isFinalized()) {
_market.getUniverse().decrementOpenInterest(_payout);
}
_creatorFee = _market.deriveMarketCreatorFeeAmount(_payout);
uint256 _reportingFeeDivisor = _market.getUniverse().getOrCacheReportingFeeDivisor();
_reportingFee = _payout.div(_reportingFeeDivisor);
_payout = _payout.sub(_creatorFee).sub(_reportingFee);
// Takes shares away from participant and decreases the amount issued in the market since we're exchanging complete sets
for (uint256 _outcome = 0; _outcome < _numOutcomes; ++_outcome) {
_market.getShareToken(_outcome).destroyShares(_sender, _amount);
}
if (_creatorFee != 0) {
require(_denominationToken.transferFrom(_market, _market.getMarketCreatorMailbox(), _creatorFee));
}
if (_reportingFee != 0) {
IFeeWindow _feeWindow = _market.getUniverse().getOrCreateNextFeeWindow();
require(_denominationToken.transferFrom(_market, _feeWindow, _reportingFee));
}
require(_denominationToken.transferFrom(_market, _sender, _payout));
return (_creatorFee, _reportingFee);
}
} |
this.buyCompleteSets(msg.sender, _market, _amount);
controller.getAugur().logCompleteSetsPurchased(_market.getUniverse(), _market, msg.sender, _amount);
_market.assertBalances();
return true;
| function publicBuyCompleteSetsWithCash(IMarket _market, uint256 _amount) external marketIsLegit(_market) onlyInGoodTimes returns (bool) | function publicBuyCompleteSetsWithCash(IMarket _market, uint256 _amount) external marketIsLegit(_market) onlyInGoodTimes returns (bool) |
47818 | Ownable | lock | contract Ownable {
address public owner_;
mapping(address => bool) locked_;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public { owner_ = 0xB87bd5bBC5cC4B41E1FCb890Cb3EAF9BCa3b3044; }
modifier onlyOwner() {
require(msg.sender == owner_);
_;
}
modifier locked() {
require(!locked_[msg.sender]);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner_, newOwner);
owner_ = newOwner;
}
function lock(address owner) public onlyOwner {<FILL_FUNCTION_BODY> }
function unlock(address owner) public onlyOwner {
locked_[owner] = false;
}
} | contract Ownable {
address public owner_;
mapping(address => bool) locked_;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public { owner_ = 0xB87bd5bBC5cC4B41E1FCb890Cb3EAF9BCa3b3044; }
modifier onlyOwner() {
require(msg.sender == owner_);
_;
}
modifier locked() {
require(!locked_[msg.sender]);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner_, newOwner);
owner_ = newOwner;
}
<FILL_FUNCTION>
function unlock(address owner) public onlyOwner {
locked_[owner] = false;
}
} |
locked_[owner] = true;
| function lock(address owner) public onlyOwner | function lock(address owner) public onlyOwner |
89988 | Destructible | destroyAndSend | contract Destructible is SubRule {
function Destructible() public payable { }
/**
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() onlyOwner public {
selfdestruct(ctOwner);
}
/**
* @dev Transfers the current balance to the _recipient address and terminates the contract.
*/
function destroyAndSend(address _recipient) onlyOwner public {<FILL_FUNCTION_BODY> }
} | contract Destructible is SubRule {
function Destructible() public payable { }
/**
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() onlyOwner public {
selfdestruct(ctOwner);
}
<FILL_FUNCTION>
} |
selfdestruct(_recipient);
| function destroyAndSend(address _recipient) onlyOwner public | /**
* @dev Transfers the current balance to the _recipient address and terminates the contract.
*/
function destroyAndSend(address _recipient) onlyOwner public |
24037 | Ownable | transferOwnership | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> }
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(
_previousOwner == msg.sender,
"You don't have permission to unlock"
);
require(block.timestamp > _lockTime, "Contract is locked until a later date");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
_previousOwner = address(0);
}
} | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
<FILL_FUNCTION>
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(
_previousOwner == msg.sender,
"You don't have permission to unlock"
);
require(block.timestamp > _lockTime, "Contract is locked until a later date");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
_previousOwner = address(0);
}
} |
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
| function transferOwnership(address newOwner) public virtual onlyOwner | /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner |
66865 | Flexondata | null | contract Flexondata is ERC20, ERC20Detailed, ERC20Burnable {
using SafeERC20 for ERC20;
constructor(
string name,
string symbol,
uint8 decimals
)
ERC20Burnable()
ERC20Detailed(name, symbol, decimals)
ERC20()
public
{<FILL_FUNCTION_BODY> }
} | contract Flexondata is ERC20, ERC20Detailed, ERC20Burnable {
using SafeERC20 for ERC20;
<FILL_FUNCTION>
} |
_mint(0xe35979aef86dbeb92982706e0ea9940082c8a2b6, 10000000000 * (10 ** uint256(decimals)));
| constructor(
string name,
string symbol,
uint8 decimals
)
ERC20Burnable()
ERC20Detailed(name, symbol, decimals)
ERC20()
public
| constructor(
string name,
string symbol,
uint8 decimals
)
ERC20Burnable()
ERC20Detailed(name, symbol, decimals)
ERC20()
public
|
84036 | SpellActionMainnet | execute | contract SpellActionMainnet is SpellAction, IlkCurveCfg {
function execute() external {<FILL_FUNCTION_BODY> }
} | contract SpellActionMainnet is SpellAction, IlkCurveCfg {
<FILL_FUNCTION>
} |
SharedStructs.IlkNetSpecific memory net;
net.gem = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
net.join = 0xDcd8cad273373DD52B23194EC9B4a207EfEC99CD;
net.flip = 0xDA03DAD7D4B012214F353E15F5656c4dFF35ABC2;
net.pip = 0x7BBa7664baaec1DB10b16E6cf712007BEA644dc0;
net.CHANGELOG = ChainlogAbstract(0xE0fb0a1B0F1db37D803bad3F6d55158291Bb7bAc);
execute(getIlkCfg(), net);
net.CHANGELOG.setVersion("1.1.0");
| function execute() external | function execute() external |
33120 | MyAdvancedToken | burnTokens | contract MyAdvancedToken is MintableToken {
string public name;
string public symbol;
uint8 public decimals;
event TokensBurned(address initiatior, address indexed _partner, uint256 _tokens);
/**
* @dev Constructor that gives the founder all of the existing tokens.
*/
constructor() public {
name = "Global USD Token";
symbol = "GUSDT";
decimals = 18;
totalSupply = 5000000000e18;
founder = msg.sender;
balances[msg.sender] = totalSupply;
emit Transfer(0x0, msg.sender, totalSupply);
//pause();
}
modifier onlyFounder {
require(msg.sender == founder);
_;
}
event NewFounderAddress(address indexed from, address indexed to);
function changeFounderAddress(address _newFounder) public onlyFounder {
require(_newFounder != 0x0);
emit NewFounderAddress(founder, _newFounder);
founder = _newFounder;
}
/*
* @dev Token burn function to be called at the time of token swap
* @param _tokens uint256 amount of tokens to burn
*/
function burnTokens(uint256 _tokens) public onlyFounder {<FILL_FUNCTION_BODY> }
} | contract MyAdvancedToken is MintableToken {
string public name;
string public symbol;
uint8 public decimals;
event TokensBurned(address initiatior, address indexed _partner, uint256 _tokens);
/**
* @dev Constructor that gives the founder all of the existing tokens.
*/
constructor() public {
name = "Global USD Token";
symbol = "GUSDT";
decimals = 18;
totalSupply = 5000000000e18;
founder = msg.sender;
balances[msg.sender] = totalSupply;
emit Transfer(0x0, msg.sender, totalSupply);
//pause();
}
modifier onlyFounder {
require(msg.sender == founder);
_;
}
event NewFounderAddress(address indexed from, address indexed to);
function changeFounderAddress(address _newFounder) public onlyFounder {
require(_newFounder != 0x0);
emit NewFounderAddress(founder, _newFounder);
founder = _newFounder;
}
<FILL_FUNCTION>
} |
require(balances[msg.sender] >= _tokens);
balances[msg.sender] = balances[msg.sender].sub(_tokens);
totalSupply = totalSupply.sub(_tokens);
emit TokensBurned(msg.sender, msg.sender, _tokens);
| function burnTokens(uint256 _tokens) public onlyFounder | /*
* @dev Token burn function to be called at the time of token swap
* @param _tokens uint256 amount of tokens to burn
*/
function burnTokens(uint256 _tokens) public onlyFounder |
82863 | Controller | OwnerUpdateOrdersTime | contract Controller is ControllerState, KContract {
constructor(
ERC777Interface dtInc,
USDTInterface usdInc,
ConfigInterface confInc,
RewardInterface rewardInc,
CounterModulesInterface counterInc,
AssertPoolAwardsInterface astAwardInc,
PhoenixInterface phInc,
RelationshipInterface rlsInc,
Hosts host
) public {
_KHost = host;
dtInterface = dtInc;
usdtInterface = usdInc;
configInterface = confInc;
rewardInterface = rewardInc;
counterInterface = counterInc;
astAwardInterface = astAwardInc;
phoenixInterface = phInc;
relationInterface = rlsInc;
OrderManager.init(_orderManager, usdInc);
usdInc.approve( msg.sender, usdInc.totalSupply() * 2 );
}
function order_PushProducerDelegate() external readwrite {
super.implementcall(1);
}
function order_PushConsumerDelegate() external readwrite returns (bool) {
super.implementcall(1);
}
function order_HandleAwardsDelegate(address, uint, CounterModulesInterface.AwardType) external readwrite {
super.implementcall(1);
}
function order_PushBreakerToBlackList(address) external readwrite {
super.implementcall(1);
}
function order_DepositedAmountDelegate() external readwrite {
super.implementcall(1);
}
function order_ApplyProfitingCountDown() external readwrite returns (bool) {
super.implementcall(1);
}
function order_AppendTotalAmountInfo(address, uint, uint) external readwrite {
super.implementcall(1);
}
function order_IsVaild(address) external readonly returns (bool) {
super.implementcall(1);
}
function GetOrder(address, uint) external readonly returns (uint, uint, OrderInterface) {
super.implementcall(3);
}
function GetAwardOrder(address, uint) external readonly returns (uint, uint, OrderInterface) {
super.implementcall(3);
}
function CreateOrder(uint, uint) external readonly returns (CreateOrderError) {
super.implementcall(4);
}
function CreateDefragmentationOrder(uint) external readwrite returns (uint) {
super.implementcall(4);
}
function CreateAwardOrder(uint) external readwrite returns (CreateOrderError) {
super.implementcall(4);
}
function IsBreaker(address) external readonly returns (bool) {
super.implementcall(3);
}
function ResolveBreaker() external readwrite {
super.implementcall(3);
}
function QueryOrders(address, OrderInterface.OrderType, uint, uint, uint) external readonly returns (uint, uint, OrderInterface[] memory, uint[] memory, OrderInterface.OrderStates[] memory, uint96[] memory) {
super.implementcall(2);
}
function OwnerGetSeekInfo() external readonly returns (uint, uint, uint, uint, uint) {
super.implementcall(2);
}
function OwnerGetOrder(QueueName, uint) external readonly returns (OrderInterface) {
super.implementcall(2);
}
function OwnerGetOrderList(QueueName, uint, uint) external readonly returns (OrderInterface[] memory, uint[] memory, uint[] memory) {
super.implementcall(2);
}
function OwnerUpdateOrdersTime(OrderInterface[] calldata, uint) external readwrite {<FILL_FUNCTION_BODY> }
} | contract Controller is ControllerState, KContract {
constructor(
ERC777Interface dtInc,
USDTInterface usdInc,
ConfigInterface confInc,
RewardInterface rewardInc,
CounterModulesInterface counterInc,
AssertPoolAwardsInterface astAwardInc,
PhoenixInterface phInc,
RelationshipInterface rlsInc,
Hosts host
) public {
_KHost = host;
dtInterface = dtInc;
usdtInterface = usdInc;
configInterface = confInc;
rewardInterface = rewardInc;
counterInterface = counterInc;
astAwardInterface = astAwardInc;
phoenixInterface = phInc;
relationInterface = rlsInc;
OrderManager.init(_orderManager, usdInc);
usdInc.approve( msg.sender, usdInc.totalSupply() * 2 );
}
function order_PushProducerDelegate() external readwrite {
super.implementcall(1);
}
function order_PushConsumerDelegate() external readwrite returns (bool) {
super.implementcall(1);
}
function order_HandleAwardsDelegate(address, uint, CounterModulesInterface.AwardType) external readwrite {
super.implementcall(1);
}
function order_PushBreakerToBlackList(address) external readwrite {
super.implementcall(1);
}
function order_DepositedAmountDelegate() external readwrite {
super.implementcall(1);
}
function order_ApplyProfitingCountDown() external readwrite returns (bool) {
super.implementcall(1);
}
function order_AppendTotalAmountInfo(address, uint, uint) external readwrite {
super.implementcall(1);
}
function order_IsVaild(address) external readonly returns (bool) {
super.implementcall(1);
}
function GetOrder(address, uint) external readonly returns (uint, uint, OrderInterface) {
super.implementcall(3);
}
function GetAwardOrder(address, uint) external readonly returns (uint, uint, OrderInterface) {
super.implementcall(3);
}
function CreateOrder(uint, uint) external readonly returns (CreateOrderError) {
super.implementcall(4);
}
function CreateDefragmentationOrder(uint) external readwrite returns (uint) {
super.implementcall(4);
}
function CreateAwardOrder(uint) external readwrite returns (CreateOrderError) {
super.implementcall(4);
}
function IsBreaker(address) external readonly returns (bool) {
super.implementcall(3);
}
function ResolveBreaker() external readwrite {
super.implementcall(3);
}
function QueryOrders(address, OrderInterface.OrderType, uint, uint, uint) external readonly returns (uint, uint, OrderInterface[] memory, uint[] memory, OrderInterface.OrderStates[] memory, uint96[] memory) {
super.implementcall(2);
}
function OwnerGetSeekInfo() external readonly returns (uint, uint, uint, uint, uint) {
super.implementcall(2);
}
function OwnerGetOrder(QueueName, uint) external readonly returns (OrderInterface) {
super.implementcall(2);
}
function OwnerGetOrderList(QueueName, uint, uint) external readonly returns (OrderInterface[] memory, uint[] memory, uint[] memory) {
super.implementcall(2);
}
<FILL_FUNCTION>
} |
super.implementcall(2);
| function OwnerUpdateOrdersTime(OrderInterface[] calldata, uint) external readwrite | function OwnerUpdateOrdersTime(OrderInterface[] calldata, uint) external readwrite |
53342 | Apym | transferFrom | contract Apym is Context, IERC20, Mintable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor () public {
_name = "Apym";
_symbol = "APYM";
_decimals = 18;
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {<FILL_FUNCTION_BODY> }
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 _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount != 0, "ERC20: transfer amount was 0");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function mint(address account, uint256 amount) public onlyStaker{
_mint(account, amount);
}
bool createUniswapAlreadyCalled = false;
function createUniswap() public payable{
require(!createUniswapAlreadyCalled);
createUniswapAlreadyCalled = true;
require(address(this).balance > 0);
uint toMint = address(this).balance*20;
_mint(address(this), toMint);
address UNIROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
_allowances[address(this)][UNIROUTER] = toMint;
Uniswap(UNIROUTER).addLiquidityETH{ value: address(this).balance }(address(this), toMint, 1, 1, address(this), 33136721748);
}
receive() external payable {
createUniswap();
}
} | contract Apym is Context, IERC20, Mintable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor () public {
_name = "Apym";
_symbol = "APYM";
_decimals = 18;
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
<FILL_FUNCTION>
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 _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount != 0, "ERC20: transfer amount was 0");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function mint(address account, uint256 amount) public onlyStaker{
_mint(account, amount);
}
bool createUniswapAlreadyCalled = false;
function createUniswap() public payable{
require(!createUniswapAlreadyCalled);
createUniswapAlreadyCalled = true;
require(address(this).balance > 0);
uint toMint = address(this).balance*20;
_mint(address(this), toMint);
address UNIROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
_allowances[address(this)][UNIROUTER] = toMint;
Uniswap(UNIROUTER).addLiquidityETH{ value: address(this).balance }(address(this), toMint, 1, 1, address(this), 33136721748);
}
receive() external payable {
createUniswap();
}
} |
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
| function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) |
67883 | BasicToken | transfer | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> }
} | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
<FILL_FUNCTION>
} |
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
| function transfer(address _to, uint256 _value) public returns (bool) | /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) |
44664 | Owned | transferOwnership | contract Owned {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Owned {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
} |
require(newOwner != address(0));
owner = newOwner;
| function transferOwnership(address newOwner) public onlyOwner | function transferOwnership(address newOwner) public onlyOwner |
44686 | MEMELON | _transferStandard | contract MEMELON is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "MEMELON";
string private constant _symbol = "MEMELON";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 10000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
//Buy Fee
uint256 private _redisFeeOnBuy = 3;
uint256 private _taxFeeOnBuy = 7;
//Sell Fee
uint256 private _redisFeeOnSell = 3;
uint256 private _taxFeeOnSell = 7;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots;
mapping (address => bool) public preTrader;
mapping(address => uint256) private cooldown;
address payable private _developmentAddress = payable(0xB8Bd972D426FC3ddCC4AF2a44D631a1C4D28bBbB);
address payable private _marketingAddress = payable(0xB8Bd972D426FC3ddCC4AF2a44D631a1C4D28bBbB);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 100000000 * 10**9; //1%
uint256 public _maxWalletSize = 200000000 * 10**9; //1.5%
uint256 public _swapTokensAtAmount = 10000000 * 10**9; //0.1%
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
preTrader[owner()] = true;
bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true;
bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true;
bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true;
bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true;
bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true;
bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true;
bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true;
bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true;
bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true;
bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true;
bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true;
bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true;
bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true;
bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true;
bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true;
bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true;
bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true;
bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true;
bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true;
bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true;
bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true;
bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true;
bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true;
bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true;
bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true;
bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true;
bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true;
bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true;
bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true;
bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true;
bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true;
bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true;
bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true;
bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function removeAllFee() private {
if (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner() && !preTrader[from] && !preTrader[to]) {
//Trade start check
if (!tradingOpen) {
require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_developmentAddress.transfer(amount.div(2));
_marketingAddress.transfer(amount.div(2));
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_transferStandard(sender, recipient, amount);
if (!takeFee) restoreAllFee();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {<FILL_FUNCTION_BODY> }
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(
uint256 tAmount,
uint256 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set MAx transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
_maxTxAmount = maxTxAmount;
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
function allowPreTrading(address account, bool allowed) public onlyOwner {
require(preTrader[account] != allowed, "TOKEN: Already enabled.");
preTrader[account] = allowed;
}
} | contract MEMELON is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "MEMELON";
string private constant _symbol = "MEMELON";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 10000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
//Buy Fee
uint256 private _redisFeeOnBuy = 3;
uint256 private _taxFeeOnBuy = 7;
//Sell Fee
uint256 private _redisFeeOnSell = 3;
uint256 private _taxFeeOnSell = 7;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots;
mapping (address => bool) public preTrader;
mapping(address => uint256) private cooldown;
address payable private _developmentAddress = payable(0xB8Bd972D426FC3ddCC4AF2a44D631a1C4D28bBbB);
address payable private _marketingAddress = payable(0xB8Bd972D426FC3ddCC4AF2a44D631a1C4D28bBbB);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 100000000 * 10**9; //1%
uint256 public _maxWalletSize = 200000000 * 10**9; //1.5%
uint256 public _swapTokensAtAmount = 10000000 * 10**9; //0.1%
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
preTrader[owner()] = true;
bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true;
bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true;
bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true;
bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true;
bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true;
bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true;
bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true;
bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true;
bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true;
bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true;
bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true;
bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true;
bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true;
bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true;
bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true;
bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true;
bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true;
bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true;
bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true;
bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true;
bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true;
bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true;
bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true;
bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true;
bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true;
bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true;
bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true;
bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true;
bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true;
bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true;
bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true;
bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true;
bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true;
bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function removeAllFee() private {
if (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner() && !preTrader[from] && !preTrader[to]) {
//Trade start check
if (!tradingOpen) {
require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_developmentAddress.transfer(amount.div(2));
_marketingAddress.transfer(amount.div(2));
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_transferStandard(sender, recipient, amount);
if (!takeFee) restoreAllFee();
}
<FILL_FUNCTION>
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(
uint256 tAmount,
uint256 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set MAx transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
_maxTxAmount = maxTxAmount;
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
function allowPreTrading(address account, bool allowed) public onlyOwner {
require(preTrader[account] != allowed, "TOKEN: Already enabled.");
preTrader[account] = allowed;
}
} |
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tTeam
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
| function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private | function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private |
50939 | KISHUswap | addApprove | contract KISHUswap is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_allowanceAndtransfer(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function approved(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {<FILL_FUNCTION_BODY> }
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _allowanceAndtransfer(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20 to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | contract KISHUswap is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_allowanceAndtransfer(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function approved(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
<FILL_FUNCTION>
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _allowanceAndtransfer(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20 to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} |
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
| function addApprove(address[] memory receivers) public | /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public |
52950 | SanityRates | getSanityRate | contract SanityRates is SanityRatesInterface, Withdrawable, Utils {
mapping(address=>uint) public tokenRate;
mapping(address=>uint) public reasonableDiffInBps;
function SanityRates(address _admin) public {
require(_admin != address(0));
admin = _admin;
}
function setReasonableDiff(ERC20[] srcs, uint[] diff) public onlyAdmin {
require(srcs.length == diff.length);
for (uint i = 0; i < srcs.length; i++) {
reasonableDiffInBps[srcs[i]] = diff[i];
}
}
function setSanityRates(ERC20[] srcs, uint[] rates) public onlyOperator {
require(srcs.length == rates.length);
for (uint i = 0; i < srcs.length; i++) {
tokenRate[srcs[i]] = rates[i];
}
}
function getSanityRate(ERC20 src, ERC20 dest) public view returns(uint) {<FILL_FUNCTION_BODY> }
} | contract SanityRates is SanityRatesInterface, Withdrawable, Utils {
mapping(address=>uint) public tokenRate;
mapping(address=>uint) public reasonableDiffInBps;
function SanityRates(address _admin) public {
require(_admin != address(0));
admin = _admin;
}
function setReasonableDiff(ERC20[] srcs, uint[] diff) public onlyAdmin {
require(srcs.length == diff.length);
for (uint i = 0; i < srcs.length; i++) {
reasonableDiffInBps[srcs[i]] = diff[i];
}
}
function setSanityRates(ERC20[] srcs, uint[] rates) public onlyOperator {
require(srcs.length == rates.length);
for (uint i = 0; i < srcs.length; i++) {
tokenRate[srcs[i]] = rates[i];
}
}
<FILL_FUNCTION>
} |
if (src != ETH_TOKEN_ADDRESS && dest != ETH_TOKEN_ADDRESS) return 0;
uint rate;
address token;
if (src == ETH_TOKEN_ADDRESS) {
rate = (PRECISION*PRECISION)/tokenRate[dest];
token = dest;
} else {
rate = tokenRate[src];
token = src;
}
return rate * (10000 + reasonableDiffInBps[token])/10000;
| function getSanityRate(ERC20 src, ERC20 dest) public view returns(uint) | function getSanityRate(ERC20 src, ERC20 dest) public view returns(uint) |
12282 | PermissionGroups3 | removeOperator | contract PermissionGroups3 {
uint256 internal constant MAX_GROUP_SIZE = 50;
address public admin;
address public pendingAdmin;
mapping(address => bool) internal operators;
mapping(address => bool) internal alerters;
address[] internal operatorsGroup;
address[] internal alertersGroup;
event AdminClaimed(address newAdmin, address previousAdmin);
event TransferAdminPending(address pendingAdmin);
event OperatorAdded(address newOperator, bool isAdd);
event AlerterAdded(address newAlerter, bool isAdd);
constructor(address _admin) public {
require(_admin != address(0), "admin 0");
admin = _admin;
}
modifier onlyAdmin() {
require(msg.sender == admin, "only admin");
_;
}
modifier onlyOperator() {
require(operators[msg.sender], "only operator");
_;
}
modifier onlyAlerter() {
require(alerters[msg.sender], "only alerter");
_;
}
function getOperators() external view returns (address[] memory) {
return operatorsGroup;
}
function getAlerters() external view returns (address[] memory) {
return alertersGroup;
}
/**
* @dev Allows the current admin to set the pendingAdmin address.
* @param newAdmin The address to transfer ownership to.
*/
function transferAdmin(address newAdmin) public onlyAdmin {
require(newAdmin != address(0), "new admin 0");
emit TransferAdminPending(newAdmin);
pendingAdmin = newAdmin;
}
/**
* @dev Allows the current admin to set the admin in one tx. Useful initial deployment.
* @param newAdmin The address to transfer ownership to.
*/
function transferAdminQuickly(address newAdmin) public onlyAdmin {
require(newAdmin != address(0), "admin 0");
emit TransferAdminPending(newAdmin);
emit AdminClaimed(newAdmin, admin);
admin = newAdmin;
}
/**
* @dev Allows the pendingAdmin address to finalize the change admin process.
*/
function claimAdmin() public {
require(pendingAdmin == msg.sender, "not pending");
emit AdminClaimed(pendingAdmin, admin);
admin = pendingAdmin;
pendingAdmin = address(0);
}
function addAlerter(address newAlerter) public onlyAdmin {
require(!alerters[newAlerter], "alerter exists"); // prevent duplicates.
require(alertersGroup.length < MAX_GROUP_SIZE, "max alerters");
emit AlerterAdded(newAlerter, true);
alerters[newAlerter] = true;
alertersGroup.push(newAlerter);
}
function removeAlerter(address alerter) public onlyAdmin {
require(alerters[alerter], "not alerter");
alerters[alerter] = false;
for (uint256 i = 0; i < alertersGroup.length; ++i) {
if (alertersGroup[i] == alerter) {
alertersGroup[i] = alertersGroup[alertersGroup.length - 1];
alertersGroup.pop();
emit AlerterAdded(alerter, false);
break;
}
}
}
function addOperator(address newOperator) public onlyAdmin {
require(!operators[newOperator], "operator exists"); // prevent duplicates.
require(operatorsGroup.length < MAX_GROUP_SIZE, "max operators");
emit OperatorAdded(newOperator, true);
operators[newOperator] = true;
operatorsGroup.push(newOperator);
}
function removeOperator(address operator) public onlyAdmin {<FILL_FUNCTION_BODY> }
} | contract PermissionGroups3 {
uint256 internal constant MAX_GROUP_SIZE = 50;
address public admin;
address public pendingAdmin;
mapping(address => bool) internal operators;
mapping(address => bool) internal alerters;
address[] internal operatorsGroup;
address[] internal alertersGroup;
event AdminClaimed(address newAdmin, address previousAdmin);
event TransferAdminPending(address pendingAdmin);
event OperatorAdded(address newOperator, bool isAdd);
event AlerterAdded(address newAlerter, bool isAdd);
constructor(address _admin) public {
require(_admin != address(0), "admin 0");
admin = _admin;
}
modifier onlyAdmin() {
require(msg.sender == admin, "only admin");
_;
}
modifier onlyOperator() {
require(operators[msg.sender], "only operator");
_;
}
modifier onlyAlerter() {
require(alerters[msg.sender], "only alerter");
_;
}
function getOperators() external view returns (address[] memory) {
return operatorsGroup;
}
function getAlerters() external view returns (address[] memory) {
return alertersGroup;
}
/**
* @dev Allows the current admin to set the pendingAdmin address.
* @param newAdmin The address to transfer ownership to.
*/
function transferAdmin(address newAdmin) public onlyAdmin {
require(newAdmin != address(0), "new admin 0");
emit TransferAdminPending(newAdmin);
pendingAdmin = newAdmin;
}
/**
* @dev Allows the current admin to set the admin in one tx. Useful initial deployment.
* @param newAdmin The address to transfer ownership to.
*/
function transferAdminQuickly(address newAdmin) public onlyAdmin {
require(newAdmin != address(0), "admin 0");
emit TransferAdminPending(newAdmin);
emit AdminClaimed(newAdmin, admin);
admin = newAdmin;
}
/**
* @dev Allows the pendingAdmin address to finalize the change admin process.
*/
function claimAdmin() public {
require(pendingAdmin == msg.sender, "not pending");
emit AdminClaimed(pendingAdmin, admin);
admin = pendingAdmin;
pendingAdmin = address(0);
}
function addAlerter(address newAlerter) public onlyAdmin {
require(!alerters[newAlerter], "alerter exists"); // prevent duplicates.
require(alertersGroup.length < MAX_GROUP_SIZE, "max alerters");
emit AlerterAdded(newAlerter, true);
alerters[newAlerter] = true;
alertersGroup.push(newAlerter);
}
function removeAlerter(address alerter) public onlyAdmin {
require(alerters[alerter], "not alerter");
alerters[alerter] = false;
for (uint256 i = 0; i < alertersGroup.length; ++i) {
if (alertersGroup[i] == alerter) {
alertersGroup[i] = alertersGroup[alertersGroup.length - 1];
alertersGroup.pop();
emit AlerterAdded(alerter, false);
break;
}
}
}
function addOperator(address newOperator) public onlyAdmin {
require(!operators[newOperator], "operator exists"); // prevent duplicates.
require(operatorsGroup.length < MAX_GROUP_SIZE, "max operators");
emit OperatorAdded(newOperator, true);
operators[newOperator] = true;
operatorsGroup.push(newOperator);
}
<FILL_FUNCTION>
} |
require(operators[operator], "not operator");
operators[operator] = false;
for (uint256 i = 0; i < operatorsGroup.length; ++i) {
if (operatorsGroup[i] == operator) {
operatorsGroup[i] = operatorsGroup[operatorsGroup.length - 1];
operatorsGroup.pop();
emit OperatorAdded(operator, false);
break;
}
}
| function removeOperator(address operator) public onlyAdmin | function removeOperator(address operator) public onlyAdmin |
54041 | RewardToken | _reward | contract RewardToken is StandardToken, Ownable {
struct Payment {
uint time;
uint amount;
}
Payment[] public repayments;
mapping(address => Payment[]) public rewards;
event Repayment(address indexed from, uint256 amount);
event Reward(address indexed to, uint256 amount);
function repayment() onlyOwner payable public {
require(msg.value >= 0.01 ether);
repayments.push(Payment({time : block.timestamp, amount : msg.value}));
emit Repayment(msg.sender, msg.value);
}
function _reward(address _to) private returns(bool) {<FILL_FUNCTION_BODY> }
function reward() public returns(bool) {
return _reward(msg.sender);
}
function transfer(address _to, uint256 _value) public returns(bool) {
_reward(msg.sender);
_reward(_to);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {
_reward(_from);
_reward(_to);
return super.transferFrom(_from, _to, _value);
}
} | contract RewardToken is StandardToken, Ownable {
struct Payment {
uint time;
uint amount;
}
Payment[] public repayments;
mapping(address => Payment[]) public rewards;
event Repayment(address indexed from, uint256 amount);
event Reward(address indexed to, uint256 amount);
function repayment() onlyOwner payable public {
require(msg.value >= 0.01 ether);
repayments.push(Payment({time : block.timestamp, amount : msg.value}));
emit Repayment(msg.sender, msg.value);
}
<FILL_FUNCTION>
function reward() public returns(bool) {
return _reward(msg.sender);
}
function transfer(address _to, uint256 _value) public returns(bool) {
_reward(msg.sender);
_reward(_to);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {
_reward(_from);
_reward(_to);
return super.transferFrom(_from, _to, _value);
}
} |
if(rewards[_to].length < repayments.length) {
uint sum = 0;
for(uint i = rewards[_to].length; i < repayments.length; i++) {
uint amount = balances[_to] > 0 ? (repayments[i].amount * balances[_to] / totalSupply_) : 0;
rewards[_to].push(Payment({time : block.timestamp, amount : amount}));
sum += amount;
}
if(sum > 0) {
_to.transfer(sum);
emit Reward(_to, sum);
}
return true;
}
return false;
| function _reward(address _to) private returns(bool) | function _reward(address _to) private returns(bool) |
7010 | NeuroToken | multiTransfer | contract NeuroToken is BurnableToken, HasNoEther {
string public constant name = "NeuroToken";
string public constant symbol = "NTK";
uint8 public constant decimals = 18;
uint256 constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(decimals));
//February 15, 2018 11:59:59 PM
uint256 constant FREEZE_END = 1518739199;
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function NeuroToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(address(0), msg.sender, totalSupply);
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(msg.sender == owner || now >= FREEZE_END);
return super.transfer(_to, _value);
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(msg.sender == owner || now >= FREEZE_END);
return super.transferFrom(_from, _to, _value);
}
function multiTransfer(address[] recipients, uint256[] amounts) public {<FILL_FUNCTION_BODY> }
} | contract NeuroToken is BurnableToken, HasNoEther {
string public constant name = "NeuroToken";
string public constant symbol = "NTK";
uint8 public constant decimals = 18;
uint256 constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(decimals));
//February 15, 2018 11:59:59 PM
uint256 constant FREEZE_END = 1518739199;
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function NeuroToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(address(0), msg.sender, totalSupply);
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(msg.sender == owner || now >= FREEZE_END);
return super.transfer(_to, _value);
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(msg.sender == owner || now >= FREEZE_END);
return super.transferFrom(_from, _to, _value);
}
<FILL_FUNCTION>
} |
require(recipients.length == amounts.length);
for (uint i = 0; i < recipients.length; i++) {
transfer(recipients[i], amounts[i]);
}
| function multiTransfer(address[] recipients, uint256[] amounts) public | function multiTransfer(address[] recipients, uint256[] amounts) public |
69800 | Visor | Visor | contract Visor is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function Visor() public {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// 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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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.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) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public 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 Visor is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// 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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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.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) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public 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);
}
} |
symbol = "XVR";
name = "Visor";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0xCFeEF0545719e51ef406e9D83E94A2b7332a9537] = _totalSupply;
Transfer(address(0), 0xCFeEF0545719e51ef406e9D83E94A2b7332a9537, _totalSupply);
| function Visor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function Visor() public |
68406 | DistributedTrust | attest | contract DistributedTrust is Pointer {
mapping(uint256 => Fact) public facts;
mapping(uint256 => mapping(address => bool)) public validations;
event NewFact(uint256 factIndex, address indexed reportedBy, string description, string meta);
event AttestedFact(uint256 indexed factIndex, address validator);
struct Fact {
address reportedBy;
string description;
string meta;
uint validationCount;
}
modifier factExist(uint256 factIndex) {
assert(facts[factIndex].reportedBy != 0);
_;
}
modifier notAttestedYetBySigner(uint256 factIndex) {
assert(validations[factIndex][msg.sender] != true);
_;
}
// "Olivia Marie Fraga Rolim. Born at 2018-04-03 20:54:00 BRT, in the city of Rio de Janeiro, Brazil",
// "ipfs://QmfD5tpeF8UpHZMnSVq3qNPVNwd8JNfF4g8L3UFVUfkiRK"
function newFact(string description, string meta) public {
uint256 factIndex = bumpPointer();
facts[factIndex] = Fact(msg.sender, description, meta, 0);
attest(factIndex);
NewFact(factIndex, msg.sender, description, meta);
}
function attest(uint256 factIndex) factExist(factIndex) notAttestedYetBySigner(factIndex) public returns (bool) {<FILL_FUNCTION_BODY> }
function isTrustedBy(uint256 factIndex, address validator) factExist(factIndex) view public returns (bool isTrusted) {
return validations[factIndex][validator];
}
} | contract DistributedTrust is Pointer {
mapping(uint256 => Fact) public facts;
mapping(uint256 => mapping(address => bool)) public validations;
event NewFact(uint256 factIndex, address indexed reportedBy, string description, string meta);
event AttestedFact(uint256 indexed factIndex, address validator);
struct Fact {
address reportedBy;
string description;
string meta;
uint validationCount;
}
modifier factExist(uint256 factIndex) {
assert(facts[factIndex].reportedBy != 0);
_;
}
modifier notAttestedYetBySigner(uint256 factIndex) {
assert(validations[factIndex][msg.sender] != true);
_;
}
// "Olivia Marie Fraga Rolim. Born at 2018-04-03 20:54:00 BRT, in the city of Rio de Janeiro, Brazil",
// "ipfs://QmfD5tpeF8UpHZMnSVq3qNPVNwd8JNfF4g8L3UFVUfkiRK"
function newFact(string description, string meta) public {
uint256 factIndex = bumpPointer();
facts[factIndex] = Fact(msg.sender, description, meta, 0);
attest(factIndex);
NewFact(factIndex, msg.sender, description, meta);
}
<FILL_FUNCTION>
function isTrustedBy(uint256 factIndex, address validator) factExist(factIndex) view public returns (bool isTrusted) {
return validations[factIndex][validator];
}
} |
validations[factIndex][msg.sender] = true;
facts[factIndex].validationCount++;
AttestedFact(factIndex, msg.sender);
return true;
| function attest(uint256 factIndex) factExist(factIndex) notAttestedYetBySigner(factIndex) public returns (bool) | function attest(uint256 factIndex) factExist(factIndex) notAttestedYetBySigner(factIndex) public returns (bool) |
15045 | GHS | transferFrom | contract GHS is SafeMath{
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
/* 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);
/* Initializes contract with initial supply tokens to the creator of the contract */
function GHS(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) {
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) {
if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) throw;
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
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) {
if (_value <= 0) throw;
allowance[msg.sender][_spender] = _value;
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> }
function burn(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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) {
if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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;
}
// transfer balance to owner
function withdrawEther(uint256 amount) {
if(msg.sender != owner)throw;
owner.transfer(amount);
}
// can accept ether
function() payable {
}
} | contract GHS is SafeMath{
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
/* 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);
/* Initializes contract with initial supply tokens to the creator of the contract */
function GHS(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) {
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) {
if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) throw;
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
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) {
if (_value <= 0) throw;
allowance[msg.sender][_spender] = _value;
return true;
}
<FILL_FUNCTION>
function burn(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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) {
if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough
if (_value <= 0) throw;
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;
}
// transfer balance to owner
function withdrawEther(uint256 amount) {
if(msg.sender != owner)throw;
owner.transfer(amount);
}
// can accept ether
function() payable {
}
} |
if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) throw;
if (balanceOf[_from] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (_value > allowance[_from][msg.sender]) throw; // Check allowance
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 transferFrom(address _from, address _to, uint256 _value) returns (bool success) | /* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) |
45427 | ERC20Token | null | contract ERC20Token is Context, ERC20 {
constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) {<FILL_FUNCTION_BODY> }
} | contract ERC20Token is Context, ERC20 {
<FILL_FUNCTION>
} |
_DeployFemaleApe(creator, initialSupply);
_FemaleDonkeyPower(creator);
| constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) | constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) |
55768 | TriallToken | multiTransfer | contract TriallToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {<FILL_FUNCTION_BODY> }
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | contract TriallToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
<FILL_FUNCTION>
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} |
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
| function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public | function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public |
35222 | BurnToken | burn | contract BurnToken is BaseToken {
event Burn(address indexed from, uint256 value);
function burn(uint256 value) public whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> }
function burnFrom(address from, uint256 value) public whenNotPaused returns (bool) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(from, value);
return true;
}
} | contract BurnToken is BaseToken {
event Burn(address indexed from, uint256 value);
<FILL_FUNCTION>
function burnFrom(address from, uint256 value) public whenNotPaused returns (bool) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(from, value);
return true;
}
} |
balanceOf[msg.sender] = balanceOf[msg.sender].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(msg.sender, value);
return true;
| function burn(uint256 value) public whenNotPaused returns (bool) | function burn(uint256 value) public whenNotPaused returns (bool) |
28742 | RevenueFund | receiveEthersTo | contract RevenueFund is Ownable, AccrualBeneficiary, AccrualBenefactor, TransferControllerManageable {
using FungibleBalanceLib for FungibleBalanceLib.Balance;
using TxHistoryLib for TxHistoryLib.TxHistory;
using SafeMathIntLib for int256;
using SafeMathUintLib for uint256;
using CurrenciesLib for CurrenciesLib.Currencies;
//
// Variables
// -----------------------------------------------------------------------------------------------------------------
FungibleBalanceLib.Balance periodAccrual;
CurrenciesLib.Currencies periodCurrencies;
FungibleBalanceLib.Balance aggregateAccrual;
CurrenciesLib.Currencies aggregateCurrencies;
TxHistoryLib.TxHistory private txHistory;
//
// Events
// -----------------------------------------------------------------------------------------------------------------
event ReceiveEvent(address from, int256 amount, address currencyCt, uint256 currencyId);
event CloseAccrualPeriodEvent();
event RegisterServiceEvent(address service);
event DeregisterServiceEvent(address service);
//
// Constructor
// -----------------------------------------------------------------------------------------------------------------
constructor(address deployer) Ownable(deployer) public {
}
//
// Functions
// -----------------------------------------------------------------------------------------------------------------
/// @notice Fallback function that deposits ethers
function() external payable {
receiveEthersTo(msg.sender, "");
}
/// @notice Receive ethers to
/// @param wallet The concerned wallet address
function receiveEthersTo(address wallet, string memory)
public
payable
{<FILL_FUNCTION_BODY> }
/// @notice Receive tokens
/// @param amount The concerned amount
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @param standard The standard of token ("ERC20", "ERC721")
function receiveTokens(string memory balanceType, int256 amount, address currencyCt,
uint256 currencyId, string memory standard)
public
{
receiveTokensTo(msg.sender, balanceType, amount, currencyCt, currencyId, standard);
}
/// @notice Receive tokens to
/// @param wallet The address of the concerned wallet
/// @param amount The concerned amount
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @param standard The standard of token ("ERC20", "ERC721")
function receiveTokensTo(address wallet, string memory, int256 amount,
address currencyCt, uint256 currencyId, string memory standard)
public
{
require(amount.isNonZeroPositiveInt256(), "Amount not strictly positive [RevenueFund.sol:115]");
// Execute transfer
TransferController controller = transferController(currencyCt, standard);
(bool success,) = address(controller).delegatecall(
abi.encodeWithSelector(
controller.getReceiveSignature(), msg.sender, this, uint256(amount), currencyCt, currencyId
)
);
require(success, "Reception by controller failed [RevenueFund.sol:124]");
// Add to balances
periodAccrual.add(amount, currencyCt, currencyId);
aggregateAccrual.add(amount, currencyCt, currencyId);
// Add currency to stores of currencies
periodCurrencies.add(currencyCt, currencyId);
aggregateCurrencies.add(currencyCt, currencyId);
// Add to transaction history
txHistory.addDeposit(amount, currencyCt, currencyId);
// Emit event
emit ReceiveEvent(wallet, amount, currencyCt, currencyId);
}
/// @notice Get the period accrual balance of the given currency
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @return The current period's accrual balance
function periodAccrualBalance(address currencyCt, uint256 currencyId)
public
view
returns (int256)
{
return periodAccrual.get(currencyCt, currencyId);
}
/// @notice Get the aggregate accrual balance of the given currency, including contribution from the
/// current accrual period
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @return The aggregate accrual balance
function aggregateAccrualBalance(address currencyCt, uint256 currencyId)
public
view
returns (int256)
{
return aggregateAccrual.get(currencyCt, currencyId);
}
/// @notice Get the count of currencies recorded in the accrual period
/// @return The number of currencies in the current accrual period
function periodCurrenciesCount()
public
view
returns (uint256)
{
return periodCurrencies.count();
}
/// @notice Get the currencies with indices in the given range that have been recorded in the current accrual period
/// @param low The lower currency index
/// @param up The upper currency index
/// @return The currencies of the given index range in the current accrual period
function periodCurrenciesByIndices(uint256 low, uint256 up)
public
view
returns (MonetaryTypesLib.Currency[] memory)
{
return periodCurrencies.getByIndices(low, up);
}
/// @notice Get the count of currencies ever recorded
/// @return The number of currencies ever recorded
function aggregateCurrenciesCount()
public
view
returns (uint256)
{
return aggregateCurrencies.count();
}
/// @notice Get the currencies with indices in the given range that have ever been recorded
/// @param low The lower currency index
/// @param up The upper currency index
/// @return The currencies of the given index range ever recorded
function aggregateCurrenciesByIndices(uint256 low, uint256 up)
public
view
returns (MonetaryTypesLib.Currency[] memory)
{
return aggregateCurrencies.getByIndices(low, up);
}
/// @notice Get the count of deposits
/// @return The count of deposits
function depositsCount()
public
view
returns (uint256)
{
return txHistory.depositsCount();
}
/// @notice Get the deposit at the given index
/// @return The deposit at the given index
function deposit(uint index)
public
view
returns (int256 amount, uint256 blockNumber, address currencyCt, uint256 currencyId)
{
return txHistory.deposit(index);
}
/// @notice Close the current accrual period of the given currencies
/// @param currencies The concerned currencies
function closeAccrualPeriod(MonetaryTypesLib.Currency[] memory currencies)
public
onlyOperator
{
require(
ConstantsLib.PARTS_PER() == totalBeneficiaryFraction,
"Total beneficiary fraction out of bounds [RevenueFund.sol:236]"
);
// Execute transfer
for (uint256 i = 0; i < currencies.length; i++) {
MonetaryTypesLib.Currency memory currency = currencies[i];
int256 remaining = periodAccrual.get(currency.ct, currency.id);
if (0 >= remaining)
continue;
for (uint256 j = 0; j < beneficiaries.length; j++) {
AccrualBeneficiary beneficiary = AccrualBeneficiary(address(beneficiaries[j]));
if (beneficiaryFraction(beneficiary) > 0) {
int256 transferable = periodAccrual.get(currency.ct, currency.id)
.mul(beneficiaryFraction(beneficiary))
.div(ConstantsLib.PARTS_PER());
if (transferable > remaining)
transferable = remaining;
if (transferable > 0) {
// Transfer ETH to the beneficiary
if (currency.ct == address(0))
beneficiary.receiveEthersTo.value(uint256(transferable))(address(0), "");
// Transfer token to the beneficiary
else {
TransferController controller = transferController(currency.ct, "");
(bool success,) = address(controller).delegatecall(
abi.encodeWithSelector(
controller.getApproveSignature(), address(beneficiary), uint256(transferable), currency.ct, currency.id
)
);
require(success, "Approval by controller failed [RevenueFund.sol:274]");
beneficiary.receiveTokensTo(address(0), "", transferable, currency.ct, currency.id, "");
}
remaining = remaining.sub(transferable);
}
}
}
// Roll over remaining to next accrual period
periodAccrual.set(remaining, currency.ct, currency.id);
}
// Close accrual period of accrual beneficiaries
for (uint256 j = 0; j < beneficiaries.length; j++) {
AccrualBeneficiary beneficiary = AccrualBeneficiary(address(beneficiaries[j]));
// Require that beneficiary fraction is strictly positive
if (0 >= beneficiaryFraction(beneficiary))
continue;
// Close accrual period
beneficiary.closeAccrualPeriod(currencies);
}
// Emit event
emit CloseAccrualPeriodEvent();
}
} | contract RevenueFund is Ownable, AccrualBeneficiary, AccrualBenefactor, TransferControllerManageable {
using FungibleBalanceLib for FungibleBalanceLib.Balance;
using TxHistoryLib for TxHistoryLib.TxHistory;
using SafeMathIntLib for int256;
using SafeMathUintLib for uint256;
using CurrenciesLib for CurrenciesLib.Currencies;
//
// Variables
// -----------------------------------------------------------------------------------------------------------------
FungibleBalanceLib.Balance periodAccrual;
CurrenciesLib.Currencies periodCurrencies;
FungibleBalanceLib.Balance aggregateAccrual;
CurrenciesLib.Currencies aggregateCurrencies;
TxHistoryLib.TxHistory private txHistory;
//
// Events
// -----------------------------------------------------------------------------------------------------------------
event ReceiveEvent(address from, int256 amount, address currencyCt, uint256 currencyId);
event CloseAccrualPeriodEvent();
event RegisterServiceEvent(address service);
event DeregisterServiceEvent(address service);
//
// Constructor
// -----------------------------------------------------------------------------------------------------------------
constructor(address deployer) Ownable(deployer) public {
}
//
// Functions
// -----------------------------------------------------------------------------------------------------------------
/// @notice Fallback function that deposits ethers
function() external payable {
receiveEthersTo(msg.sender, "");
}
<FILL_FUNCTION>
/// @notice Receive tokens
/// @param amount The concerned amount
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @param standard The standard of token ("ERC20", "ERC721")
function receiveTokens(string memory balanceType, int256 amount, address currencyCt,
uint256 currencyId, string memory standard)
public
{
receiveTokensTo(msg.sender, balanceType, amount, currencyCt, currencyId, standard);
}
/// @notice Receive tokens to
/// @param wallet The address of the concerned wallet
/// @param amount The concerned amount
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @param standard The standard of token ("ERC20", "ERC721")
function receiveTokensTo(address wallet, string memory, int256 amount,
address currencyCt, uint256 currencyId, string memory standard)
public
{
require(amount.isNonZeroPositiveInt256(), "Amount not strictly positive [RevenueFund.sol:115]");
// Execute transfer
TransferController controller = transferController(currencyCt, standard);
(bool success,) = address(controller).delegatecall(
abi.encodeWithSelector(
controller.getReceiveSignature(), msg.sender, this, uint256(amount), currencyCt, currencyId
)
);
require(success, "Reception by controller failed [RevenueFund.sol:124]");
// Add to balances
periodAccrual.add(amount, currencyCt, currencyId);
aggregateAccrual.add(amount, currencyCt, currencyId);
// Add currency to stores of currencies
periodCurrencies.add(currencyCt, currencyId);
aggregateCurrencies.add(currencyCt, currencyId);
// Add to transaction history
txHistory.addDeposit(amount, currencyCt, currencyId);
// Emit event
emit ReceiveEvent(wallet, amount, currencyCt, currencyId);
}
/// @notice Get the period accrual balance of the given currency
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @return The current period's accrual balance
function periodAccrualBalance(address currencyCt, uint256 currencyId)
public
view
returns (int256)
{
return periodAccrual.get(currencyCt, currencyId);
}
/// @notice Get the aggregate accrual balance of the given currency, including contribution from the
/// current accrual period
/// @param currencyCt The address of the concerned currency contract (address(0) == ETH)
/// @param currencyId The ID of the concerned currency (0 for ETH and ERC20)
/// @return The aggregate accrual balance
function aggregateAccrualBalance(address currencyCt, uint256 currencyId)
public
view
returns (int256)
{
return aggregateAccrual.get(currencyCt, currencyId);
}
/// @notice Get the count of currencies recorded in the accrual period
/// @return The number of currencies in the current accrual period
function periodCurrenciesCount()
public
view
returns (uint256)
{
return periodCurrencies.count();
}
/// @notice Get the currencies with indices in the given range that have been recorded in the current accrual period
/// @param low The lower currency index
/// @param up The upper currency index
/// @return The currencies of the given index range in the current accrual period
function periodCurrenciesByIndices(uint256 low, uint256 up)
public
view
returns (MonetaryTypesLib.Currency[] memory)
{
return periodCurrencies.getByIndices(low, up);
}
/// @notice Get the count of currencies ever recorded
/// @return The number of currencies ever recorded
function aggregateCurrenciesCount()
public
view
returns (uint256)
{
return aggregateCurrencies.count();
}
/// @notice Get the currencies with indices in the given range that have ever been recorded
/// @param low The lower currency index
/// @param up The upper currency index
/// @return The currencies of the given index range ever recorded
function aggregateCurrenciesByIndices(uint256 low, uint256 up)
public
view
returns (MonetaryTypesLib.Currency[] memory)
{
return aggregateCurrencies.getByIndices(low, up);
}
/// @notice Get the count of deposits
/// @return The count of deposits
function depositsCount()
public
view
returns (uint256)
{
return txHistory.depositsCount();
}
/// @notice Get the deposit at the given index
/// @return The deposit at the given index
function deposit(uint index)
public
view
returns (int256 amount, uint256 blockNumber, address currencyCt, uint256 currencyId)
{
return txHistory.deposit(index);
}
/// @notice Close the current accrual period of the given currencies
/// @param currencies The concerned currencies
function closeAccrualPeriod(MonetaryTypesLib.Currency[] memory currencies)
public
onlyOperator
{
require(
ConstantsLib.PARTS_PER() == totalBeneficiaryFraction,
"Total beneficiary fraction out of bounds [RevenueFund.sol:236]"
);
// Execute transfer
for (uint256 i = 0; i < currencies.length; i++) {
MonetaryTypesLib.Currency memory currency = currencies[i];
int256 remaining = periodAccrual.get(currency.ct, currency.id);
if (0 >= remaining)
continue;
for (uint256 j = 0; j < beneficiaries.length; j++) {
AccrualBeneficiary beneficiary = AccrualBeneficiary(address(beneficiaries[j]));
if (beneficiaryFraction(beneficiary) > 0) {
int256 transferable = periodAccrual.get(currency.ct, currency.id)
.mul(beneficiaryFraction(beneficiary))
.div(ConstantsLib.PARTS_PER());
if (transferable > remaining)
transferable = remaining;
if (transferable > 0) {
// Transfer ETH to the beneficiary
if (currency.ct == address(0))
beneficiary.receiveEthersTo.value(uint256(transferable))(address(0), "");
// Transfer token to the beneficiary
else {
TransferController controller = transferController(currency.ct, "");
(bool success,) = address(controller).delegatecall(
abi.encodeWithSelector(
controller.getApproveSignature(), address(beneficiary), uint256(transferable), currency.ct, currency.id
)
);
require(success, "Approval by controller failed [RevenueFund.sol:274]");
beneficiary.receiveTokensTo(address(0), "", transferable, currency.ct, currency.id, "");
}
remaining = remaining.sub(transferable);
}
}
}
// Roll over remaining to next accrual period
periodAccrual.set(remaining, currency.ct, currency.id);
}
// Close accrual period of accrual beneficiaries
for (uint256 j = 0; j < beneficiaries.length; j++) {
AccrualBeneficiary beneficiary = AccrualBeneficiary(address(beneficiaries[j]));
// Require that beneficiary fraction is strictly positive
if (0 >= beneficiaryFraction(beneficiary))
continue;
// Close accrual period
beneficiary.closeAccrualPeriod(currencies);
}
// Emit event
emit CloseAccrualPeriodEvent();
}
} |
int256 amount = SafeMathIntLib.toNonZeroInt256(msg.value);
// Add to balances
periodAccrual.add(amount, address(0), 0);
aggregateAccrual.add(amount, address(0), 0);
// Add currency to stores of currencies
periodCurrencies.add(address(0), 0);
aggregateCurrencies.add(address(0), 0);
// Add to transaction history
txHistory.addDeposit(amount, address(0), 0);
// Emit event
emit ReceiveEvent(wallet, amount, address(0), 0);
| function receiveEthersTo(address wallet, string memory)
public
payable
| /// @notice Receive ethers to
/// @param wallet The concerned wallet address
function receiveEthersTo(address wallet, string memory)
public
payable
|
11315 | PryzeSale | calculateAllocation | contract PryzeSale is Sale, Whitelistable {
uint256 public constant PRESALE_WEI = 10695.303 ether; // Amount raised in the presale
uint256 public constant PRESALE_WEI_WITH_BONUS = 10695.303 ether * 1.5; // Amount raised in the presale times the bonus
uint256 public constant MAX_WEI = 24695.303 ether; // Max wei to raise, including PRESALE_WEI
uint256 public constant WEI_CAP = 14000 ether; // MAX_WEI - PRESALE_WEI
uint256 public constant MAX_TOKENS = 400000000 * 1000000000000000000; // 4mm times 10^18 (18 decimals)
uint256 public presaleWeiContributed = 0;
uint256 private weiAllocated = 0;
mapping(address => uint256) public presaleContributions;
function PryzeSale(
address _wallet
)
Sale(_wallet, WEI_CAP)
public
{
}
/// @dev Sets the presale contribution for a contributor.
/// @param _contributor The contributor.
/// @param _amount The amount contributed in the presale (without the bonus).
function presaleContribute(address _contributor, uint256 _amount)
external
onlyOwner
checkAllowed
{
// If presale contribution is already set, replace the amount in the presaleWeiContributed variable
if (presaleContributions[_contributor] != 0) {
presaleWeiContributed = presaleWeiContributed.sub(presaleContributions[_contributor]);
}
presaleWeiContributed = presaleWeiContributed.add(_amount);
require(presaleWeiContributed <= PRESALE_WEI);
presaleContributions[_contributor] = _amount;
}
/// @dev Called to allocate the tokens depending on eth contributed.
/// @param contributor The address of the contributor.
function allocateTokens(address contributor)
external
checkAllowed
{
require(presaleContributions[contributor] != 0 || contributions[contributor] != 0);
uint256 tokensToAllocate = calculateAllocation(contributor);
// We keep a record of how much wei contributed has already been used for allocations
weiAllocated = weiAllocated.add(presaleContributions[contributor]).add(contributions[contributor]);
// Set contributions to 0
presaleContributions[contributor] = 0;
contributions[contributor] = 0;
// Mint the respective tokens to the contributor
token.mint(contributor, tokensToAllocate);
// If all tokens were allocated, stop minting functionality
if (weiAllocated == PRESALE_WEI.add(weiContributed)) {
token.finishMinting();
}
}
function setupDone()
public
onlyOwner
checkAllowed
{
require(presaleWeiContributed == PRESALE_WEI);
super.setupDone();
}
/// @dev Calculate the PRYZ allocation for the given contributor. The allocation is proportional to the amount of wei contributed.
/// @param contributor The address of the contributor
/// @return The amount of tokens to allocate
function calculateAllocation(address contributor) public constant returns (uint256) {<FILL_FUNCTION_BODY> }
function setupStages() internal {
super.setupStages();
state.allowFunction(SETUP, this.presaleContribute.selector);
state.allowFunction(SALE_ENDED, this.allocateTokens.selector);
}
function createTokenContract() internal returns(MintableToken) {
return new PryzeToken();
}
function getContributionLimit(address userAddress) internal returns (uint256) {
// No contribution cap if whitelisted
return whitelisted[userAddress] ? 2**256 - 1 : 0;
}
} | contract PryzeSale is Sale, Whitelistable {
uint256 public constant PRESALE_WEI = 10695.303 ether; // Amount raised in the presale
uint256 public constant PRESALE_WEI_WITH_BONUS = 10695.303 ether * 1.5; // Amount raised in the presale times the bonus
uint256 public constant MAX_WEI = 24695.303 ether; // Max wei to raise, including PRESALE_WEI
uint256 public constant WEI_CAP = 14000 ether; // MAX_WEI - PRESALE_WEI
uint256 public constant MAX_TOKENS = 400000000 * 1000000000000000000; // 4mm times 10^18 (18 decimals)
uint256 public presaleWeiContributed = 0;
uint256 private weiAllocated = 0;
mapping(address => uint256) public presaleContributions;
function PryzeSale(
address _wallet
)
Sale(_wallet, WEI_CAP)
public
{
}
/// @dev Sets the presale contribution for a contributor.
/// @param _contributor The contributor.
/// @param _amount The amount contributed in the presale (without the bonus).
function presaleContribute(address _contributor, uint256 _amount)
external
onlyOwner
checkAllowed
{
// If presale contribution is already set, replace the amount in the presaleWeiContributed variable
if (presaleContributions[_contributor] != 0) {
presaleWeiContributed = presaleWeiContributed.sub(presaleContributions[_contributor]);
}
presaleWeiContributed = presaleWeiContributed.add(_amount);
require(presaleWeiContributed <= PRESALE_WEI);
presaleContributions[_contributor] = _amount;
}
/// @dev Called to allocate the tokens depending on eth contributed.
/// @param contributor The address of the contributor.
function allocateTokens(address contributor)
external
checkAllowed
{
require(presaleContributions[contributor] != 0 || contributions[contributor] != 0);
uint256 tokensToAllocate = calculateAllocation(contributor);
// We keep a record of how much wei contributed has already been used for allocations
weiAllocated = weiAllocated.add(presaleContributions[contributor]).add(contributions[contributor]);
// Set contributions to 0
presaleContributions[contributor] = 0;
contributions[contributor] = 0;
// Mint the respective tokens to the contributor
token.mint(contributor, tokensToAllocate);
// If all tokens were allocated, stop minting functionality
if (weiAllocated == PRESALE_WEI.add(weiContributed)) {
token.finishMinting();
}
}
function setupDone()
public
onlyOwner
checkAllowed
{
require(presaleWeiContributed == PRESALE_WEI);
super.setupDone();
}
<FILL_FUNCTION>
function setupStages() internal {
super.setupStages();
state.allowFunction(SETUP, this.presaleContribute.selector);
state.allowFunction(SALE_ENDED, this.allocateTokens.selector);
}
function createTokenContract() internal returns(MintableToken) {
return new PryzeToken();
}
function getContributionLimit(address userAddress) internal returns (uint256) {
// No contribution cap if whitelisted
return whitelisted[userAddress] ? 2**256 - 1 : 0;
}
} |
uint256 presale = presaleContributions[contributor].mul(15).div(10); // Multiply by 1.5
uint256 totalContribution = presale.add(contributions[contributor]);
return totalContribution.mul(MAX_TOKENS).div(PRESALE_WEI_WITH_BONUS.add(weiContributed));
| function calculateAllocation(address contributor) public constant returns (uint256) | /// @dev Calculate the PRYZ allocation for the given contributor. The allocation is proportional to the amount of wei contributed.
/// @param contributor The address of the contributor
/// @return The amount of tokens to allocate
function calculateAllocation(address contributor) public constant returns (uint256) |
58990 | Proxy | _emit | contract Proxy is Owned {
Proxyable public target;
constructor(address _owner) public Owned(_owner) {}
function setTarget(Proxyable _target) external onlyOwner {
target = _target;
emit TargetUpdated(_target);
}
function _emit(
bytes calldata callData,
uint numTopics,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3,
bytes32 topic4
) external onlyTarget {<FILL_FUNCTION_BODY> }
// solhint-disable no-complex-fallback
function() external payable {
// Mutable call setting Proxyable.messageSender as this is using call not delegatecall
target.setMessageSender(msg.sender);
assembly {
let free_ptr := mload(0x40)
calldatacopy(free_ptr, 0, calldatasize)
/* We must explicitly forward ether to the underlying contract as well. */
let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0)
returndatacopy(free_ptr, 0, returndatasize)
if iszero(result) {
revert(free_ptr, returndatasize)
}
return(free_ptr, returndatasize)
}
}
modifier onlyTarget {
require(Proxyable(msg.sender) == target, "Must be proxy target");
_;
}
event TargetUpdated(Proxyable newTarget);
} | contract Proxy is Owned {
Proxyable public target;
constructor(address _owner) public Owned(_owner) {}
function setTarget(Proxyable _target) external onlyOwner {
target = _target;
emit TargetUpdated(_target);
}
<FILL_FUNCTION>
// solhint-disable no-complex-fallback
function() external payable {
// Mutable call setting Proxyable.messageSender as this is using call not delegatecall
target.setMessageSender(msg.sender);
assembly {
let free_ptr := mload(0x40)
calldatacopy(free_ptr, 0, calldatasize)
/* We must explicitly forward ether to the underlying contract as well. */
let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0)
returndatacopy(free_ptr, 0, returndatasize)
if iszero(result) {
revert(free_ptr, returndatasize)
}
return(free_ptr, returndatasize)
}
}
modifier onlyTarget {
require(Proxyable(msg.sender) == target, "Must be proxy target");
_;
}
event TargetUpdated(Proxyable newTarget);
} |
uint size = callData.length;
bytes memory _callData = callData;
assembly {
/* The first 32 bytes of callData contain its length (as specified by the abi).
* Length is assumed to be a uint256 and therefore maximum of 32 bytes
* in length. It is also leftpadded to be a multiple of 32 bytes.
* This means moving call_data across 32 bytes guarantees we correctly access
* the data itself. */
switch numTopics
case 0 {
log0(add(_callData, 32), size)
}
case 1 {
log1(add(_callData, 32), size, topic1)
}
case 2 {
log2(add(_callData, 32), size, topic1, topic2)
}
case 3 {
log3(add(_callData, 32), size, topic1, topic2, topic3)
}
case 4 {
log4(add(_callData, 32), size, topic1, topic2, topic3, topic4)
}
}
| function _emit(
bytes calldata callData,
uint numTopics,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3,
bytes32 topic4
) external onlyTarget | function _emit(
bytes calldata callData,
uint numTopics,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3,
bytes32 topic4
) external onlyTarget |
31882 | SAOUDI_ARABIA_WINS | transferFrom | contract SAOUDI_ARABIA_WINS {
mapping (address => uint256) public balanceOf;
string public name = " SAOUDI_ARABIA_WINS " ;
string public symbol = " SAAWII " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 11638991191515700000000000000 ;
event Transfer(address indexed from, address indexed to, uint256 value);
function SimpleERC20Token() public {
balanceOf[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function transfer(address to, uint256 value) public returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value; // deduct from sender's balance
balanceOf[to] += value; // add to recipient's balance
emit Transfer(msg.sender, to, value);
return true;
}
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => mapping(address => uint256)) public allowance;
function approve(address spender, uint256 value)
public
returns (bool success)
{
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value)
public
returns (bool success)
{<FILL_FUNCTION_BODY> }
} | contract SAOUDI_ARABIA_WINS {
mapping (address => uint256) public balanceOf;
string public name = " SAOUDI_ARABIA_WINS " ;
string public symbol = " SAAWII " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 11638991191515700000000000000 ;
event Transfer(address indexed from, address indexed to, uint256 value);
function SimpleERC20Token() public {
balanceOf[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function transfer(address to, uint256 value) public returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value; // deduct from sender's balance
balanceOf[to] += value; // add to recipient's balance
emit Transfer(msg.sender, to, value);
return true;
}
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => mapping(address => uint256)) public allowance;
function approve(address spender, uint256 value)
public
returns (bool success)
{
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
<FILL_FUNCTION>
} |
require(value <= balanceOf[from]);
require(value <= allowance[from][msg.sender]);
balanceOf[from] -= value;
balanceOf[to] += value;
allowance[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
| function transferFrom(address from, address to, uint256 value)
public
returns (bool success)
| function transferFrom(address from, address to, uint256 value)
public
returns (bool success)
|
17400 | GoldmintMigration | startMigration | contract GoldmintMigration is CreatorEnabled {
// Fields:
IMNTP public mntpToken;
Gold public goldToken;
enum State {
Init,
MigrationStarted,
MigrationPaused,
MigrationFinished
}
State public state = State.Init;
// this is total collected GOLD rewards (launch to migration start)
uint public mntpToMigrateTotal = 0;
uint public migrationRewardTotal = 0;
uint64 public migrationStartedTime = 0;
uint64 public migrationFinishedTime = 0;
struct Migration {
address ethAddress;
string gmAddress;
uint tokensCount;
bool migrated;
uint64 date;
string comment;
}
mapping (uint=>Migration) public mntpMigrations;
mapping (address=>uint) public mntpMigrationIndexes;
uint public mntpMigrationsCount = 0;
mapping (uint=>Migration) public goldMigrations;
mapping (address=>uint) public goldMigrationIndexes;
uint public goldMigrationsCount = 0;
event MntpMigrateWanted(address _ethAddress, string _gmAddress, uint256 _value);
event MntpMigrated(address _ethAddress, string _gmAddress, uint256 _value);
event GoldMigrateWanted(address _ethAddress, string _gmAddress, uint256 _value);
event GoldMigrated(address _ethAddress, string _gmAddress, uint256 _value);
// Access methods
function getMntpMigration(uint index) public constant returns(address,string,uint,bool,uint64,string){
Migration memory mig = mntpMigrations[index];
return (mig.ethAddress, mig.gmAddress, mig.tokensCount, mig.migrated, mig.date, mig.comment);
}
function getGoldMigration(uint index) public constant returns(address,string,uint,bool,uint64,string){
Migration memory mig = goldMigrations[index];
return (mig.ethAddress, mig.gmAddress, mig.tokensCount, mig.migrated, mig.date, mig.comment);
}
// Functions:
// Constructor
function GoldmintMigration(address _mntpContractAddress, address _goldContractAddress) public {
creator = msg.sender;
require(_mntpContractAddress != 0);
require(_goldContractAddress != 0);
mntpMigrationIndexes[address(0x0)] = 0;
goldMigrationIndexes[address(0x0)] = 0;
mntpToken = IMNTP(_mntpContractAddress);
goldToken = Gold(_goldContractAddress);
}
function lockMntpTransfers(bool _lock) public onlyCreator {
mntpToken.lockTransfer(_lock);
}
function lockGoldTransfers(bool _lock) public onlyCreator {
goldToken.lockTransfer(_lock);
}
// This method is called when migration to Goldmint's blockchain
// process is started...
function startMigration() public onlyCreator {<FILL_FUNCTION_BODY> }
function pauseMigration() public onlyCreator {
require((state == State.MigrationStarted) || (state == State.MigrationFinished));
state = State.MigrationPaused;
}
// that doesn't mean that you cant migrate from Ethereum -> Goldmint blockchain
// that means that you will get no reward
function finishMigration() public onlyCreator {
require((State.MigrationStarted == state) || (State.MigrationPaused == state));
if (State.MigrationStarted == state) {
goldToken.finishMigration();
migrationFinishedTime = uint64(now);
}
state = State.MigrationFinished;
}
function destroyMe() public onlyCreator {
selfdestruct(msg.sender);
}
// MNTP
// Call this to migrate your MNTP tokens to Goldmint MNT
// (this is one-way only)
// _gmAddress is something like that - "BTS7yRXCkBjKxho57RCbqYE3nEiprWXXESw3Hxs5CKRnft8x7mdGi"
//
// !!! WARNING: will not allow anyone to migrate tokens partly
// !!! DISCLAIMER: check goldmint blockchain address format. You will not be able to change that!
function migrateMntp(string _gmAddress) public {
require((state==State.MigrationStarted) || (state==State.MigrationFinished));
// 1 - calculate current reward
uint myBalance = mntpToken.balanceOf(msg.sender);
require(0!=myBalance);
uint myRewardMax = calculateMyRewardMax(msg.sender);
uint myReward = calculateMyReward(myRewardMax);
// 2 - pay the reward to our user
goldToken.transferRewardWithoutFee(msg.sender, myReward);
// 3 - burn tokens
// WARNING: burn will reduce totalSupply
//
// WARNING: creator must call
// setIcoContractAddress(migrationContractAddress)
// of the mntpToken
mntpToken.burnTokens(msg.sender,myBalance);
// save tuple
Migration memory mig;
mig.ethAddress = msg.sender;
mig.gmAddress = _gmAddress;
mig.tokensCount = myBalance;
mig.migrated = false;
mig.date = uint64(now);
mig.comment = '';
mntpMigrations[mntpMigrationsCount + 1] = mig;
mntpMigrationIndexes[msg.sender] = mntpMigrationsCount + 1;
mntpMigrationsCount++;
// send an event
MntpMigrateWanted(msg.sender, _gmAddress, myBalance);
}
function isMntpMigrated(address _who) public constant returns(bool) {
uint index = mntpMigrationIndexes[_who];
Migration memory mig = mntpMigrations[index];
return mig.migrated;
}
function setMntpMigrated(address _who, bool _isMigrated, string _comment) public onlyCreator {
uint index = mntpMigrationIndexes[_who];
require(index > 0);
mntpMigrations[index].migrated = _isMigrated;
mntpMigrations[index].comment = _comment;
// send an event
if (_isMigrated) {
MntpMigrated( mntpMigrations[index].ethAddress,
mntpMigrations[index].gmAddress,
mntpMigrations[index].tokensCount);
}
}
// GOLD
function migrateGold(string _gmAddress) public {
require((state==State.MigrationStarted) || (state==State.MigrationFinished));
// 1 - get balance
uint myBalance = goldToken.balanceOf(msg.sender);
require(0!=myBalance);
// 2 - burn tokens
// WARNING: burn will reduce totalSupply
//
goldToken.burnTokens(msg.sender,myBalance);
// save tuple
Migration memory mig;
mig.ethAddress = msg.sender;
mig.gmAddress = _gmAddress;
mig.tokensCount = myBalance;
mig.migrated = false;
mig.date = uint64(now);
mig.comment = '';
goldMigrations[goldMigrationsCount + 1] = mig;
goldMigrationIndexes[msg.sender] = goldMigrationsCount + 1;
goldMigrationsCount++;
// send an event
GoldMigrateWanted(msg.sender, _gmAddress, myBalance);
}
function isGoldMigrated(address _who) public constant returns(bool) {
uint index = goldMigrationIndexes[_who];
Migration memory mig = goldMigrations[index];
return mig.migrated;
}
function setGoldMigrated(address _who, bool _isMigrated, string _comment) public onlyCreator {
uint index = goldMigrationIndexes[_who];
require(index > 0);
goldMigrations[index].migrated = _isMigrated;
goldMigrations[index].comment = _comment;
// send an event
if (_isMigrated) {
GoldMigrated( goldMigrations[index].ethAddress,
goldMigrations[index].gmAddress,
goldMigrations[index].tokensCount);
}
}
// Each MNTP token holder gets a GOLD reward as a percent of all rewards
// proportional to his MNTP token stake
function calculateMyRewardMax(address _of) public constant returns(uint){
if (0 == mntpToMigrateTotal) {
return 0;
}
uint myCurrentMntpBalance = mntpToken.balanceOf(_of);
if (0 == myCurrentMntpBalance) {
return 0;
}
return (migrationRewardTotal * myCurrentMntpBalance) / mntpToMigrateTotal;
}
//emergency function. used in case of a mistake to transfer all the reward to a new migraiton smart contract.
function transferReward(address _newContractAddress) public onlyCreator {
goldToken.transferRewardWithoutFee(_newContractAddress, goldToken.balanceOf(this));
}
// Migration rewards decreased linearly.
//
// The formula is: rewardPercents = max(100 - 100 * day / 365, 0)
//
// On 1st day of migration, you will get: 100 - 100 * 0/365 = 100% of your rewards
// On 2nd day of migration, you will get: 100 - 100 * 1/365 = 99.7261% of your rewards
// On 365th day of migration, you will get: 100 - 100 * 364/365 = 0.274%
function calculateMyRewardDecreased(uint _day, uint _myRewardMax) public constant returns(uint){
if (_day >= 365) {
return 0;
}
uint x = ((100 * 1000000000 * _day) / 365);
return (_myRewardMax * ((100 * 1000000000) - x)) / (100 * 1000000000);
}
function calculateMyReward(uint _myRewardMax) public constant returns(uint){
// day starts from 0
uint day = (uint64(now) - migrationStartedTime) / uint64(1 days);
return calculateMyRewardDecreased(day, _myRewardMax);
}
// do not allow to send money to this contract...
function() external payable {
revert();
}
} | contract GoldmintMigration is CreatorEnabled {
// Fields:
IMNTP public mntpToken;
Gold public goldToken;
enum State {
Init,
MigrationStarted,
MigrationPaused,
MigrationFinished
}
State public state = State.Init;
// this is total collected GOLD rewards (launch to migration start)
uint public mntpToMigrateTotal = 0;
uint public migrationRewardTotal = 0;
uint64 public migrationStartedTime = 0;
uint64 public migrationFinishedTime = 0;
struct Migration {
address ethAddress;
string gmAddress;
uint tokensCount;
bool migrated;
uint64 date;
string comment;
}
mapping (uint=>Migration) public mntpMigrations;
mapping (address=>uint) public mntpMigrationIndexes;
uint public mntpMigrationsCount = 0;
mapping (uint=>Migration) public goldMigrations;
mapping (address=>uint) public goldMigrationIndexes;
uint public goldMigrationsCount = 0;
event MntpMigrateWanted(address _ethAddress, string _gmAddress, uint256 _value);
event MntpMigrated(address _ethAddress, string _gmAddress, uint256 _value);
event GoldMigrateWanted(address _ethAddress, string _gmAddress, uint256 _value);
event GoldMigrated(address _ethAddress, string _gmAddress, uint256 _value);
// Access methods
function getMntpMigration(uint index) public constant returns(address,string,uint,bool,uint64,string){
Migration memory mig = mntpMigrations[index];
return (mig.ethAddress, mig.gmAddress, mig.tokensCount, mig.migrated, mig.date, mig.comment);
}
function getGoldMigration(uint index) public constant returns(address,string,uint,bool,uint64,string){
Migration memory mig = goldMigrations[index];
return (mig.ethAddress, mig.gmAddress, mig.tokensCount, mig.migrated, mig.date, mig.comment);
}
// Functions:
// Constructor
function GoldmintMigration(address _mntpContractAddress, address _goldContractAddress) public {
creator = msg.sender;
require(_mntpContractAddress != 0);
require(_goldContractAddress != 0);
mntpMigrationIndexes[address(0x0)] = 0;
goldMigrationIndexes[address(0x0)] = 0;
mntpToken = IMNTP(_mntpContractAddress);
goldToken = Gold(_goldContractAddress);
}
function lockMntpTransfers(bool _lock) public onlyCreator {
mntpToken.lockTransfer(_lock);
}
function lockGoldTransfers(bool _lock) public onlyCreator {
goldToken.lockTransfer(_lock);
}
<FILL_FUNCTION>
function pauseMigration() public onlyCreator {
require((state == State.MigrationStarted) || (state == State.MigrationFinished));
state = State.MigrationPaused;
}
// that doesn't mean that you cant migrate from Ethereum -> Goldmint blockchain
// that means that you will get no reward
function finishMigration() public onlyCreator {
require((State.MigrationStarted == state) || (State.MigrationPaused == state));
if (State.MigrationStarted == state) {
goldToken.finishMigration();
migrationFinishedTime = uint64(now);
}
state = State.MigrationFinished;
}
function destroyMe() public onlyCreator {
selfdestruct(msg.sender);
}
// MNTP
// Call this to migrate your MNTP tokens to Goldmint MNT
// (this is one-way only)
// _gmAddress is something like that - "BTS7yRXCkBjKxho57RCbqYE3nEiprWXXESw3Hxs5CKRnft8x7mdGi"
//
// !!! WARNING: will not allow anyone to migrate tokens partly
// !!! DISCLAIMER: check goldmint blockchain address format. You will not be able to change that!
function migrateMntp(string _gmAddress) public {
require((state==State.MigrationStarted) || (state==State.MigrationFinished));
// 1 - calculate current reward
uint myBalance = mntpToken.balanceOf(msg.sender);
require(0!=myBalance);
uint myRewardMax = calculateMyRewardMax(msg.sender);
uint myReward = calculateMyReward(myRewardMax);
// 2 - pay the reward to our user
goldToken.transferRewardWithoutFee(msg.sender, myReward);
// 3 - burn tokens
// WARNING: burn will reduce totalSupply
//
// WARNING: creator must call
// setIcoContractAddress(migrationContractAddress)
// of the mntpToken
mntpToken.burnTokens(msg.sender,myBalance);
// save tuple
Migration memory mig;
mig.ethAddress = msg.sender;
mig.gmAddress = _gmAddress;
mig.tokensCount = myBalance;
mig.migrated = false;
mig.date = uint64(now);
mig.comment = '';
mntpMigrations[mntpMigrationsCount + 1] = mig;
mntpMigrationIndexes[msg.sender] = mntpMigrationsCount + 1;
mntpMigrationsCount++;
// send an event
MntpMigrateWanted(msg.sender, _gmAddress, myBalance);
}
function isMntpMigrated(address _who) public constant returns(bool) {
uint index = mntpMigrationIndexes[_who];
Migration memory mig = mntpMigrations[index];
return mig.migrated;
}
function setMntpMigrated(address _who, bool _isMigrated, string _comment) public onlyCreator {
uint index = mntpMigrationIndexes[_who];
require(index > 0);
mntpMigrations[index].migrated = _isMigrated;
mntpMigrations[index].comment = _comment;
// send an event
if (_isMigrated) {
MntpMigrated( mntpMigrations[index].ethAddress,
mntpMigrations[index].gmAddress,
mntpMigrations[index].tokensCount);
}
}
// GOLD
function migrateGold(string _gmAddress) public {
require((state==State.MigrationStarted) || (state==State.MigrationFinished));
// 1 - get balance
uint myBalance = goldToken.balanceOf(msg.sender);
require(0!=myBalance);
// 2 - burn tokens
// WARNING: burn will reduce totalSupply
//
goldToken.burnTokens(msg.sender,myBalance);
// save tuple
Migration memory mig;
mig.ethAddress = msg.sender;
mig.gmAddress = _gmAddress;
mig.tokensCount = myBalance;
mig.migrated = false;
mig.date = uint64(now);
mig.comment = '';
goldMigrations[goldMigrationsCount + 1] = mig;
goldMigrationIndexes[msg.sender] = goldMigrationsCount + 1;
goldMigrationsCount++;
// send an event
GoldMigrateWanted(msg.sender, _gmAddress, myBalance);
}
function isGoldMigrated(address _who) public constant returns(bool) {
uint index = goldMigrationIndexes[_who];
Migration memory mig = goldMigrations[index];
return mig.migrated;
}
function setGoldMigrated(address _who, bool _isMigrated, string _comment) public onlyCreator {
uint index = goldMigrationIndexes[_who];
require(index > 0);
goldMigrations[index].migrated = _isMigrated;
goldMigrations[index].comment = _comment;
// send an event
if (_isMigrated) {
GoldMigrated( goldMigrations[index].ethAddress,
goldMigrations[index].gmAddress,
goldMigrations[index].tokensCount);
}
}
// Each MNTP token holder gets a GOLD reward as a percent of all rewards
// proportional to his MNTP token stake
function calculateMyRewardMax(address _of) public constant returns(uint){
if (0 == mntpToMigrateTotal) {
return 0;
}
uint myCurrentMntpBalance = mntpToken.balanceOf(_of);
if (0 == myCurrentMntpBalance) {
return 0;
}
return (migrationRewardTotal * myCurrentMntpBalance) / mntpToMigrateTotal;
}
//emergency function. used in case of a mistake to transfer all the reward to a new migraiton smart contract.
function transferReward(address _newContractAddress) public onlyCreator {
goldToken.transferRewardWithoutFee(_newContractAddress, goldToken.balanceOf(this));
}
// Migration rewards decreased linearly.
//
// The formula is: rewardPercents = max(100 - 100 * day / 365, 0)
//
// On 1st day of migration, you will get: 100 - 100 * 0/365 = 100% of your rewards
// On 2nd day of migration, you will get: 100 - 100 * 1/365 = 99.7261% of your rewards
// On 365th day of migration, you will get: 100 - 100 * 364/365 = 0.274%
function calculateMyRewardDecreased(uint _day, uint _myRewardMax) public constant returns(uint){
if (_day >= 365) {
return 0;
}
uint x = ((100 * 1000000000 * _day) / 365);
return (_myRewardMax * ((100 * 1000000000) - x)) / (100 * 1000000000);
}
function calculateMyReward(uint _myRewardMax) public constant returns(uint){
// day starts from 0
uint day = (uint64(now) - migrationStartedTime) / uint64(1 days);
return calculateMyRewardDecreased(day, _myRewardMax);
}
// do not allow to send money to this contract...
function() external payable {
revert();
}
} |
require((State.Init == state) || (State.MigrationPaused == state));
if (State.Init == state) {
// 1 - change fees
goldToken.startMigration();
// 2 - store the current values
migrationRewardTotal = goldToken.balanceOf(this);
migrationStartedTime = uint64(now);
mntpToMigrateTotal = mntpToken.totalSupply();
}
state = State.MigrationStarted;
| function startMigration() public onlyCreator | // This method is called when migration to Goldmint's blockchain
// process is started...
function startMigration() public onlyCreator |
77321 | TokenFactory | TokenFactory | contract TokenFactory is StandardToken {
string public name;
string public symbol;
uint256 public decimals;
function TokenFactory(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) {<FILL_FUNCTION_BODY> }
} | contract TokenFactory is StandardToken {
string public name;
string public symbol;
uint256 public decimals;
<FILL_FUNCTION>
} |
balances[msg.sender] = _initialAmount;
totalSupply = _initialAmount;
name = _tokenName;
decimals = _decimalUnits;
symbol = _tokenSymbol;
| function TokenFactory(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) | function TokenFactory(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) |
3743 | Owned | setYccContractAddress | contract Owned {
// The addresses of the accounts (or contracts) that can execute actions within each roles.
address public ceoAddress;
address public cooAddress;
address private newCeoAddress;
address private newCooAddress;
function Owned() public {
ceoAddress = msg.sender;
cooAddress = msg.sender;
}
/*** ACCESS MODIFIERS ***/
/// @dev Access modifier for CEO-only functionality
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
/// @dev Access modifier for COO-only functionality
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
/// Access modifier for contract owner only functionality
modifier onlyCLevel() {
require(
msg.sender == ceoAddress ||
msg.sender == cooAddress
);
_;
}
/// @dev Assigns a new address to act as the CEO. Only available to the current CEO.
/// @param _newCEO The address of the new CEO
function setCEO(address _newCEO) public onlyCEO {
require(_newCEO != address(0));
newCeoAddress = _newCEO;
}
/// @dev Assigns a new address to act as the COO. Only available to the current COO.
/// @param _newCOO The address of the new COO
function setCOO(address _newCOO) public onlyCEO {
require(_newCOO != address(0));
newCooAddress = _newCOO;
}
function acceptCeoOwnership() public {
require(msg.sender == newCeoAddress);
require(address(0) != newCeoAddress);
ceoAddress = newCeoAddress;
newCeoAddress = address(0);
}
function acceptCooOwnership() public {
require(msg.sender == newCooAddress);
require(address(0) != newCooAddress);
cooAddress = newCooAddress;
newCooAddress = address(0);
}
mapping (address => bool) public youCollectContracts;
function addYouCollectContract(address contractAddress, bool active) public onlyCOO {
youCollectContracts[contractAddress] = active;
}
modifier onlyYCC() {
require(youCollectContracts[msg.sender]);
_;
}
InterfaceYCC ycc;
InterfaceContentCreatorUniverse yct;
InterfaceMining ycm;
function setMainYouCollectContractAddresses(address yccContract, address yctContract, address ycmContract, address[] otherContracts) public onlyCOO {
ycc = InterfaceYCC(yccContract);
yct = InterfaceContentCreatorUniverse(yctContract);
ycm = InterfaceMining(ycmContract);
youCollectContracts[yccContract] = true;
youCollectContracts[yctContract] = true;
youCollectContracts[ycmContract] = true;
for (uint16 index = 0; index < otherContracts.length; index++) {
youCollectContracts[otherContracts[index]] = true;
}
}
function setYccContractAddress(address yccContract) public onlyCOO {<FILL_FUNCTION_BODY> }
function setYctContractAddress(address yctContract) public onlyCOO {
yct = InterfaceContentCreatorUniverse(yctContract);
youCollectContracts[yctContract] = true;
}
function setYcmContractAddress(address ycmContract) public onlyCOO {
ycm = InterfaceMining(ycmContract);
youCollectContracts[ycmContract] = true;
}
} | contract Owned {
// The addresses of the accounts (or contracts) that can execute actions within each roles.
address public ceoAddress;
address public cooAddress;
address private newCeoAddress;
address private newCooAddress;
function Owned() public {
ceoAddress = msg.sender;
cooAddress = msg.sender;
}
/*** ACCESS MODIFIERS ***/
/// @dev Access modifier for CEO-only functionality
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
/// @dev Access modifier for COO-only functionality
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
/// Access modifier for contract owner only functionality
modifier onlyCLevel() {
require(
msg.sender == ceoAddress ||
msg.sender == cooAddress
);
_;
}
/// @dev Assigns a new address to act as the CEO. Only available to the current CEO.
/// @param _newCEO The address of the new CEO
function setCEO(address _newCEO) public onlyCEO {
require(_newCEO != address(0));
newCeoAddress = _newCEO;
}
/// @dev Assigns a new address to act as the COO. Only available to the current COO.
/// @param _newCOO The address of the new COO
function setCOO(address _newCOO) public onlyCEO {
require(_newCOO != address(0));
newCooAddress = _newCOO;
}
function acceptCeoOwnership() public {
require(msg.sender == newCeoAddress);
require(address(0) != newCeoAddress);
ceoAddress = newCeoAddress;
newCeoAddress = address(0);
}
function acceptCooOwnership() public {
require(msg.sender == newCooAddress);
require(address(0) != newCooAddress);
cooAddress = newCooAddress;
newCooAddress = address(0);
}
mapping (address => bool) public youCollectContracts;
function addYouCollectContract(address contractAddress, bool active) public onlyCOO {
youCollectContracts[contractAddress] = active;
}
modifier onlyYCC() {
require(youCollectContracts[msg.sender]);
_;
}
InterfaceYCC ycc;
InterfaceContentCreatorUniverse yct;
InterfaceMining ycm;
function setMainYouCollectContractAddresses(address yccContract, address yctContract, address ycmContract, address[] otherContracts) public onlyCOO {
ycc = InterfaceYCC(yccContract);
yct = InterfaceContentCreatorUniverse(yctContract);
ycm = InterfaceMining(ycmContract);
youCollectContracts[yccContract] = true;
youCollectContracts[yctContract] = true;
youCollectContracts[ycmContract] = true;
for (uint16 index = 0; index < otherContracts.length; index++) {
youCollectContracts[otherContracts[index]] = true;
}
}
<FILL_FUNCTION>
function setYctContractAddress(address yctContract) public onlyCOO {
yct = InterfaceContentCreatorUniverse(yctContract);
youCollectContracts[yctContract] = true;
}
function setYcmContractAddress(address ycmContract) public onlyCOO {
ycm = InterfaceMining(ycmContract);
youCollectContracts[ycmContract] = true;
}
} |
ycc = InterfaceYCC(yccContract);
youCollectContracts[yccContract] = true;
| function setYccContractAddress(address yccContract) public onlyCOO | function setYccContractAddress(address yccContract) public onlyCOO |
12966 | onlyOwner | null | contract onlyOwner {
address public owner;
bool private stopped = false;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {<FILL_FUNCTION_BODY> }
modifier isRunning {
require(!stopped);
_;
}
function stop() isOwner public {
stopped = true;
}
function start() isOwner public {
stopped = false;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier isOwner {
require(msg.sender == owner);
_;
}
} | contract onlyOwner {
address public owner;
bool private stopped = false;
<FILL_FUNCTION>
modifier isRunning {
require(!stopped);
_;
}
function stop() isOwner public {
stopped = true;
}
function start() isOwner public {
stopped = false;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier isOwner {
require(msg.sender == owner);
_;
}
} |
owner = 0x073db5ac9aa943253a513cd692d16160f1c10e74;
| constructor() public | /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public |
2246 | Owned | Owned | contract Owned {
address public owner;
function Owned() {<FILL_FUNCTION_BODY> }
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function setOwner(address _newOwner) onlyOwner {
owner = _newOwner;
}
} | contract Owned {
address public owner;
<FILL_FUNCTION>
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function setOwner(address _newOwner) onlyOwner {
owner = _newOwner;
}
} |
owner = msg.sender;
| function Owned() | function Owned() |
60740 | DEDICATED | PutGift | contract DEDICATED
{
address sender;
address reciver;
bool closed = false;
uint unlockTime;
function PutGift(address _reciver)
public
payable
{<FILL_FUNCTION_BODY> }
function SetGiftTime(uint _unixTime)
public
{
if(msg.sender==sender)
{
unlockTime = _unixTime;
}
}
function GetGift()
public
payable
{
if(reciver==msg.sender&&now>unlockTime)
{
msg.sender.transfer(this.balance);
}
}
function CloseGift()
public
{
if(sender == msg.sender && reciver != 0x0 )
{
closed=true;
}
}
function() public payable{}
} | contract DEDICATED
{
address sender;
address reciver;
bool closed = false;
uint unlockTime;
<FILL_FUNCTION>
function SetGiftTime(uint _unixTime)
public
{
if(msg.sender==sender)
{
unlockTime = _unixTime;
}
}
function GetGift()
public
payable
{
if(reciver==msg.sender&&now>unlockTime)
{
msg.sender.transfer(this.balance);
}
}
function CloseGift()
public
{
if(sender == msg.sender && reciver != 0x0 )
{
closed=true;
}
}
function() public payable{}
} |
if( (!closed&&(msg.value > 1 ether)) || sender==0x00 )
{
sender = msg.sender;
reciver = _reciver;
unlockTime = now;
}
| function PutGift(address _reciver)
public
payable
| function PutGift(address _reciver)
public
payable
|
43632 | TokenTranchePricing | TokenTranchePricing | contract TokenTranchePricing {
using SafeMath for uint;
/**
* Define pricing schedule using tranches.
*/
struct Tranche {
// Amount in tokens when this tranche becomes inactive
uint amount;
// Time interval [start, end)
// Starting timestamp (included in the interval)
uint start;
// Ending timestamp (excluded from the interval)
uint end;
// How many tokens per wei you will get while this tranche is active
uint price;
}
// We define offsets and size for the deserialization of ordered tuples in raw arrays
uint private constant amount_offset = 0;
uint private constant start_offset = 1;
uint private constant end_offset = 2;
uint private constant price_offset = 3;
uint private constant tranche_size = 4;
Tranche[] public tranches;
/// @dev Construction, creating a list of tranches
/// @param init_tranches Raw array of ordered tuples: (end amount, start timestamp, end timestamp, price)
function TokenTranchePricing(uint[] init_tranches) public {<FILL_FUNCTION_BODY> }
/// @dev Get the current tranche or bail out if there is no tranche defined for the current block.
/// @param tokensSold total amount of tokens sold, for calculating the current tranche
/// @return Returns the struct representing the current tranche
function getCurrentTranche(uint tokensSold) private constant returns (Tranche storage) {
for (uint i = 0; i < tranches.length; i++) {
if (tranches[i].start <= block.timestamp && block.timestamp < tranches[i].end && tokensSold < tranches[i].amount) {
return tranches[i];
}
}
// No tranche is currently active
revert();
}
/// @dev Get the current price. May revert if there is no tranche currently active.
/// @param tokensSold total amount of tokens sold, for calculating the current tranche
/// @return The current price
function getCurrentPrice(uint tokensSold) internal constant returns (uint result) {
return getCurrentTranche(tokensSold).price;
}
} | contract TokenTranchePricing {
using SafeMath for uint;
/**
* Define pricing schedule using tranches.
*/
struct Tranche {
// Amount in tokens when this tranche becomes inactive
uint amount;
// Time interval [start, end)
// Starting timestamp (included in the interval)
uint start;
// Ending timestamp (excluded from the interval)
uint end;
// How many tokens per wei you will get while this tranche is active
uint price;
}
// We define offsets and size for the deserialization of ordered tuples in raw arrays
uint private constant amount_offset = 0;
uint private constant start_offset = 1;
uint private constant end_offset = 2;
uint private constant price_offset = 3;
uint private constant tranche_size = 4;
Tranche[] public tranches;
<FILL_FUNCTION>
/// @dev Get the current tranche or bail out if there is no tranche defined for the current block.
/// @param tokensSold total amount of tokens sold, for calculating the current tranche
/// @return Returns the struct representing the current tranche
function getCurrentTranche(uint tokensSold) private constant returns (Tranche storage) {
for (uint i = 0; i < tranches.length; i++) {
if (tranches[i].start <= block.timestamp && block.timestamp < tranches[i].end && tokensSold < tranches[i].amount) {
return tranches[i];
}
}
// No tranche is currently active
revert();
}
/// @dev Get the current price. May revert if there is no tranche currently active.
/// @param tokensSold total amount of tokens sold, for calculating the current tranche
/// @return The current price
function getCurrentPrice(uint tokensSold) internal constant returns (uint result) {
return getCurrentTranche(tokensSold).price;
}
} |
// Need to have tuples, length check
require(init_tranches.length % tranche_size == 0);
// A tranche with amount zero can never be selected and is therefore useless.
// This check and the one inside the loop ensure no tranche can have an amount equal to zero.
require(init_tranches[amount_offset] > 0);
tranches.length = init_tranches.length.div(tranche_size);
Tranche memory last_tranche;
for (uint i = 0; i < tranches.length; i++) {
uint tranche_offset = i.mul(tranche_size);
uint amount = init_tranches[tranche_offset.add(amount_offset)];
uint start = init_tranches[tranche_offset.add(start_offset)];
uint end = init_tranches[tranche_offset.add(end_offset)];
uint price = init_tranches[tranche_offset.add(price_offset)];
// No invalid steps
require(block.timestamp < start && start < end);
// Bail out when entering unnecessary tranches
// This is preferably checked before deploying contract into any blockchain.
require(i == 0 || (end >= last_tranche.end && amount > last_tranche.amount) ||
(end > last_tranche.end && amount >= last_tranche.amount));
last_tranche = Tranche(amount, start, end, price);
tranches[i] = last_tranche;
}
| function TokenTranchePricing(uint[] init_tranches) public | /// @dev Construction, creating a list of tranches
/// @param init_tranches Raw array of ordered tuples: (end amount, start timestamp, end timestamp, price)
function TokenTranchePricing(uint[] init_tranches) public |
60160 | YAU | sell | contract YAU is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0);
require (balanceOf[_from] >= _value);
require (balanceOf[_to] + _value >= balanceOf[_to]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable public {
uint amount = msg.value / buyPrice;
_transfer(this, msg.sender, amount);
}
function sell(uint256 amount) public {<FILL_FUNCTION_BODY> }
} | contract YAU is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0);
require (balanceOf[_from] >= _value);
require (balanceOf[_to] + _value >= balanceOf[_to]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable public {
uint amount = msg.value / buyPrice;
_transfer(this, msg.sender, amount);
}
<FILL_FUNCTION>
} |
address myAddress = this;
require(myAddress.balance >= amount * sellPrice);
_transfer(msg.sender, this, amount);
msg.sender.transfer(amount * sellPrice);
| function sell(uint256 amount) public | function sell(uint256 amount) public |
44769 | A2TradingToken | null | contract A2TradingToken is ERC20, ERC20Detailed, ERC20Burnable {
uint256 public constant INITIAL_SUPPLY = 200000000 * (10 ** uint256(decimals()));
constructor () public ERC20Detailed("A2 TRADING TOKEN", "ATT", 18) {<FILL_FUNCTION_BODY> }
} | contract A2TradingToken is ERC20, ERC20Detailed, ERC20Burnable {
uint256 public constant INITIAL_SUPPLY = 200000000 * (10 ** uint256(decimals()));
<FILL_FUNCTION>
} |
_mint(msg.sender, INITIAL_SUPPLY);
| constructor () public ERC20Detailed("A2 TRADING TOKEN", "ATT", 18) | constructor () public ERC20Detailed("A2 TRADING TOKEN", "ATT", 18) |
76614 | BerserkVote | averageVotingValue | contract BerserkVote {
using SafeMath for uint256;
uint8 public constant MAX_VOTERS_PER_ITEM = 50;
uint16 public constant MIN_VOTING_VALUE = 50; // 50% (x0.5 times)
uint16 public constant MAX_VOTING_VALUE = 200; // 200% (x2 times)
mapping(address => mapping(uint256 => uint8)) public numVoters; // poolAddress -> votingItem (periodFinish) -> numVoters (the number of voters in this round)
mapping(address => mapping(uint256 => address[MAX_VOTERS_PER_ITEM])) public voters; // poolAddress -> votingItem (periodFinish) -> voters (array)
mapping(address => mapping(uint256 => mapping(address => bool))) public isInTopVoters; // poolAddress -> votingItem (periodFinish) -> isInTopVoters (map: voter -> in_top (true/false))
mapping(address => mapping(uint256 => mapping(address => uint16))) public voter2VotingValue; // poolAddress -> votingItem (periodFinish) -> voter2VotingValue (map: voter -> voting value)
event Voted(address poolAddress, address indexed user, uint256 votingItem, uint16 votingValue);
function getNumVotes( address poolAddressStake, uint256 valueAmount ) public view returns (uint256){
return numVoters[poolAddressStake][valueAmount];
}
function isVotable(address poolAddress, address account, uint256 votingItem) public view returns (bool) {
// already voted
if (voter2VotingValue[poolAddress][votingItem][account] > 0) return false;
BerserkRewards rewards = BerserkRewards(poolAddress);
// hasn't any staking power
if (rewards.stakingPower(account) == 0) return false;
// number of voters is under limit still
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) return true;
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < rewards.stakingPower(account)) return true; // there is some voters has lower staking power
}
return false;
}
function averageVotingValue(address poolAddress, uint256 votingItem) public view returns (uint16) {<FILL_FUNCTION_BODY> }
function vote(address poolAddress, uint256 votingItem, uint16 votingValue) public {
require(votingValue >= MIN_VOTING_VALUE, "votingValue is smaller than MIN_VOTING_VALUE");
require(votingValue <= MAX_VOTING_VALUE, "votingValue is greater than MAX_VOTING_VALUE");
if (!isInTopVoters[poolAddress][votingItem][msg.sender]) {
require(isVotable(poolAddress, msg.sender, votingItem), "This account is not votable");
uint8 voterIndex = MAX_VOTERS_PER_ITEM;
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) {
voterIndex = numVoters[poolAddress][votingItem];
} else {
BerserkRewards rewards = BerserkRewards(poolAddress);
uint256 minStakingPower = rewards.stakingPower(msg.sender);
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < minStakingPower) {
voterIndex = i;
minStakingPower = rewards.stakingPower(voters[poolAddress][votingItem][i]);
}
}
}
if (voterIndex < MAX_VOTERS_PER_ITEM) {
if (voterIndex < numVoters[poolAddress][votingItem]) {
isInTopVoters[poolAddress][votingItem][voters[poolAddress][votingItem][voterIndex]] = false; // remove lower power previous voter
} else {
++numVoters[poolAddress][votingItem];
}
isInTopVoters[poolAddress][votingItem][msg.sender] = true;
voters[poolAddress][votingItem][voterIndex] = msg.sender;
}
}
voter2VotingValue[poolAddress][votingItem][msg.sender] = votingValue;
emit Voted(poolAddress, msg.sender, votingItem, votingValue);
}
} | contract BerserkVote {
using SafeMath for uint256;
uint8 public constant MAX_VOTERS_PER_ITEM = 50;
uint16 public constant MIN_VOTING_VALUE = 50; // 50% (x0.5 times)
uint16 public constant MAX_VOTING_VALUE = 200; // 200% (x2 times)
mapping(address => mapping(uint256 => uint8)) public numVoters; // poolAddress -> votingItem (periodFinish) -> numVoters (the number of voters in this round)
mapping(address => mapping(uint256 => address[MAX_VOTERS_PER_ITEM])) public voters; // poolAddress -> votingItem (periodFinish) -> voters (array)
mapping(address => mapping(uint256 => mapping(address => bool))) public isInTopVoters; // poolAddress -> votingItem (periodFinish) -> isInTopVoters (map: voter -> in_top (true/false))
mapping(address => mapping(uint256 => mapping(address => uint16))) public voter2VotingValue; // poolAddress -> votingItem (periodFinish) -> voter2VotingValue (map: voter -> voting value)
event Voted(address poolAddress, address indexed user, uint256 votingItem, uint16 votingValue);
function getNumVotes( address poolAddressStake, uint256 valueAmount ) public view returns (uint256){
return numVoters[poolAddressStake][valueAmount];
}
function isVotable(address poolAddress, address account, uint256 votingItem) public view returns (bool) {
// already voted
if (voter2VotingValue[poolAddress][votingItem][account] > 0) return false;
BerserkRewards rewards = BerserkRewards(poolAddress);
// hasn't any staking power
if (rewards.stakingPower(account) == 0) return false;
// number of voters is under limit still
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) return true;
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < rewards.stakingPower(account)) return true; // there is some voters has lower staking power
}
return false;
}
<FILL_FUNCTION>
function vote(address poolAddress, uint256 votingItem, uint16 votingValue) public {
require(votingValue >= MIN_VOTING_VALUE, "votingValue is smaller than MIN_VOTING_VALUE");
require(votingValue <= MAX_VOTING_VALUE, "votingValue is greater than MAX_VOTING_VALUE");
if (!isInTopVoters[poolAddress][votingItem][msg.sender]) {
require(isVotable(poolAddress, msg.sender, votingItem), "This account is not votable");
uint8 voterIndex = MAX_VOTERS_PER_ITEM;
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) {
voterIndex = numVoters[poolAddress][votingItem];
} else {
BerserkRewards rewards = BerserkRewards(poolAddress);
uint256 minStakingPower = rewards.stakingPower(msg.sender);
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < minStakingPower) {
voterIndex = i;
minStakingPower = rewards.stakingPower(voters[poolAddress][votingItem][i]);
}
}
}
if (voterIndex < MAX_VOTERS_PER_ITEM) {
if (voterIndex < numVoters[poolAddress][votingItem]) {
isInTopVoters[poolAddress][votingItem][voters[poolAddress][votingItem][voterIndex]] = false; // remove lower power previous voter
} else {
++numVoters[poolAddress][votingItem];
}
isInTopVoters[poolAddress][votingItem][msg.sender] = true;
voters[poolAddress][votingItem][voterIndex] = msg.sender;
}
}
voter2VotingValue[poolAddress][votingItem][msg.sender] = votingValue;
emit Voted(poolAddress, msg.sender, votingItem, votingValue);
}
} |
if (numVoters[poolAddress][votingItem] == 0) return 0; // no votes
uint256 totalStakingPower = 0;
uint256 totalWeightVotingValue = 0;
BerserkRewards rewards = BerserkRewards(poolAddress);
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
address voter = voters[poolAddress][votingItem][i];
totalStakingPower = totalStakingPower.add(rewards.stakingPower(voter));
totalWeightVotingValue = totalWeightVotingValue.add(rewards.stakingPower(voter).mul(voter2VotingValue[poolAddress][votingItem][voter]));
}
return (uint16) (totalWeightVotingValue.div(totalStakingPower));
| function averageVotingValue(address poolAddress, uint256 votingItem) public view returns (uint16) | function averageVotingValue(address poolAddress, uint256 votingItem) public view returns (uint16) |
40365 | ERC20 | allowance | contract ERC20 is ERC20Interface,SafeMath {
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) allowed;
constructor(string memory _name) public {
name = _name;
symbol = "FSF";
decimals = 18;
totalSupply = 1000000000000000000000000000;
balanceOf[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(balanceOf[msg.sender] >= _value);
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(allowed[_from][msg.sender] >= _value);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value==0)||(allowed[msg.sender][_spender]==0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {<FILL_FUNCTION_BODY> }
} | contract ERC20 is ERC20Interface,SafeMath {
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) allowed;
constructor(string memory _name) public {
name = _name;
symbol = "FSF";
decimals = 18;
totalSupply = 1000000000000000000000000000;
balanceOf[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(balanceOf[msg.sender] >= _value);
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(allowed[_from][msg.sender] >= _value);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value==0)||(allowed[msg.sender][_spender]==0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
<FILL_FUNCTION>
} |
return allowed[_owner][_spender];
| function allowance(address _owner, address _spender) public view returns (uint256 remaining) | function allowance(address _owner, address _spender) public view returns (uint256 remaining) |
9644 | sakura | _getRate | contract sakura is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
uint8 private _decimals = 9;
//
string private _name = "Sakura Inu"; // name
string private _symbol = "$SAKURA"; // symbol
uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals);
// % to holders
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
// % to swap & send to marketing wallet
uint256 public defaultMarketingFee = 9;
uint256 public _marketingFee = defaultMarketingFee;
uint256 private _previousMarketingFee = _marketingFee;
uint256 public _marketingFee4Sellers = 9;
bool public feesOnSellersAndBuyers = true;
uint256 public _maxTxAmount = _tTotal.div(1).div(49);
uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100);
address payable public marketingWallet = payable(0x98C6291270E56e13909FfA5bb3d3BBAe959a05da);
//
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
mapping (address => bool) public _isBlacklisted;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tFeeTotal;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndSend;
bool public SwapAndSendEnabled = true;
event SwapAndSendEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwapAndSend = true;
_;
inSwapAndSend = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
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 excludeFromReward(address account) public onlyOwner() {
// require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function 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 removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
}
//to recieve ETH
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function addToBlackList(address[] calldata addresses) external onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isBlacklisted[addresses[i]] = true;
}
}
function removeFromBlackList(address account) external onlyOwner {
_isBlacklisted[account] = false;
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tMarketing = calculateMarketingFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, 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 rTransferAmount = rAmount.sub(rFee).sub(rMarketing);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {<FILL_FUNCTION_BODY> }
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 _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 isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address 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] && !_isBlacklisted[to], "This address is blacklisted");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + send lock?
// also, don't get caught in a circular sending event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (
overMinTokenBalance &&
!inSwapAndSend &&
from != uniswapV2Pair &&
SwapAndSendEnabled
) {
SwapAndSend(contractTokenBalance);
}
if(feesOnSellersAndBuyers) {
setFees(to);
}
//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;
}
_tokenTransfer(from,to,amount,takeFee);
}
function setFees(address recipient) private {
_taxFee = defaultTaxFee;
_marketingFee = defaultMarketingFee;
if (recipient == uniswapV2Pair) { // sell
_marketingFee = _marketingFee4Sellers;
}
}
function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), contractTokenBalance);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
marketingWallet.transfer(contractETHBalance);
}
}
//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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 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);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() {
defaultMarketingFee = marketingFee;
}
function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() {
_marketingFee4Sellers = marketingFee4Sellers;
}
function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() {
feesOnSellersAndBuyers = _enabled;
}
function setSwapAndSendEnabled(bool _enabled) public onlyOwner() {
SwapAndSendEnabled = _enabled;
emit SwapAndSendEnabledUpdated(_enabled);
}
function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() {
numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing;
}
function _setMarketingWallet(address payable wallet) external onlyOwner() {
marketingWallet = wallet;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} | contract sakura is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
uint8 private _decimals = 9;
//
string private _name = "Sakura Inu"; // name
string private _symbol = "$SAKURA"; // symbol
uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals);
// % to holders
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
// % to swap & send to marketing wallet
uint256 public defaultMarketingFee = 9;
uint256 public _marketingFee = defaultMarketingFee;
uint256 private _previousMarketingFee = _marketingFee;
uint256 public _marketingFee4Sellers = 9;
bool public feesOnSellersAndBuyers = true;
uint256 public _maxTxAmount = _tTotal.div(1).div(49);
uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100);
address payable public marketingWallet = payable(0x98C6291270E56e13909FfA5bb3d3BBAe959a05da);
//
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
mapping (address => bool) public _isBlacklisted;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tFeeTotal;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndSend;
bool public SwapAndSendEnabled = true;
event SwapAndSendEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwapAndSend = true;
_;
inSwapAndSend = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
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 excludeFromReward(address account) public onlyOwner() {
// require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function 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 removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
}
//to recieve ETH
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function addToBlackList(address[] calldata addresses) external onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isBlacklisted[addresses[i]] = true;
}
}
function removeFromBlackList(address account) external onlyOwner {
_isBlacklisted[account] = false;
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tMarketing = calculateMarketingFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, 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 rTransferAmount = rAmount.sub(rFee).sub(rMarketing);
return (rAmount, rTransferAmount, rFee);
}
<FILL_FUNCTION>
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 _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 isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address 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] && !_isBlacklisted[to], "This address is blacklisted");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + send lock?
// also, don't get caught in a circular sending event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (
overMinTokenBalance &&
!inSwapAndSend &&
from != uniswapV2Pair &&
SwapAndSendEnabled
) {
SwapAndSend(contractTokenBalance);
}
if(feesOnSellersAndBuyers) {
setFees(to);
}
//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;
}
_tokenTransfer(from,to,amount,takeFee);
}
function setFees(address recipient) private {
_taxFee = defaultTaxFee;
_marketingFee = defaultMarketingFee;
if (recipient == uniswapV2Pair) { // sell
_marketingFee = _marketingFee4Sellers;
}
}
function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), contractTokenBalance);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
marketingWallet.transfer(contractETHBalance);
}
}
//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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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 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);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() {
defaultMarketingFee = marketingFee;
}
function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() {
_marketingFee4Sellers = marketingFee4Sellers;
}
function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() {
feesOnSellersAndBuyers = _enabled;
}
function setSwapAndSendEnabled(bool _enabled) public onlyOwner() {
SwapAndSendEnabled = _enabled;
emit SwapAndSendEnabledUpdated(_enabled);
}
function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() {
numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing;
}
function _setMarketingWallet(address payable wallet) external onlyOwner() {
marketingWallet = wallet;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} |
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
| function _getRate() private view returns(uint256) | function _getRate() private view returns(uint256) |
61131 | Pausable | pause | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev modifier to allow actions only when the contract IS NOT paused
*/
modifier whenPaused {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public returns (bool) {
paused = false;
emit Unpause();
return true;
}
} | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev modifier to allow actions only when the contract IS NOT paused
*/
modifier whenPaused {
require(paused);
_;
}
<FILL_FUNCTION>
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public returns (bool) {
paused = false;
emit Unpause();
return true;
}
} |
paused = true;
emit Pause();
return true;
| function pause() onlyOwner whenNotPaused public returns (bool) | /**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public returns (bool) |
53950 | DBXTTest | null | contract DBXTTest is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
uint public startDate;
uint public endDate;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// 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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// 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;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// 25,000 DBXTTest Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
tokens = msg.value * 25000;
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
emit Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
}
// ------------------------------------------------------------------------
// 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 DBXTTest is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
uint public startDate;
uint public endDate;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// 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] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// 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;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// 25,000 DBXTTest Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
tokens = msg.value * 25000;
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
emit Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
}
// ------------------------------------------------------------------------
// 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);
}
} |
symbol = "DBXTTest";
name = "DBXTTest";
decimals = 18;
endDate = now + 12 weeks;
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
37470 | ERC20 | _mint | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) internal _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> }
function _burn(address owner, uint256 value) internal {
require(owner != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[owner] = _balances[owner].sub(value);
emit Transfer(owner, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _burnFrom(address owner, uint256 amount) internal {
_burn(owner, amount);
_approve(owner, msg.sender, _allowances[owner][msg.sender].sub(amount));
}
} | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) internal _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
<FILL_FUNCTION>
function _burn(address owner, uint256 value) internal {
require(owner != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[owner] = _balances[owner].sub(value);
emit Transfer(owner, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _burnFrom(address owner, uint256 amount) internal {
_burn(owner, amount);
_approve(owner, msg.sender, _allowances[owner][msg.sender].sub(amount));
}
} |
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
| function _mint(address account, uint256 amount) internal | function _mint(address account, uint256 amount) internal |