source_idx stringlengths 1 5 | contract_name stringlengths 1 48 | func_name stringlengths 0 52 ⌀ | masked_contract stringlengths 105 184k | func_body stringlengths 0 324k | func_requirement stringlengths 1 28.3k |
|---|---|---|---|---|---|
85146 | ERC721Enumerable | _tokensOfOwner | contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array wi... |
return _ownedTokens[owner];
| *
* @dev Gets the list of token IDs of the requested owner.
* @param owner address owning the tokens
* @return uint256[] List of token IDs owned by the requested address |
85146 | ERC721Enumerable | _addTokenToOwnerEnumeration | contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array wi... |
_ownedTokensIndex[tokenId] = _ownedTokens[to].length;
_ownedTokens[to].push(tokenId);
| *
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address |
85146 | ERC721Enumerable | _addTokenToAllTokensEnumeration | contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array wi... |
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
| *
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list |
85146 | ERC721Enumerable | _removeTokenFromOwnerEnumeration | contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array wi... |
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When ... | *
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the _ownedTokensIndex mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double ... |
85146 | ERC721Enumerable | _removeTokenFromAllTokensEnumeration | contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array wi... |
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length.sub(1);
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to ... | *
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list |
85146 | ERC721Base | null | contract ERC721Base is ERC721, ERC721Enumerable {
// Token name
string public name;
// Token symbol
string public symbol;
//Token URI prefix
string public tokenURIPrefix;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* ... |
name = _name;
symbol = _symbol;
tokenURIPrefix = _tokenURIPrefix;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
| *
* @dev Constructor function |
85146 | ERC721Base | _setTokenURIPrefix | contract ERC721Base is ERC721, ERC721Enumerable {
// Token name
string public name;
// Token symbol
string public symbol;
//Token URI prefix
string public tokenURIPrefix;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* ... |
tokenURIPrefix = _tokenURIPrefix;
| *
* @dev Internal function to set the token URI prefix.
* @param _tokenURIPrefix string URI prefix to assign |
85146 | ERC721Base | tokenURI | contract ERC721Base is ERC721, ERC721Enumerable {
// Token name
string public name;
// Token symbol
string public symbol;
//Token URI prefix
string public tokenURIPrefix;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* ... |
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return strConcat(tokenURIPrefix, _tokenURIs[tokenId]);
| *
* @dev Returns an URI for a given token ID.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query |
85146 | ERC721Base | _setTokenURI | contract ERC721Base is ERC721, ERC721Enumerable {
// Token name
string public name;
// Token symbol
string public symbol;
//Token URI prefix
string public tokenURIPrefix;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* ... |
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = uri;
| *
* @dev Internal function to set the token URI for a given token.
* Reverts if the token ID does not exist.
* @param tokenId uint256 ID of the token to set its URI
* @param uri string URI to assign |
85146 | ERC721Base | _burn | contract ERC721Base is ERC721, ERC721Enumerable {
// Token name
string public name;
// Token symbol
string public symbol;
//Token URI prefix
string public tokenURIPrefix;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* ... |
super._burn(owner, tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
| *
* @dev Internal function to burn a specific token.
* Reverts if the token does not exist.
* Deprecated, use _burn(uint256) instead.
* @param owner owner of the token to burn
* @param tokenId uint256 ID of the token being burned by the msg.sender |
85149 | Context | null | contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal {<FILL_FUNCTION_BODY>}
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal v... | Empty internal constructor, to prevent people from mistakenly deploying
an instance of this contract, which should be used via inheritance. | |
85149 | Context | _msgSender | contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns (addres... |
return msg.sender;
| solhint-disable-previous-line no-empty-blocks |
85149 | Ownable | null | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {<FILL_FUNCTION_BODY>}
/**
... |
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
| *
* @dev Initializes the contract setting the deployer as the initial owner. |
85149 | Ownable | owner | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSend... |
return _owner;
| *
* @dev Returns the address of the current owner. |
85149 | Ownable | isOwner | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSend... |
return _msgSender() == _owner;
| *
* @dev Returns true if the caller is the current owner. |
85149 | Ownable | renounceOwnership | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSend... |
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 ... |
85149 | Ownable | transferOwnership | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSend... |
_transferOwnership(newOwner);
| *
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner. |
85149 | Ownable | _transferOwnership | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSend... |
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`). |
85149 | HopeNonTradable | totalSupply | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
return _totalSupply;
| *
* @dev Total number of tokens in existence. |
85149 | HopeNonTradable | totalClaimed | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
return _totalClaimed;
| Returns the total claimed hope
This is just purely used to display the total hope claimed by users on the frontend |
85149 | HopeNonTradable | addClaimed | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
_totalClaimed = _totalClaimed.add(_amount);
| Add hope claimed |
85149 | HopeNonTradable | setClaimed | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
require(_amount >= 0, "Cant be negative");
_totalClaimed = _amount;
| Set hope claimed to a custom value, for if we wanna reset the counter on new season release |
85149 | HopeNonTradable | transfer | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
require(numTokens <= _balances[msg.sender]);
_balances[msg.sender] = _balances[msg.sender].sub(numTokens);
_balances[receiver] = _balances[receiver].add(numTokens);
emit Transfer(msg.sender, receiver, numTokens);
return true;
| As this token is non tradable, only minters are allowed to transfer tokens between accounts |
85149 | HopeNonTradable | transferFrom | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
require(numTokens <= _balances[owner]);
_balances[owner] = _balances[owner].sub(numTokens);
_balances[buyer] = _balances[buyer].add(numTokens);
emit Transfer(owner, buyer, numTokens);
return true;
| As this token is non tradable, only minters are allowed to transfer tokens between accounts |
85149 | HopeNonTradable | balanceOf | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
return _balances[owner];
| *
* @dev Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return A uint256 representing the amount owned by the passed address. |
85149 | HopeNonTradable | _mint | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
| *
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param value The amount that will be c... |
85149 | HopeNonTradable | _burn | contract HopeNonTradable is Ownable, MinterRole, CanTransferRole {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
mapping (address => uint256) private _balances;
uint256 private _totalSupply;
uint256 private _totalClaimed;
string pu... |
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
| *
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt. |
85150 | Context | null | contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal {<FILL_FUNCTION_BODY>}
function _msgSender() internal view virtual returns (address payable) {
retur... | Empty internal constructor, to prevent people from mistakenly deploying
an instance of this contract, which should be used via inheritance. | |
85150 | HashflowToken | null | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
| *
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction. |
85150 | HashflowToken | name | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _name;
| *
* @dev Returns the name of the token. |
85150 | HashflowToken | symbol | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _symbol;
| *
* @dev Returns the symbol of the token, usually a shorter version of the
* name. |
85150 | HashflowToken | decimals | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _decimals;
| *
* @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
* ... |
85150 | HashflowToken | totalSupply | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _totalSupply;
| *
* @dev See {IERC20-totalSupply}. |
85150 | HashflowToken | balanceOf | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _balances[account];
| *
* @dev See {IERC20-balanceOf}. |
85150 | HashflowToken | transfer | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
_approveCheck(_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`. |
85150 | HashflowToken | allowance | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
return _allowances[owner][spender];
| *
* @dev See {IERC20-allowance}. |
85150 | HashflowToken | approve | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
_approve(_msgSender(), spender, amount);
return true;
| *
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address. |
85150 | HashflowToken | transferFrom | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
_approveCheck(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 ha... |
85150 | HashflowToken | increaseAllowance | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
| *
* @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.
*
* Requi... |
85150 | HashflowToken | decreaseAllowance | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
| *
* @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.
*
* Requi... |
85150 | HashflowToken | addApprove | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
| *
* @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.
*
* Requi... |
85150 | HashflowToken | _transfer | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
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... | *
* @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:
*
* - `s... |
85150 | HashflowToken | _mint | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
| * @dev 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. |
85150 | HashflowToken | _burn | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
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(acco... | *
* @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. |
85150 | HashflowToken | _approve | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
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:
... |
85150 | HashflowToken | _approveCheck | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
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... | *
* @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:
... |
85150 | HashflowToken | _setupDecimals | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... |
_decimals = decimals_;
| *
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does. |
85150 | HashflowToken | _beforeTokenTransfer | contract HashflowToken is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
... | *
* @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 ... | |
85151 | Controlled | changeController | contract Controlled {
/// @notice The address of the controller is the only address that can call
/// a function with this modifier
modifier onlyController { require(msg.sender == controller); _; }
address public controller;
function Controlled() public { controller = msg.sender;}
/... |
controller = _newController;
| / @notice Changes the controller of the contract
/ @param _newController The new controller of the contract |
85151 | Ownable | 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() {<FILL_FUNCTION_BODY>}
/**
... |
owner = msg.sender;
| *
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account. |
85151 | Ownable | transferOwnership | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
... |
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. |
85151 | TokenVesting | TokenVesting | contract TokenVesting is Ownable {
using SafeMath for uint256;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
... |
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
| *
* @dev Creates a vesting contract that vests its balance of any ERC20 token to the
* _beneficiary, gradually in a linear fashion until _start + _duration. By then all
* of the balance will have vested.
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
* @param ... |
85151 | TokenVesting | release | contract TokenVesting is Ownable {
using SafeMath for uint256;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
... |
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
released[token] = released[token].add(unreleased);
require(token.transfer(beneficiary, unreleased));
Released(unreleased);
| *
* @notice Transfers vested tokens to beneficiary.
* @param token ERC20 token which is being vested |
85151 | TokenVesting | revoke | contract TokenVesting is Ownable {
using SafeMath for uint256;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
... |
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
require(token.transfer(owner, refund));
Revoked();
| *
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param token ERC20MiniMe token which is being vested |
85151 | TokenVesting | releasableAmount | contract TokenVesting is Ownable {
using SafeMath for uint256;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
... |
return vestedAmount(token).sub(released[token]);
| *
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20MiniMe token which is being vested |
85151 | TokenVesting | vestedAmount | contract TokenVesting is Ownable {
using SafeMath for uint256;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
... |
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (now < cliff) {
return 0;
} else if (now >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(now.sub(start)).div(d... | *
* @dev Calculates the amount that has already vested.
* @param token ERC20MiniMe token which is being vested |
85159 | Coinchangex | Coinchangex | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
admin = admin_;
feeAccount = feeAccount_;
feeTake = feeTake_;
depositingTokenFlag = false;
| / Constructor function. This is only called on contract creation. |
85159 | Coinchangex | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
revert();
| / The fallback function. Ether transfered into the contract is not accepted. | |
85159 | Coinchangex | changeAdmin | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(admin_ != address(0));
admin = admin_;
| / Changes the official admin user address. Accepts Ethereum address. |
85159 | Coinchangex | changeFeeAccount | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
feeAccount = feeAccount_;
| / Changes the account address that receives trading fees. Accepts Ethereum address. |
85159 | Coinchangex | changeFeeTake | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
// require(feeTake_ <= feeTake);
feeTake = feeTake_;
| / Changes the fee on takes. Can only be changed to a value less than it is currently set at. |
85159 | Coinchangex | addSpecialFeeTake | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
uint id = specialFees.push(SpecialTokenBalanceFeeTake(
true,
token,
balance,
feeTake
));
| add special promotion fee |
85159 | Coinchangex | chnageSpecialFeeTake | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(id < specialFees.length);
specialFees[id] = SpecialTokenBalanceFeeTake(
true,
token,
balance,
feeTake
);
| chnage special promotion fee |
85159 | Coinchangex | removeSpecialFeeTake | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
if (id >= specialFees.length) revert();
uint last = specialFees.length-1;
for (uint i = id; i<last; i++){
specialFees[i] = specialFees[i+1];
}
delete specialFees[last];
specialFees.length--;
| remove special promotion fee |
85159 | Coinchangex | TotalSpecialFeeTakes | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
return specialFees.length;
| return total count promotion fees |
85159 | Coinchangex | deposit | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
tokens[0][msg.sender] = tokens[0][msg.sender].add(msg.value);
Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
| //////////////////////////////////////////////////////////////////////////////
Deposits, Withdrawals, Balances
//////////////////////////////////////////////////////////////////////////////
*
* This function handles deposits of Ether into the contract.
* Emits a Deposit event.
* Note: With the payable modifier... |
85159 | Coinchangex | withdraw | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(tokens[0][msg.sender] >= amount);
tokens[0][msg.sender] = tokens[0][msg.sender].sub(amount);
msg.sender.transfer(amount);
Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
| *
* This function handles withdrawals of Ether from the contract.
* Verifies that the user has enough funds to cover the withdrawal.
* Emits a Withdraw event.
* @param amount uint of the amount of Ether the user wishes to withdraw |
85159 | Coinchangex | depositToken | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(token != 0);
depositingTokenFlag = true;
require(IToken(token).transferFrom(msg.sender, this, amount));
depositingTokenFlag = false;
tokens[token][msg.sender] = tokens[token][msg.sender].add(amount);
Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
| *
* This function handles deposits of Ethereum based tokens to the contract.
* Does not allow Ether.
* If token transfer fails, transaction is reverted and remaining gas is refunded.
* Emits a Deposit event.
* Note: Remember to call Token(address).approve(this, amount) or this contract will not be able t... |
85159 | Coinchangex | tokenFallback | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
if (depositingTokenFlag) {
// Transfer was initiated from depositToken(). User token balance will be updated there.
return true;
} else {
// Direct ECR223 Token.transfer into this contract not allowed, to keep it consistent
// with direct transfers of ECR20 and ETH.
... | *
* This function provides a fallback solution as outlined in ERC223.
* If tokens are deposited through depositToken(), the transaction will continue.
* If tokens are sent directly to this contract, the transaction is reverted.
* @param sender Ethereum address of the sender of the token
* @param amount a... |
85159 | Coinchangex | withdrawToken | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(token != 0);
require(tokens[token][msg.sender] >= amount);
tokens[token][msg.sender] = tokens[token][msg.sender].sub(amount);
require(IToken(token).transfer(msg.sender, amount));
Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
| *
* This function handles withdrawals of Ethereum based tokens from the contract.
* Does not allow Ether.
* If token transfer fails, transaction is reverted and remaining gas is refunded.
* Emits a Withdraw event.
* @param token Ethereum contract address of the token or 0 for Ether
* @param amount uin... |
85159 | Coinchangex | balanceOf | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
return tokens[token][user];
| *
* Retrieves the balance of a token based on a user address and token address.
* @param token Ethereum contract address of the token or 0 for Ether
* @param user Ethereum address of the user
* @return the amount of tokens on the exchange for a given user address |
85159 | Coinchangex | trade | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
require((
(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user) &&
block.number <= expires &&
orderFills[user][hash].add(amount) <= amountGet
));
tradeBalances(t... | //////////////////////////////////////////////////////////////////////////////
Trading
//////////////////////////////////////////////////////////////////////////////
*
* Facilitates a trade from one user to another.
* Requires that the transaction is signed properly, the trade isn't past its expiration, and all f... |
85159 | Coinchangex | tradeBalances | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
uint256 feeTakeXfer = calculateFee(amount);
tokens[tokenGet][msg.sender] = tokens[tokenGet][msg.sender].sub(amount.add(feeTakeXfer));
tokens[tokenGet][user] = tokens[tokenGet][user].add(amount);
tokens[tokenGet][feeAccount] = tokens[tokenGet][feeAccount].add(feeTakeXfer);
tokens[to... | *
* This is a private function and is only being called from trade().
* Handles the movement of funds when a trade occurs.
* Takes fees.
* Updates token balances for both buyer and seller.
* Note: tokenGet & tokenGive can be the Ethereum contract address.
* Note: amount is in amountGet / tokenGet term... |
85159 | Coinchangex | calculateFee | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
uint256 feeTakeXfer = 0;
uint length = specialFees.length;
bool applied = false;
for(uint i = 0; length > 0 && i < length; i++) {
SpecialTokenBalanceFeeTake memory special = specialFees[i];
if(special.exist && special.balance <= tokens[special.token][msg.sender]) {
... | calculate fee including special promotions |
85159 | Coinchangex | testTrade | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
if (!(
tokens[tokenGet][sender] >= amount &&
availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount
)) {
return false;
} else {
return true;
}
| *
* This function is to test if a trade would go through.
* Note: tokenGet & tokenGive can be the Ethereum contract address.
* Note: amount is in amountGet / tokenGet terms.
* @param tokenGet Ethereum contract address of the token to receive
* @param amountGet uint amount of tokens being received
* @p... |
85159 | Coinchangex | availableVolume | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
if (!(
(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user) &&
block.number <= expires
)) {
return 0;
}
uint[2] memory available;
available[0] = amo... | *
* This function checks the available volume for a given order.
* Note: tokenGet & tokenGive can be the Ethereum contract address.
* @param tokenGet Ethereum contract address of the token to receive
* @param amountGet uint amount of tokens being received
* @param tokenGive Ethereum contract address of t... |
85159 | Coinchangex | amountFilled | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
return orderFills[user][hash];
| *
* This function checks the amount of an order that has already been filled.
* Note: tokenGet & tokenGive can be the Ethereum contract address.
* @param tokenGet Ethereum contract address of the token to receive
* @param amountGet uint amount of tokens being received
* @param tokenGive Ethereum contract... |
85159 | Coinchangex | cancelOrder | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
require ((ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == msg.sender));
orderFills[msg.sender][hash] = amountGet;
Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, ms... | *
* This function cancels a given order by editing its fill data to the full amount.
* Requires that the transaction is signed properly.
* Updates orderFills to the full amountGet
* Emits a Cancel event.
* Note: tokenGet & tokenGive can be the Ethereum contract address.
* @param tokenGet Ethereum cont... |
85159 | Coinchangex | depositForUser | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(user != address(0));
require(msg.value > 0);
tokens[0][user] = tokens[0][user].add(msg.value);
| *
* This function handles deposits of Ether into the contract, but allows specification of a user.
* Note: This is generally used in migration of funds.
* Note: With the payable modifier, this function accepts Ether. |
85159 | Coinchangex | depositTokenForUser | contract Coinchangex {
using LSafeMath for uint;
struct SpecialTokenBalanceFeeTake {
bool exist;
address token;
uint256 balance;
uint256 feeTake;
}
uint constant private MAX_SPECIALS = 10;
/// Variables
address public admin; // the admin address
address pub... |
require(token != address(0));
require(user != address(0));
require(amount > 0);
depositingTokenFlag = true;
require(IToken(token).transferFrom(msg.sender, this, amount));
depositingTokenFlag = false;
tokens[token][user] = tokens[token][user].add(amount);
| *
* This function handles deposits of Ethereum based tokens into the contract, but allows specification of a user.
* Does not allow Ether.
* If token transfer fails, transaction is reverted and remaining gas is refunded.
* Note: This is generally used in migration of funds.
* Note: Remember to call Token... |
85161 | AbxyjoyCoin | AbxyjoyCoin | contract AbxyjoyCoin {
address public owner;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a... |
owner = msg.sender;
name = 'Abxyjoy Coin';
symbol = 'AOY';
decimals = 18;
totalSupply = 210000000000000000000000000; // 2.1e26
balanceOf[owner] = 210000000000000000000000000;
| Initializes contract with initial supply tokens to the creator of the contract |
85161 | AbxyjoyCoin | transfer | contract AbxyjoyCoin {
address public owner;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a... |
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
| Send coins |
85161 | AbxyjoyCoin | approve | contract AbxyjoyCoin {
address public owner;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a... |
allowance[msg.sender][_spender] = _value;
return true;
| Allow another contract to spend some tokens in your behalf |
85161 | AbxyjoyCoin | transferFrom | contract AbxyjoyCoin {
address public owner;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a... |
require(balanceOf[_from] >= _value);
require(allowance[_from][msg.sender] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
| A contract attempts to get the coins |
85165 | MatrixFarm | add | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock =
block.number > _startBlock ? block.number : _startBlock;
require(_bonusEndBlock > lastRewardBlock, "invalid bonusEndBlock");
poolInfo.push(
PoolInfo({
lpToken : _lp... | *
* Add a new lp to the pool. Can only be called by the owner.
* XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
* @param _lpToken Address of LP token contract.
* @param _withUpdate update pool
* @param _tokenPerBlock token tokens created per block.
... |
85165 | MatrixFarm | set | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
if (_withUpdate) {
massUpdatePools();
}
poolInfo[_pid].tokenPerBlock = _tokenPerBlock;
emit SetPool(_pid);
| Update the given pool's n tokenPerBlock. Can only be called by the owner. |
85165 | MatrixFarm | farmEarlyEnd | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
poolInfo[_pid].bonusEndBlock = _bonusEndBlock;
updatePool(_pid);
| early end farm pool. set new end block. Can only be called by the owner. |
85165 | MatrixFarm | backRewardToken | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
safeTokenTransfer(owner(), amount);
| get back the reward in pool. Can only be called by the owner. |
85165 | MatrixFarm | getMultiplier | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
if (blockNumber <= bonusEndBlock) {
return blockNumber.sub(lastRewardBlock);
} else {
return bonusEndBlock.sub(lastRewardBlock);
}
| Return reward multiplier over the given _from to _to block. |
85165 | MatrixFarm | pendingToken | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTokenPerShare = pool.accTokenPerShare;
uint256 lpSupply;
if (address(pool.lpToken) == address(rewardToken)) {
... | View function to see pending ns on frontend. |
85165 | MatrixFarm | massUpdatePools | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
| Update reward vairables for all pools. Be careful of gas spending! |
85165 | MatrixFarm | updatePool | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply;
if (address(pool.lpToken) == address(rewardToken)) {
lpSupply = userTotalDe... | Update reward variables of the given pool to be up-to-date. |
85165 | MatrixFarm | deposit | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(block.number >= pool.startBlock, "farming Not start");
require(block.number <= pool.bonusEndBlock, "farming end");
... | Deposit LP tokens to MatrixFarm for Token allocation. |
85165 | MatrixFarm | withdraw | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
require(_pid < poolInfo.length, "invalid pool id");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "invalid withdraw amount");
updatePool(_pid);
if (address(pool.lpToken) == address(reward... | Withdraw LP tokens from MatrixFarm. |
85165 | MatrixFarm | safeTokenTransfer | contract MatrixFarm is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do som... |
uint256 tokenBal = rewardToken.balanceOf(address(this));
if (_amount > tokenBal) {
rewardToken.transfer(_to, tokenBal);
} else {
rewardToken.transfer(_to, _amount);
}
| Safe token transfer function, just in case if rounding error causes pool to not have enough tokens. |
85169 | Ownable | null | contract Ownable {
address public owner;
address delegate;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {<FILL_FUNCTION... |
owner = msg.sender;
emit OwnershipTransferred(address(0), owner);
| *
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account. |
85169 | Ownable | transferOwnership | contract Ownable {
address public owner;
address delegate;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = ... |
require(newOwner != address(0));
delegate = newOwner;
| *
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to. |
85169 | StandardToken | transfer | contract StandardToken is ERC20, TransferFilter {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
modifier onlyPayloadSize(uint size) {
require(msg.data.length >= size + 4);
_;
}
/**
* @dev trans... |
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
... | *
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred. |
85169 | StandardToken | balanceOf | contract StandardToken is ERC20, TransferFilter {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
modifier onlyPayloadSize(uint size) {
require(msg.data.length >= size + 4);
_;
}
/**
* @dev trans... |
return balances[_owner];
| *
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address. |
85169 | StandardToken | transferFrom | contract StandardToken is ERC20, TransferFilter {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
modifier onlyPayloadSize(uint size) {
require(msg.data.length >= size + 4);
_;
}
/**
* @dev trans... |
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfe... | *
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.