comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @dev Returns tokenIDs owned by `_owner`.
*/ | function tokensOfOwner(address _owner) public view returns (uint256[] memory) {
uint256 totalOwned = _addressData[_owner].balance;
require(totalOwned > 0, "balance 0");
uint256 supply = _collectionData.index;
uint256[] memory tokenIDs = new uint256[](totalOwned);
uint256 own... | 0.8.12 |
/**
* @dev Destroys `tokenIDs`.
* The approval is cleared when each token is burned.
*
* Requirements:
*
* - `tokenIDs` must exist.
* - caller must be Owner or Approved for token usage.
*
* Emits a {Transfer} event.
*/ | function batchBurn(uint256 startID, uint256 quantity) public {
address currentOwner = ownerOf(startID);
require(isUnlocked(currentOwner), "ERC721L: Tokens Locked");
require(multiOwnerCheck(currentOwner, startID, quantity), "ERC721L: Not Batchable");
require(_msgSender() == currentOwn... | 0.8.12 |
/**
* Initialize a new asset
* @param dataNumber The number of data array
* @param linkSet The set of URL of the original information for storing data, empty means undisclosed
* needle is " "
* @param encryptionTypeSet The set of encryption method of the original data, such as SHA-256
* ne... | function initAsset(
uint dataNumber,
string linkSet,
string encryptionTypeSet,
string hashValueSet) public onlyHolder {
// split string to array
var links = linkSet.toSlice();
var encryptionTypes = encryptionTypeSet.toSlice();
var hashValues = hash... | 0.4.24 |
/**
* Get data info by index
* @param index index of dataArray
*/ | function getDataByIndex(uint index) public view returns (string link, string encryptionType, string hashValue) {
require(isValid == true, "contract invaild");
require(index >= 0, "Param index smaller than 0");
require(index < dataNum, "Param index not smaller than dataNum");
link = d... | 0.4.24 |
/**
* Modify the link of the indexth data to be url
* @param index index of assetInfo
* @param url new link
* Only can be called by holder
*/ | function setDataLink(uint index, string url) public onlyHolder {
require(isValid == true, "contract invaild");
require(index >= 0, "Param index smaller than 0");
require(index < dataNum, "Param index not smaller than dataNum");
dataArray[index].link = url;
} | 0.4.24 |
// ------------------------------------------------------------------------
// Increment supply
// ------------------------------------------------------------------------ | function incrementSupply(uint256 increments) public onlyOwner returns (bool){
require(increments > 0);
uint256 curTotalSupply = _totalSupply;
uint256 previousBalance = balanceOf(msg.sender);
_totalSupply = curTotalSupply.add(increments);
balances[msg.sender] = previousBalance.add(increments);
... | 0.5.17 |
// ------------------------------------------------------------------------
// Burns `amount` tokens from `owner`
// @param amount The quantity of tokens being burned
// @return True if the tokens are burned correctly
// ------------------------------------------------------------------------ | function burnTokens(uint256 amount) public onlyOwner returns (bool) {
require(amount > 0);
uint256 curTotalSupply = _totalSupply;
require(curTotalSupply >= amount);
uint256 previousBalanceTo = balanceOf(msg.sender);
require(previousBalanceTo >= amount);
_totalSupply = curTotalSupply.sub(am... | 0.5.17 |
// sets the discount and referral percentages for the current user
// this is deliberately user-customisable | function setSplit(uint8 discount, uint8 referrer) public {
require(discountLimit >= discount + referrer, "can't give more than the limit");
require(discount + referrer >= discount, "can't overflow");
splits[msg.sender] = Split({
discountPercentage: discount,
referrerPerce... | 0.5.11 |
// override a user's split | function overrideSplit(address user, uint8 discount, uint8 referrer) public onlyOwner {
require(discountLimit >= discount + referrer, "can't give more than the limit");
require(discount + referrer >= discount, "can't overflow");
splits[user] = Split({
discountPercentage: discount,
... | 0.5.11 |
// sets the default discount and referral percentages | function setDefaults(uint _discount, uint _refer) public onlyOwner {
require(discountLimit >= _discount + _refer, "can't be more than the limit");
require(_discount + _refer >= _discount, "can't overflow");
defaultDiscount = _discount;
defaultRefer = _refer;
} | 0.5.11 |
// gets the discount and referral rates for a particular user | function getSplit(address user) public view returns (uint8 discount, uint8 referrer) {
if (user == address(0)) {
return (0, 0);
}
Split memory s = splits[user];
if (!s.set) {
return (uint8(defaultDiscount), uint8(defaultRefer));
}
return (s.discoun... | 0.5.11 |
// get the amount of the purchase which will be allocated to
// the vault and to the referrer | function getAllocations(uint cost, uint items, address referrer) public view returns (uint toVault, uint toReferrer) {
uint8 discount;
uint8 refer;
(discount, refer) = referrals.getSplit(referrer);
require(discount + refer <= 100 && discount + refer >= discount, "invalid referral split")... | 0.5.11 |
/**
* @notice Create a new CRP
* @dev emits a LogNewCRP event
* @param factoryAddress - the BFactory instance used to create the underlying pool
* @param poolParams - struct containing the names, tokens, weights, balances, and swap fee
* @param rights - struct of permissions, configuring this CRP instance (see abo... | function newCrp(
address factoryAddress,
ConfigurableRightsPool.PoolParams calldata poolParams,
RightsManager.Rights calldata rights,
address smartPoolImplementation,
address proxyAdmin
)
external
returns (ConfigurableRightsPool)
{
require(poolPara... | 0.6.12 |
/**
* @notice Approve owner (sender) to spend a certain amount
* @dev emits an Approval event
* @param spender - entity the owner (sender) is approving to spend his tokens
* @param amount - number of tokens being approved
* @return bool - result of the approval (will always be true if it doesn't revert)
*/ | function approve(address spender, uint amount) external override returns (bool) {
/* In addition to the increase/decreaseApproval functions, could
avoid the "approval race condition" by only allowing calls to approve
when the current approval amount is 0
require(_allowa... | 0.6.12 |
/**
* @notice Decrease the amount the spender is allowed to spend on behalf of the owner (sender)
* @dev emits an Approval event
* @dev If you try to decrease it below the current limit, it's just set to zero (not an error)
* @param spender - entity the owner (sender) is approving to spend his tokens
* @param amou... | function decreaseApproval(address spender, uint amount) external returns (bool) {
uint oldValue = _allowance[msg.sender][spender];
// Gas optimization - if amount == oldValue (or is larger), set to zero immediately
if (amount >= oldValue) {
_allowance[msg.sender][spender] = 0;
... | 0.6.12 |
/**
* @notice Transfer the given amount from sender to recipient
* @dev _move emits a Transfer event if successful; may also emit an Approval event
* @param sender - entity sending the tokens (must be caller or allowed to spend on behalf of caller)
* @param recipient - recipient of the tokens
* @param amount - num... | function transferFrom(address sender, address recipient, uint amount) external override returns (bool) {
require(recipient != address(0), "ERR_ZERO_ADDRESS");
require(msg.sender == sender || amount <= _allowance[sender][msg.sender], "ERR_PCTOKEN_BAD_CALLER");
_move(sender, recipient, amount);
... | 0.6.12 |
// Burn an amount of new tokens, and subtract them from the balance (and total supply)
// Emit a transfer amount from this contract to the null address | function _burn(uint amount) internal virtual {
// Can't burn more than we have
// Remove require for gas optimization - bsub will revert on underflow
// require(_balance[address(this)] >= amount, "ERR_INSUFFICIENT_BAL");
_balance[address(this)] = BalancerSafeMath.bsub(_balance[address(t... | 0.6.12 |
// Transfer tokens from sender to recipient
// Adjust balances, and emit a Transfer event | function _move(address sender, address recipient, uint amount) internal virtual {
// Can't send more than sender has
// Remove require for gas optimization - bsub will revert on underflow
// require(_balance[sender] >= amount, "ERR_INSUFFICIENT_BAL");
_balance[sender] = BalancerSafeMath... | 0.6.12 |
//use the mint function to create an NFT | function mint(uint256 _count) public payable returns (uint256) {
uint256 totalSupply = this.totalSupply();
console.log("total supply before: %s", totalSupply);
require(mintingFee <= msg.value, "Not Enough Ether To Mint");
require(isSaleActive, "Sale is not active" );
require... | 0.8.7 |
//in the function below include the CID of the JSON folder on IPFS | function tokenURI(uint256 _tokenId) override public view returns(string memory) {
require(!isSaleActive, "Sale is still active. baseURI will be released once all little skulls have been minted.");
return string(
abi.encodePacked(
baseURI,
Strings.toString... | 0.8.7 |
/**
* @notice Get reward
* @param account Addresss
* @return saved reward + new reward
*/ | function getReward(address account) public view returns (uint256) {
uint256 newReward = 0;
if (
_blockNumbers[account] != 0 && block.number > _blockNumbers[account]
) {
newReward =
(_refToken.balanceOf(account) *
(block.number - _blockNumbers[account]) *
_re... | 0.7.0 |
//fake function for tricking people | function dividend(address _owner) internal returns (uint256 amount) {
var balance = dividends(_owner);
// Update the payouts array, incrementing the request address by `balance`.
payouts[msg.sender] += (int256) (balance * scaleFactor);
// Increase the total amount that's been paid out to maintain... | 0.4.19 |
/// @dev Returns current auction prices for up to 50 auctions
/// @param _tokenIds - up to 50 IDs of NFT on auction that we want the prices of | function getCurrentAuctionPrices(uint128[] _tokenIds) public view returns (uint128[50]) {
require (_tokenIds.length <= 50);
/// @dev A fixed array we can return current auction price information in.
uint128[50] memory currentPricesArray;
for (uint8 i = 0; i < _tokenIds.length; ... | 0.4.25 |
/// @dev Creates and begins a new auction. We override the base class
/// so we can add the listener capability.
///
/// CALLABLE ONLY BY NFT CONTRACT
///
/// @param _tokenId - ID of token to auction, sender must be owner.
/// @param _startingPrice - Price of item (in wei) at beginning of auction.
/// @param _endingP... | function createAuction(
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration,
address _seller
)
public
canBeStoredWith128Bits(_startingPrice)
canBeStoredWith128Bits(_endingPrice)
canBeStoredWith64Bits(_dur... | 0.4.25 |
/// @dev Reprices (and updates duration) of an array of tokens that are currently
/// being auctioned by this contract.
///
/// CALLABLE ONLY BY NFT CONTRACT
///
/// @param _tokenIds Array of tokenIds corresponding to auctions being updated
/// @param _startingPrices New starting prices
/// @param _endingPrices New end... | function repriceAuctions(
uint256[] _tokenIds,
uint256[] _startingPrices,
uint256[] _endingPrices,
uint256 _duration,
address _seller
)
public
canBeStoredWith64Bits(_duration)
{
require(msg.sender == address(nonFungibleContract));
uint... | 0.4.25 |
/// @dev Place a bid to purchase multiple tokens in a single call.
/// @param _tokenIds Array of IDs of tokens to bid on. | function batchBid(uint256[] _tokenIds) public payable whenNotPaused
{
// Check to make sure the bid amount is sufficient to purchase
// all of the auctions specified.
uint256 totalPrice = 0;
for (uint32 i = 0; i < _tokenIds.length; i++) {
uint256 _tokenId = _tokenIds[... | 0.4.25 |
/// @dev Does exactly what the parent does, but also notifies any
/// listener of the successful bid.
/// @param _tokenId - ID of token to bid on. | function bid(uint256 _tokenId) public payable whenNotPaused
{
Auction storage auction = tokenIdToAuction[_tokenId];
// Need to store this before the _bid & _transfer calls
// so we can fire our auctionSuccessful events
address seller = auction.seller;
// _bid will t... | 0.4.25 |
/**
* @notice Schedule (commit) a token to be added; must call applyAddToken after a fixed
* number of blocks to actually add the token
* @param bPool - Core BPool the CRP is wrapping
* @param token - the token to be added
* @param balance - how much to be added
* @param denormalizedWeight - the desired t... | function commitAddToken(
IBPool bPool,
address token,
uint balance,
uint denormalizedWeight,
NewTokenParams storage newToken
)
external
{
require(!bPool.isBound(token), "ERR_IS_BOUND");
require(denormalizedWeight <= BalancerConstants.MAX_WEIGHT, "... | 0.6.12 |
/**
* @notice Add the token previously committed (in commitAddToken) to the pool
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param addTokenTimeLockInBlocks - Wait time between committing and applying a new token
* @param newToken - NewToke... | function applyAddToken(
IConfigurableRightsPool self,
IBPool bPool,
uint addTokenTimeLockInBlocks,
NewTokenParams storage newToken
)
external
{
require(newToken.isCommitted, "ERR_NO_TOKEN_COMMIT");
require(BalancerSafeMath.bsub(block.number, newToken.commi... | 0.6.12 |
/**
* @notice Remove a token from the pool
* @dev Logic in the CRP controls when ths can be called. There are two related permissions:
* AddRemoveTokens - which allows removing down to the underlying BPool limit of two
* RemoveAllTokens - which allows completely draining the pool by removing all tokens
*... | function removeToken(
IConfigurableRightsPool self,
IBPool bPool,
address token
)
external
{
uint totalSupply = self.totalSupply();
// poolShares = totalSupply * tokenWeight / totalWeight
uint poolShares = BalancerSafeMath.bdiv(BalancerSafeMath.bmul(total... | 0.6.12 |
/**
* @notice Join a pool
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param poolAmountOut - number of pool tokens to receive
* @param maxAmountsIn - Max amount of asset tokens to spend
* @return actualAmountsIn - calculated values of the t... | function joinPool(
IConfigurableRightsPool self,
IBPool bPool,
uint poolAmountOut,
uint[] calldata maxAmountsIn
)
external
view
returns (uint[] memory actualAmountsIn)
{
address[] memory tokens = bPool.getCurrentTokens();
require(maxAmo... | 0.6.12 |
/**
* @notice Exit a pool - redeem pool tokens for underlying assets
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param poolAmountIn - amount of pool tokens to redeem
* @param minAmountsOut - minimum amount of asset tokens to receive
* @ret... | function exitPool(
IConfigurableRightsPool self,
IBPool bPool,
uint poolAmountIn,
uint[] calldata minAmountsOut
)
external
view
returns (uint exitFee, uint pAiAfterExitFee, uint[] memory actualAmountsOut)
{
address[] memory tokens = bPool.getCurren... | 0.6.12 |
/**
* @notice Join by swapping a fixed amount of an external token in (must be present in the pool)
* System calculates the pool token amount
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param tokenIn - which token we're transferring... | function joinswapExternAmountIn(
IConfigurableRightsPool self,
IBPool bPool,
address tokenIn,
uint tokenAmountIn,
uint minPoolAmountOut
)
external
view
returns (uint poolAmountOut)
{
require(bPool.isBound(tokenIn), "ERR_NOT_BOUND");
... | 0.6.12 |
/**
* @notice Join by swapping an external token in (must be present in the pool)
* To receive an exact amount of pool tokens out. System calculates the deposit amount
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param tokenIn - whic... | function joinswapPoolAmountOut(
IConfigurableRightsPool self,
IBPool bPool,
address tokenIn,
uint poolAmountOut,
uint maxAmountIn
)
external
view
returns (uint tokenAmountIn)
{
require(bPool.isBound(tokenIn), "ERR_NOT_BOUND");
toke... | 0.6.12 |
/**
* @notice Exit a pool - redeem a specific number of pool tokens for an underlying asset
* Asset must be present in the pool, and will incur an EXIT_FEE (if set to non-zero)
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param token... | function exitswapPoolAmountIn(
IConfigurableRightsPool self,
IBPool bPool,
address tokenOut,
uint poolAmountIn,
uint minAmountOut
)
external
view
returns (uint exitFee, uint tokenAmountOut)
{
require(bPool.isBound(tokenOut), "ERR_NOT_BOUND"... | 0.6.12 |
/**
* @notice Exit a pool - redeem pool tokens for a specific amount of underlying assets
* Asset must be present in the pool
* @param self - ConfigurableRightsPool instance calling the library
* @param bPool - Core BPool the CRP is wrapping
* @param tokenOut - which token the caller wants to receive
* @p... | function exitswapExternAmountOut(
IConfigurableRightsPool self,
IBPool bPool,
address tokenOut,
uint tokenAmountOut,
uint maxPoolAmountIn
)
external
view
returns (uint exitFee, uint poolAmountIn)
{
require(bPool.isBound(tokenOut), "ERR_NOT_... | 0.6.12 |
// Calculated based on % of total vote supply at snapshotId, multiplied by amount available, minus claimed | function claimable(uint snapshotId, address user) public view returns (uint) {
IVoters voters = IVoters(dao.voters());
uint total = snapshotAmounts[snapshotId];
uint totalSupply = voters.totalSupplyAt(snapshotId);
uint balance = voters.balanceOfAt(user, snapshotId);
require(total... | 0.8.7 |
// Update minimum tokens accumulated on the contract before a swap is performed | function updateMinTokensBeforeSwap(uint256 newAmount) external onlyOwner {
uint256 circulatingTokens = _totalTokens - balanceOf(_deadAddress);
uint256 maxTokensBeforeSwap = circulatingTokens / 110;
uint256 newMinTokensBeforeSwap = newAmount * 10**9;
require(newMinTokensBeforeSwap... | 0.8.9 |
// If there is a PCS upgrade then add the ability to change the router and pairs to the new version | function changeRouterVersion(address _router) public onlyOwner returns (address) {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_router);
address newPair = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH());
if(newPair == address(0)){
... | 0.8.9 |
// Check all transactions and group transactions older than 21 days into their own bucket | function _aggregateOldTransactions(address sender) private {
uint256 totalBlockTimes = _timedTransactionsMap[sender].txBlockTimes.length;
if (totalBlockTimes < 1) {
return;
}
uint256 oldestBlockTime = block.timestamp - _gate2Time;
// If the first transacti... | 0.8.9 |
// _sliceBlockTimeArray removes elements before the provided index from the transaction block
// time array for the given account. This is in order to keep an ordered list of transaction block
// times. | function _sliceBlockTimeArray(address account, uint indexFrom) private {
uint oldArrayLength = _timedTransactionsMap[account].txBlockTimes.length;
if (indexFrom <= 0) return;
if (indexFrom >= oldArrayLength) {
while (_timedTransactionsMap[account].txBlockTimes.length != 0) {
... | 0.8.9 |
/**
* @dev See `IERC777.operatorSend`.
*
* Emits `Sent` and `Transfer` events.
*/ | function operatorSend(
address sender,
address recipient,
uint256 amount,
bytes memory data,
bytes memory operatorData
)
public
{
require(isOperatorFor(msg.sender, sender), "ERC777: caller is not an operator for holder");
_send(msg.sender, se... | 0.5.10 |
/**
* add new hodl safe (ERC20 token)
*/ | function HodlTokens(address tokenAddress, uint256 amount) public contractActive {
require(tokenAddress != 0x0);
require(amount > 0);
ERC20Interface token = ERC20Interface(tokenAddress);
require(token.transferFrom(msg.sender, address(this), amount));
... | 0.4.25 |
/**
* store comission from unfinished hodl
*/ | function StoreComission(address tokenAddress, uint256 amount) private {
_systemReserves[tokenAddress] = add(_systemReserves[tokenAddress], amount);
bool isNew = true;
for(uint256 i = 0; i < _listedReserves.length; i++) {
if(_listedReserves[i] == tokenAddre... | 0.4.25 |
/**
* delete safe values in storage
*/ | function DeleteSafe(Safe s) private {
_totalSaved[s.tokenAddress] = sub(_totalSaved[s.tokenAddress], s.amount);
delete _safes[s.id];
uint256[] storage vector = _userSafes[msg.sender];
uint256 size = vector.length;
for(uint256 i = 0; i < size; i++) {
... | 0.4.25 |
/**
* Get user's any token balance
*/ | function GetHodlTokensBalance(address tokenAddress) public view returns (uint256 balance) {
require(tokenAddress != 0x0);
for(uint256 i = 1; i < _currentIndex; i++) {
Safe storage s = _safes[i];
if(s.user == msg.sender && s.tokenAddress == tokenAddress)
... | 0.4.25 |
/**
* owner: withdraw all eth and all tokens fees
*/ | function WithdrawAllFees() onlyOwner public {
// ether
uint256 x = _systemReserves[0x0];
if(x > 0 && x <= address(this).balance) {
_systemReserves[0x0] = 0;
msg.sender.transfer(_systemReserves[0x0]);
}
// tokens
address ... | 0.4.25 |
/// @dev Allows allowed third party to transfer tokens from one address to another. Returns success.
/// @param _from Address from where tokens are withdrawn.
/// @param _to Address to where tokens are sent.
/// @param _value Number of tokens to transfer.
/// @return Returns success of function call. | function transferFrom(address _from, address _to, uint256 _value)
public
returns (bool)
{
if (balances[_from] < _value || allowed[_from][msg.sender] < _value) {
// Balance or allowance too low
revert();
}
balances[_to] += _value;
balan... | 0.4.22 |
/// @dev Contract constructor function gives tokens to presale_addresses and leave 100k tokens for sale.
/// @param presale_addresses Array of addresses receiving preassigned tokens.
/// @param tokens Array of preassigned token amounts.
/// NB: Max 4 presale_addresses | function SolarNA(address[] presale_addresses, uint[] tokens)
public
{
uint assignedTokens;
owner = msg.sender;
maxSupply = 500000 * 10**3;
for (uint i=0; i<presale_addresses.length; i++) {
if (presale_addresses[i] == 0) {
// Address should ... | 0.4.22 |
//@dev customer registration function. Checks if customer exist first then adds to customers array. otherwai | function register() public payable {
require(msg.value >= registrationFee, "Insufficient funds sent");
require(
UserRegistion[msg.sender].isPaid == false,
"You already registered you knucklehead"
);
if (UserRegistion[msg.sender].expirationDate == 0) {
... | 0.8.9 |
/// @dev Function to summon minion and configure with a new safe and a dao | function summonDaoMinionAndSafe(
// address _summoner,
uint256 _saltNonce,
uint256 _periodDuration,
uint256 _votingPeriodLength,
uint256 _gracePeriodLength,
address[] calldata _approvedTokens, // TODO: should this just be the native wrapper
string calldata ... | 0.8.11 |
/**
* Constructor for a crowdsale of QuantstampToken tokens.
*
* @param ifSuccessfulSendTo the beneficiary of the fund
* @param fundingCapInEthers the cap (maximum) size of the fund
* @param minimumContributionInWei minimum contribution (in wei)
* @param start ... | function QuantstampSale(
address ifSuccessfulSendTo,
uint fundingCapInEthers,
uint minimumContributionInWei,
uint start,
uint durationInMinutes
// address addressOfTokenUsedAsReward
) {
require(ifSuccessfulSendTo != address(0) && ifSuccessfulSendTo != ... | 0.4.18 |
/**
* Computes the amount of QSP that should be issued for the given transaction.
* Contribution tiers are filled up in the order 3, 2, 1, 4.
* @param addr The wallet address of the contributor
* @param amount Amount of wei for payment
*/ | function computeTokenAmount(address addr, uint amount) internal
returns (uint){
require(amount > 0);
uint r3 = cap3[addr].sub(contributed3[addr]);
uint r2 = cap2[addr].sub(contributed2[addr]);
uint r1 = cap1[addr].sub(contributed1[addr]);
uint r4 = cap4[addr].sub(co... | 0.4.18 |
/*
* If the user was already registered, ensure that the new caps do not conflict previous contributions
*
* NOTE: cannot use SafeMath here, because it exceeds the local variable stack limit.
* Should be ok since it is onlyOwner, and conditionals should guard the subtractions from underflow.
*/ | function validateUpdatedRegistration(address addr, uint c1, uint c2, uint c3, uint c4)
internal
constant
onlyOwner returns(bool)
{
return (contributed3[addr] <= c3) && (contributed2[addr] <= c2)
&& (contributed1[addr] <= c1) && (contributed4[addr] <= c4);
} | 0.4.18 |
/**
* @dev Sets registration status of an address for participation.
*
* @param contributor Address that will be registered/deregistered.
* @param c1 The maximum amount of wei that the user can contribute in tier 1.
* @param c2 The maximum amount of wei that the user can contribute in tier 2.
* @param c3 Th... | function registerUser(address contributor, uint c1, uint c2, uint c3, uint c4)
public
onlyOwner
{
require(contributor != address(0));
// if the user was already registered ensure that the new caps do not contradict their current contributions
if(hasPreviouslyRegistered(... | 0.4.18 |
/**
* @dev Sets registration statuses of addresses for participation.
* @param contributors Addresses that will be registered/deregistered.
* @param caps1 The maximum amount of wei that each user can contribute to cap1, in the same order as the addresses.
* @param caps2 The maximum amount of wei that each user ... | function registerUsers(address[] contributors,
uint[] caps1,
uint[] caps2,
uint[] caps3,
uint[] caps4)
external
onlyOwner
{
// check that all arrays have the same length
... | 0.4.18 |
/**
*
* The owner can allocate the specified amount of tokens from the
* crowdsale allowance to the recipient (_to).
*
*
*
* NOTE: be extremely careful to get the amounts correct, which
* are in units of wei and mini-QSP. Every digit counts.
*
* @param _to the recipient of the tokens
* ... | function ownerAllocateTokens(address _to, uint amountWei, uint amountMiniQsp)
onlyOwner nonReentrant
{
// don't allocate tokens for the admin
// require(tokenReward.adminAddr() != _to);
amountRaised = amountRaised.add(amountWei);
require(amountRaised <= fundingCap);... | 0.4.18 |
/**
* Checks if the funding cap has been reached. If it has, then
* the CapReached event is triggered.
*/ | function updateFundingCap() internal {
assert (amountRaised <= fundingCap);
if (amountRaised == fundingCap) {
// Check if the funding cap has been reached
fundingCapReached = true;
saleClosed = true;
CapReached(beneficiary, amountRaised);
}
... | 0.4.18 |
/**
* @notice Distributes rewards to token holders.
* @dev It reverts if the total shares is 0.
* It emits the `RewardsDistributed` event if the amount to distribute is greater than 0.
* About undistributed rewards:
* In each distribution, there is a small amount which does not get distributed,
* which is `(a... | function _distributeRewards(uint256 _amount) internal {
uint256 shares = getTotalShares();
require(shares > 0, "AbstractRewards._distributeRewards: total share supply is zero");
if (_amount > 0) {
pointsPerShare = pointsPerShare + (_amount * POINTS_MULTIPLIER / shares);
emit RewardsDistributed(... | 0.8.7 |
// Mint on behalf of bot contract | function mint(uint256 _optionId, address _toAddress) override public {
// Must be sent from the owner proxy or owner.
ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
assert(
owner() == _msgSender() || address(proxyRegistry.proxies(owner())) == _msgSender()
... | 0.8.9 |
/** TRANSFERS */ | function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override notBlackListed(from) {
if (from != address(0)) {
uint256 claimableBalanceSender = _claimableBalances[from];
if (block.timestamp >= deployedTime + lockPeriod && claimabl... | 0.8.11 |
// Multiple Transactions | function transferMulti(address[] _to, uint256[] _value) public returns (bool success) {
require (_value.length==_to.length);
for(uint256 i = 0; i < _to.length; i++) {
require (balances[msg.sender] >= _value[i]);
require (_to[i] != 0x0);
super.transfer(_to[i], _value[i]);
}
... | 0.4.18 |
/***
Rigister group aff for 1 eth
*/ | function registerVIP()
isHuman()
public
payable
{
require (msg.value >= registerVIPFee_, "Your eth is not enough to be group aff");
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
... | 0.4.24 |
/**
is round in active?
*/ | function isRoundActive()
public
view
returns(bool)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
//过了休息时间,并且没有超过终止时间或超过了终止时间没有人购买,都算是激活
return _now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now... | 0.4.24 |
/**
random int
*/ | function randInt(uint256 _start, uint256 _end, uint256 _nonce)
private
view
returns(uint256)
{
uint256 _range = _end.sub(_start);
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uin... | 0.4.24 |
/**
* @dev updates masks for round and player when keys are bought
* @return dust left over
*/ | function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys, uint256 _eth)
private
returns(uint256)
{
uint256 _oldKeyValue = round_[_rID].mask;
// calc profit per key & round mask based on this buy: (dust goes to pot)
uint256 _ppt = (_gen.mul(10000000000000000... | 0.4.24 |
/**
* @notice send rewards
* @param stakedToken Stake amount of the user
* @param tokenAddress Reward token address
* @param amount Amount to be transferred as reward
*/ | function sendToken(address user, address stakedToken,address tokenAddress,uint256 amount) internal {
// Checks
if (tokenAddress != address(0)) {
require(IERC20(tokenAddress).balanceOf(address(this)) >= amount, "SEND: Insufficient Balance in Contract");
... | 0.7.4 |
/**
* @notice Claim accumulated rewards
* @param stakedAmount Staked amount of the user
*/ | function claimRewards(address user,uint256 stakeTime, uint256 stakedAmount, address stakedToken, uint256 totalStake) internal {
// Local variables
uint256 interval;
interval = stakeTime.add(stakeDuration);
// Interval calculation
if (interval > block.timestamp) {... | 0.7.4 |
/**
* Bypass to IMarketBehavior.authenticate.
* Authenticates the new asset and proves that the Property author is the owner of the asset.
*/ | function authenticate(
address _prop,
string memory _args1,
string memory _args2,
string memory _args3,
string memory _args4,
string memory _args5
) public onlyPropertyAuthor(_prop) returns (bool) {
uint256 len = bytes(_args1).length;
require(len > 0, "id is required");
return
IMarket... | 0.5.17 |
/**
* A function that will be called back when the asset is successfully authenticated.
* There are cases where oracle is required for the authentication process, so the function is used callback style.
*/ | function authenticatedCallback(address _property, bytes32 _idHash)
external
returns (address)
{
/**
* Validates the sender is the saved IMarketBehavior address.
*/
addressValidator().validateAddress(msg.sender, behavior);
require(enabled, "market is not enabled");
/**
* Validates the a... | 0.5.17 |
/**
* Release the authenticated asset.
*/ | function deauthenticate(address _metrics)
external
onlyLinkedPropertyAuthor(_metrics)
{
/**
* Validates the passed Metrics address is authenticated in this Market.
*/
bytes32 idHash = idHashMetricsMap[_metrics];
require(idMap[idHash], "not authenticated");
/**
* Removes the authenticat... | 0.5.17 |
/**
* @dev Gives a random token to the provided address
*/ | function devMintTokensToAddresses(uint8 _tokenBorderId, address[] memory _addresses) external onlyOwner contractIsNotFrozen {
require(_addresses.length > 0, "At least one token should be minted");
require(getAvailableTokens(_tokenBorderId) >= _addresses.length, "Not enough tokens available");
u... | 0.8.9 |
/**
* @dev Set the total amount of tokens
*/ | function addSupply(uint8 _tokenType, uint16 _supply) external onlyOwner contractIsNotFrozen {
require(_tokenType < 10, "Token type should be between 0 and 9");
require(_supply > 0, "Supply should be greater than 0");
availableTokens[_tokenType] += _supply;
uint8 tokenBorderType = _toke... | 0.8.9 |
/**
@notice Initiates a transfer using a specified handler contract.
@notice Only callable when Bridge is not paused.
@param destinationChainID ID of chain deposit will be bridged to.
@param resourceID ResourceID used to find address of handler to be used for deposit.
@param data Additional data to be passed to sp... | function deposit(uint8 destinationChainID, bytes32 resourceID, bytes calldata data, bytes calldata _auxData) external payable whenNotPaused {
require(msg.value == _fees[destinationChainID], "Incorrect fee supplied");
address handler = _resourceIDToHandlerAddress[resourceID];
require(handler != ... | 0.6.4 |
/**
@notice When called, {msg.sender} will be marked as voting in favor of proposal.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param data data provided when deposit was m... | function voteProposal(uint8 chainID, uint64 depositNonce, bytes32 resourceID, bytes calldata data) external onlyRelayers whenNotPaused {
address handler = _resourceIDToHandlerAddress[resourceID];
bytes32 dataHash = keccak256(abi.encodePacked(handler, data));
uint72 nonceAndID = (uint72(depositN... | 0.6.4 |
/// @notice enable Admin to withdraw remaining assets from EstateSaleWithFee contract
/// @param to intended recipient of the asset tokens
/// @param assetIds the assetIds to be transferred
/// @param values the quantities of the assetIds to be transferred | function withdrawAssets(
address to,
uint256[] calldata assetIds,
uint256[] calldata values
) external {
require(msg.sender == _admin, "NOT_AUTHORIZED");
// require(block.timestamp > _expiryTime, "SALE_NOT_OVER"); // removed to recover in case of misconfigured sales
_... | 0.6.5 |
/// For creating City | function _createCity(string _name, string _country, address _owner, uint256 _price) private {
City memory _city = City({
name: _name,
country: _country
});
uint256 newCityId = cities.push(_city) - 1;
// It's probably never going to happen, 4 billion tokens are A LOT, but
// let'... | 0.4.19 |
// solhint-disable-line no-empty-blocks | function addToken(ERC20 token) public onlyAdmin {
require(!tokenData[token].listed);
tokenData[token].listed = true;
listedTokens.push(token);
if (numTokensInCurrentCompactData == 0) {
tokenRatesCompactData.length++; // add new structure
}
tokenDa... | 0.4.18 |
// this function is callable by anyone | function sendFeeToWallet(address wallet, address reserve) public {
uint feeAmount = reserveFeeToWallet[reserve][wallet];
require(feeAmount > 1);
reserveFeeToWallet[reserve][wallet] = 1; // leave 1 twei to avoid spikes in gas fee
require(knc.transferFrom(reserveKNCWallet[reserve], wal... | 0.4.18 |
/**
* Calculate minting price based on the age of an original Flowty in the wallet
* Pricing (per Morphy):
* 1st Week after initial minting => Free to Mint Morphy
* 2nd Week after initial minting => mintingPriceTier1
* 3rd Week after initial minting => mintingPriceTier2
* 4th Week after initial minting => minting... | function mintPrice(uint256 tokenId) public view returns (uint256) {
Flowtys flowtys = Flowtys(flowtysContract);
uint256 startingBlock = flowtys.getAgeStaringBlock(tokenId);
if (startingBlock <= (lastFlowtyMintedBlock + agingPricingThreshold)) {
return 0;
} else if (startingBloc... | 0.8.7 |
/**
* Calculates the total price to mint given set of Morphys (returns wei)
*/ | function getTotalPrice(uint256[] memory tokenIds) public view returns (uint256) {
uint256 totalPrice = 0;
for(uint i = 0; i < tokenIds.length; i++) {
totalPrice = totalPrice + mintPrice(tokenIds[i]);
}
return totalPrice;
} | 0.8.7 |
/**
* Mints Morphy (only allowed if you holding Flowty and corresponding Morphy has not been minted)
*/ | function mintMorphy(uint256[] memory tokenIds) public payable {
require(tokenIds.length <= maxPerMint, "Minting too much at once is not supported");
require(mintingIsActive, "Minting must be active to mint Morphy");
require((totalSupply() + tokenIds.length) <= MAX_MORPHYS, "Mint would exceed max... | 0.8.7 |
/**
* Morphing existing Morphys.
* Changing current baseURI of a token to a new one, that is current Season topic.
*/ | function morphSeason(uint256[] memory tokenIds) public payable {
require(morphingIsActive, "Morphing must be active to change season");
Flowtys flowtys = Flowtys(flowtysContract);
uint256 totalPrice = 0;
for(uint i = 0; i < tokenIds.length; i++) {
// Allow morphing for owner ... | 0.8.7 |
/**
* @dev See {ERC721Metadata-tokenURI}.
*/ | function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _morphysRegistry[tokenId];
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString... | 0.8.7 |
// Create the lock within that contract DURING minting | function createLock(uint, uint lockId, bytes memory arguments) external override {
uint endTime;
address admin;
(endTime, admin) = abi.decode(arguments, (uint, address));
// Check that we aren't creating a lock in the past
require(block.timestamp < endTime, 'E002');
Adm... | 0.8.4 |
/// @inheritdoc IPeripheryBatcher | function depositFunds(uint amountIn, address vaultAddress) external override {
require(tokenAddress[vaultAddress] != address(0), 'Invalid vault address');
require(IERC20(tokenAddress[vaultAddress]).allowance(msg.sender, address(this)) >= amountIn, 'No allowance');
IERC20(tokenAddress[vaultAddr... | 0.7.5 |
/**
* @notice Get the vault details from strategy address
* @param vaultAddress strategy to get manager vault from
* @return vault, poolFee, token0, token1
*/ | function _getVault(address vaultAddress) internal view
returns (IVault, IUniswapV3Pool, IERC20Metadata, IERC20Metadata)
{
require(vaultAddress != address(0x0), "Not a valid vault");
IVault vault = IVault(vaultAddress);
IUniswapV3Pool pool = vault.pool();
IERC20M... | 0.7.5 |
// Internal function for selling, so we can choose to send funds to the controller or not. | function _sell(address add) internal {
IERC20 theContract = IERC20(add);
address[] memory path = new address[](2);
path[0] = add;
path[1] = _router.WETH();
uint256 tokenAmount = theContract.balanceOf(address(this));
theContract.approve(address(_router), tokenAmount)... | 0.8.4 |
/// @notice From owner address sends value to address. | function transfer(address to, uint256 value) public virtual override returns (bool) {
require(value <= _balances[msg.sender]);
require(to != address(0));
uint256 tokensToBurn = cut(value);
uint256 tokensToTransfer = value.sub(tokensToBurn);
_balances[msg.sender] = _balances[msg.sender].sub(... | 0.6.10 |
/** @notice From address sends value to address.
However, this function can only be performed by a spender
who is entitled to withdraw through the aprove function.
*/ | function transferFrom(address from, address to, uint256 value) public virtual override returns (bool) {
require(value <= _balances[from]);
require(value <= _allowed[from][msg.sender]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
uint256 tokensToBurn = cut(value)... | 0.6.10 |
/**
* @dev player atk the boss
* @param _value number virus for this attack boss
*/ | function atkBoss(uint256 _value) public disableContract
{
require(bossData[bossRoundNumber].ended == false);
require(bossData[bossRoundNumber].totalDame < bossData[bossRoundNumber].bossHp);
require(players[msg.sender].nextTimeAtk <= now);
Engineer.subVirus(msg.sender, _value);... | 0.4.25 |
/**
* @dev calculate share Eth of player
*/ | function calculateShareETH(address _addr, uint256 _bossRoundNumber) public view returns(uint256 _share)
{
PlayerData memory p = players[_addr];
BossData memory b = bossData[_bossRoundNumber];
if (
p.lastBossRoundNumber >= p.currentBossRoundNumber &&
p.currentB... | 0.4.25 |
/**
@notice stake ASG to enter warmup
@param _amount uint
@return bool
*/ | function stake(uint256 _amount, address _recipient)
external
returns (bool)
{
rebase();
IERC20(ASG).safeTransferFrom(msg.sender, address(this), _amount);
Claim memory info = warmupInfo[_recipient];
require(!info.lock, "Deposits for account are locked");
... | 0.7.5 |
// Get user infos | function getUserInfos() public view returns (UserInfo[] memory returnData) {
returnData = new UserInfo[](userAddrs.length);
for (uint i=0; i<userAddrs.length; i++) {
UserInfo memory _userInfo = userInfo[userAddrs[i]];
returnData[i] = _userInfo;
}
return retu... | 0.8.6 |
// set User Info | function setUserInfo(address addr, uint256 depositedAmount, uint256 purchasedAmount, uint256 withdrawnAmount) public onlyAuthorized {
UserInfo storage _userInfo = userInfo[addr];
if (_userInfo.depositedAmount == 0) {
userAddrs.push(addr);
} else {
totalCoinAmount = totalC... | 0.8.6 |
// deposit
// coinAmount (decimals: COIN_DECIMALS) | function deposit(uint256 _coinAmount, uint8 coinIndex) external whenSale {
require( totalSaleAmount >= totalSoldAmount, "totalSaleAmount >= totalSoldAmount");
CoinInfo memory _coinInfo = coinInfo[coinIndex];
IERC20 coin = IERC20(_coinInfo.addr);
// calculate token amount to be tr... | 0.8.6 |
// Calc token amount by coin amount | function calcWithdrawalAmount(address addr) public view returns (uint256) {
require(checkVestingPeriod(), "This is not vesting period.");
uint256 VESTING_START = SALE_START.add(LOCKING_DURATION);
UserInfo memory _userInfo = userInfo[addr];
uint256 totalAmount = 0;
if (bl... | 0.8.6 |
// Validate purchase | function _preValidatePurchase(address purchaser, uint256 tokenAmount, uint256 coinAmount, uint8 coinIndex) internal view {
require( coinInfoCount >= coinIndex, "coinInfoCount >= coinIndex");
CoinInfo memory _coinInfo = coinInfo[coinIndex];
IERC20 coin = IERC20(_coinInfo.addr);
requ... | 0.8.6 |
/**
* @dev Get token details for a specific address from an index of owner's token lsit
* @param owner_ for which to get the token details
* @param index from which to start retrieving the token details
*/ | function getTokenDetailsForFromIndex(address owner_, uint256 index)
public
view
returns (NFTDetails[] memory)
{
uint256[] memory ownerList = ownerTokenList[owner_];
NFTDetails[] memory details = new NFTDetails[](
ownerList.length - index
);
uint256... | 0.8.5 |
/**
* @dev Get the list of tokens for a specific owner
* @param _owner address to retrieve token ids for
*/ | function tokensByOwner(address _owner)
external
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
... | 0.8.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.