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 |
|---|---|---|---|---|---|
339 | ERC721 | getApproved | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
| *
* @dev See {IERC721-getApproved}. |
339 | ERC721 | setApprovalForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
| *
* @dev See {IERC721-setApprovalForAll}. |
339 | ERC721 | isApprovedForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
return _operatorApprovals[owner][operator];
| *
* @dev See {IERC721-isApprovedForAll}. |
339 | ERC721 | transferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| *
* @dev See {IERC721-transferFrom}. |
339 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
safeTransferFrom(from, to, tokenId, "");
| *
* @dev See {IERC721-safeTransferFrom}. |
339 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
| *
* @dev See {IERC721-safeTransferFrom}. |
339 | ERC721 | _safeTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
| *
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This i... |
339 | ERC721 | _exists | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
return _owners[tokenId] != address(0);
| *
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`). |
339 | ERC721 | _isApprovedOrOwner | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
| *
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist. |
339 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
_safeMint(to, tokenId, "");
| *
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event. |
339 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
| *
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients. |
339 | ERC721 | _mint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
| *
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event. |
339 | ERC721 | _burn | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
| *
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event. |
339 | ERC721 | _transfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
... | *
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event. |
339 | ERC721 | _approve | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
| *
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event. |
339 | ERC721 | _checkOnERC721Received | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... |
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
... | *
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the to... |
339 | ERC721 | _beforeTokenTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _ow... | *
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to... | |
340 | EtherKebab | calculateTrade | contract EtherKebab{
uint256 public KEBABER_TO_MAKE_1KEBAB=86400;//for final version should be seconds in a day
uint256 public STARTING_KEBAB=150;
uint256 PSN=10000;
uint256 PSNH=5000;
bool public initialized=false;
address public ceoAddress = 0xdf4703369ecE603a01e049e34e438ff74Cd96D66;
... |
//(PSN*bs)/(PSNH+((PSN*rs+PSNH*rt)/rt));
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
| magic trade balancing algorithm |
341 | VHW | VHW | contract VHW is Ownable, ERC20Interface {
using SafeMath for uint;
uint public _totalSupply = 352500000000000;
string public constant name = "VHW";
string public constant symbol = "VHW";
uint public constant decimals = 6;
string public standard = "VHW Token";
mapping (address => uint) balances;... |
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
| Constructor |
341 | VHW | totalSupply | contract VHW is Ownable, ERC20Interface {
using SafeMath for uint;
uint public _totalSupply = 352500000000000;
string public constant name = "VHW";
string public constant symbol = "VHW";
uint public constant decimals = 6;
string public standard = "VHW Token";
mapping (address => uint) balances;... |
return _totalSupply;
| Total supply |
341 | VHW | balanceOf | contract VHW is Ownable, ERC20Interface {
using SafeMath for uint;
uint public _totalSupply = 352500000000000;
string public constant name = "VHW";
string public constant symbol = "VHW";
uint public constant decimals = 6;
string public standard = "VHW Token";
mapping (address => uint) balances;... |
return balances[_owner];
| Get the token balance of address |
341 | VHW | transfer | contract VHW is Ownable, ERC20Interface {
using SafeMath for uint;
uint public _totalSupply = 352500000000000;
string public constant name = "VHW";
string public constant symbol = "VHW";
uint public constant decimals = 6;
string public standard = "VHW Token";
mapping (address => uint) balances;... |
require(_to != 0x0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
| Transfer tokens from owner address |
342 | ERC20 | _transfer_ARTX | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
uint25... |
require(recipient == address(0), "ERC20: transfer to the zero address");
require(sender != address(0), "ERC20: transfer from the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance... | transfer |
344 | 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() public {<FILL_FUNCTION_BODY>}
/... |
owner = msg.sender;
| *
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account. |
344 | Ownable | transferOwnership | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}... |
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. |
344 | BasicToken | transfer | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) pub... |
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);
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. |
344 | BasicToken | balanceOf | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) pub... |
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. |
344 | StandardToken | transferFrom | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transf... |
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_fr... | *
* @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 |
344 | StandardToken | approve | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transf... |
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
| *
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate thi... |
344 | StandardToken | allowance | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transf... |
return allowed[_owner][_spender];
| *
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender. |
344 | StandardToken | increaseApproval | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transf... |
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
| *
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @... |
344 | StandardToken | decreaseApproval | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transf... |
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
| *
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @... |
344 | MintableToken | mint | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that ... |
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
| *
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful. |
344 | MintableToken | finishMinting | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that ... |
mintingFinished = true;
MintFinished();
return true;
| *
* @dev Function to stop minting new tokens.
* @return True if the operation was successful. |
344 | SelfKeyToken | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
cap = _cap;
| *
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap. |
344 | SelfKeyToken | mint | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
| *
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint |
344 | SelfKeyToken | transfer | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
return super.transfer(_to, _value);
| *
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send |
344 | SelfKeyToken | transferFrom | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
return super.transferFrom(_from, _to, _value);
| *
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send |
344 | SelfKeyToken | enableTransfers | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
transfersEnabled = true;
| *
* @dev Enables token transfers.
* Called when the token sale is successfully finalized |
344 | SelfKeyToken | burn | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint25... |
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
| *
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned. |
344 | TokenTimelock | release | contract TokenTimelock {
using SafeERC20 for ERC20Basic;
// ERC20 basic token contract being held
ERC20Basic public token;
// beneficiary of tokens after they are released
address public beneficiary;
// timestamp when token release is enabled
uint256 public releaseTime;
function TokenTim... |
require(now >= releaseTime);
uint256 amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
| *
* @notice Transfers tokens held by timelock to beneficiary. |
344 | SelfKeyCrowdsale | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.... | *
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell. |
344 | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
buyTokens(msg.sender);
| *
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal | |
344 | SelfKeyCrowdsale | addVerifier | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
isVerifier[_address] = true;
| *
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier |
344 | SelfKeyCrowdsale | removeVerifier | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
isVerifier[_address] = false;
| *
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed |
344 | SelfKeyCrowdsale | setStartTime | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
| *
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time |
344 | SelfKeyCrowdsale | setEndTime | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
| *
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time |
344 | SelfKeyCrowdsale | setEthPrice | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
| *
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate |
344 | SelfKeyCrowdsale | finalize | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
| *
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function. |
344 | SelfKeyCrowdsale | claimRefund | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
| *
* @dev If crowdsale is unsuccessful, a refund can be claimed back |
344 | SelfKeyCrowdsale | goalReached | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
return totalPurchased >= goal;
| *
* @dev If crowdsale is unsuccessful, participants can claim refunds |
344 | SelfKeyCrowdsale | releaseLockFounders1 | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
foundersTimelock1.release();
| *
* @dev Release time-locked tokens |
344 | SelfKeyCrowdsale | releaseLock | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
| *
* @dev Release time-locked tokens for any vested address |
344 | SelfKeyCrowdsale | verifyKYC | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
kycVerified[participant] = true;
VerifiedKYC(participant);
| *
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres |
344 | SelfKeyCrowdsale | addPrecommitment | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[benef... | *
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be ... |
344 | SelfKeyCrowdsale | finalization | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
| *
* @dev Additional finalization logic. Enables token transfers. |
344 | SelfKeyCrowdsale | buyTokens | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rat... | *
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser |
344 | SelfKeyCrowdsale | burnUnsold | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;... |
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
| *
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization |
348 | 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. |
348 | 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. |
348 | 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 ... |
348 | 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`).
* Can only be called by the current owner. |
348 | ERC20 | null | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_name = name;
_symbol = symbol;
_decimals = 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. |
348 | ERC20 | name | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
return _name;
| *
* @dev Returns the name of the token. |
348 | ERC20 | symbol | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
return _symbol;
| *
* @dev Returns the symbol of the token, usually a shorter version of the
* name. |
348 | ERC20 | decimals | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
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
* ... |
348 | ERC20 | totalSupply | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
return _totalSupply;
| *
* @dev See {IERC20-totalSupply}. |
348 | ERC20 | balanceOf | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
return _balances[account];
| *
* @dev See {IERC20-balanceOf}. |
348 | ERC20 | transfer | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_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`. |
348 | ERC20 | allowance | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
return _allowances[owner][spender];
| *
* @dev See {IERC20-allowance}. |
348 | ERC20 | approve | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_approve(_msgSender(), spender, amount);
return true;
| *
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address. |
348 | ERC20 | transferFrom | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_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 ha... |
348 | ERC20 | increaseAllowance | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_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.
*
* Requi... |
348 | ERC20 | decreaseAllowance | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_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.
*
* Requi... |
348 | ERC20 | _transfer | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
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 bal... | *
* @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... |
348 | ERC20 | _mint | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
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
*
* - `to` cannot be the zero address. |
348 | ERC20 | _burn | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
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. |
348 | ERC20 | _approve | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
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:
... |
348 | ERC20 | _setupDecimals | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... |
_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. |
348 | ERC20 | _beforeTokenTransfer | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private ... | *
* @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 ... | |
348 | RiyadhCityToken | mint | contract RiyadhCityToken is ERC20("RIYADH.cityswap.io", "RIYADH"), Ownable {
uint256 public constant MAX_SUPPLY = 5041000 * 10**18;
/**
* @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency).
*/
function mint(address _to, uint256 _amount) ... |
uint256 _totalSupply = totalSupply();
if(_totalSupply.add(_amount) > MAX_SUPPLY) {
_amount = MAX_SUPPLY.sub(_totalSupply);
}
require(_totalSupply.add(_amount) <= MAX_SUPPLY);
_mint(_to, _amount);
| *
* @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency). |
348 | RiyadhAgency | add | contract RiyadhAgency 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.
//
// W... |
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _alloc... | 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. |
348 | RiyadhAgency | set | contract RiyadhAgency 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.
//
// W... |
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
| Update the given pool's CITY allocation point. Can only be called by the owner. |
348 | RiyadhAgency | getMultiplier | contract RiyadhAgency 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.
//
// W... |
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
... | Return reward multiplier over the given _from to _to block. |
348 | RiyadhAgency | pendingCity | contract RiyadhAgency 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.
//
// W... |
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 ... | View function to see pending CITYs on frontend. |
348 | RiyadhAgency | massUpdatePools | contract RiyadhAgency 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.
//
// W... |
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
| Update reward vairables for all pools. Be careful of gas spending! |
348 | RiyadhAgency | mint | contract RiyadhAgency 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.
//
// W... |
city.mint(devaddr, amount);
| Update reward variables of the given pool to be up-to-date. |
348 | RiyadhAgency | updatePool | contract RiyadhAgency 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.
//
// W... |
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
... | Update reward variables of the given pool to be up-to-date. |
348 | RiyadhAgency | deposit | contract RiyadhAgency 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.
//
// W... |
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending... | Deposit LP tokens to TravelAgency for CITY allocation. |
348 | RiyadhAgency | withdraw | contract RiyadhAgency 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.
//
// W... |
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTran... | Withdraw LP tokens from MasterChef. |
348 | RiyadhAgency | emergencyWithdraw | contract RiyadhAgency 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.
//
// W... |
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
| Withdraw without caring about rewards. EMERGENCY ONLY. |
348 | RiyadhAgency | safeCityTransfer | contract RiyadhAgency 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.
//
// W... |
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
| Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs. |
348 | RiyadhAgency | dev | contract RiyadhAgency 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.
//
// W... |
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
| Update dev address by the previous dev. |
349 | LERC20 | getAdmin | contract LERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
address public recoveryAdmin;
address private recov... |
return admin;
| --- LOSSLESS management --- |
349 | LERC20 | name | contract LERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
address public recoveryAdmin;
address private recov... |
return _name;
| --- ERC20 methods --- |
352 | BControllerErrorReporter | fail | contract BControllerErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
BCONTROLLER_MISMATCH,
INSUFFICIENT_SHORTFALL,
INSUFFICIENT_LIQUIDITY,
INVALID_CLOSE_FACTOR,
INVALID_COLLATERAL_FACTOR,
INVALID_LIQUIDATION_INCENTIVE,
MARKET_NOT_ENTERED, /... |
emit Failure(uint(err), uint(info), 0);
return uint(err);
| *
* @dev use this when reporting a known error from the money market or a non-upgradeable collaborator |
352 | BControllerErrorReporter | failOpaque | contract BControllerErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
BCONTROLLER_MISMATCH,
INSUFFICIENT_SHORTFALL,
INSUFFICIENT_LIQUIDITY,
INVALID_CLOSE_FACTOR,
INVALID_COLLATERAL_FACTOR,
INVALID_LIQUIDATION_INCENTIVE,
MARKET_NOT_ENTERED, /... |
emit Failure(uint(err), uint(info), opaqueError);
return uint(err);
| *
* @dev use this when reporting an opaque error from an upgradeable collaborator contract |
352 | TokenErrorReporter | fail | contract TokenErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
BAD_INPUT,
BCONTROLLER_REJECTION,
BCONTROLLER_CALCULATION_ERROR,
INTEREST_RATE_MODEL_ERROR,
INVALID_ACCOUNT_PAIR,
INVALID_CLOSE_AMOUNT_REQUESTED,
INVALID_COLLATERAL_FACTOR,
... |
emit Failure(uint(err), uint(info), 0);
return uint(err);
| *
* @dev use this when reporting a known error from the money market or a non-upgradeable collaborator |
352 | TokenErrorReporter | failOpaque | contract TokenErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
BAD_INPUT,
BCONTROLLER_REJECTION,
BCONTROLLER_CALCULATION_ERROR,
INTEREST_RATE_MODEL_ERROR,
INVALID_ACCOUNT_PAIR,
INVALID_CLOSE_AMOUNT_REQUESTED,
INVALID_COLLATERAL_FACTOR,
... |
emit Failure(uint(err), uint(info), opaqueError);
return uint(err);
| *
* @dev use this when reporting an opaque error from an upgradeable collaborator contract |
352 | CarefulMath | mulUInt | contract CarefulMath {
/**
* @dev Possible error codes that we can return
*/
enum MathError {
NO_ERROR,
DIVISION_BY_ZERO,
INTEGER_OVERFLOW,
INTEGER_UNDERFLOW
}
/**
* @dev Multiplies two numbers, returns an error on overflow.
*/
function mulUInt(uin... |
if (a == 0) {
return (MathError.NO_ERROR, 0);
}
uint c = a * b;
if (c / a != b) {
return (MathError.INTEGER_OVERFLOW, 0);
} else {
return (MathError.NO_ERROR, c);
}
| *
* @dev Multiplies two numbers, returns an error on overflow. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.