comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/** * A Scribe is a contract that is allowed to write Lore *if* the transaction * originated from the token owner. For example, The Great Burning may write * the death of a Wizard and the inception of their Soul */
function addLoreWithScribe( address tokenContract, uint256 tokenId, uint256 parentLoreId, bool nsfw, string memory loreMetadataURI ) public onlyAllowedTokenContract(tokenContract) { require(scribeAllowlist[_msgSender()], 'sender is not a Scribe'); address tok...
0.8.0
/** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */
function finishMinting() onlyOwner canMint public returns (bool) { require(foundationAddress != address(0) && teamAddress != address(0) && bountyAddress != address(0)); require(SHARE_PURCHASERS + SHARE_FOUNDATION + SHARE_TEAM + SHARE_BOUNTY == 1000); require(totalSupply_ != 0); // before cal...
0.4.24
/** * @dev Returns the data about a token. */
function getDataForTokenId(uint256 _tokenId) public view returns ( uint, string, uint, uint, address, address, uint ) { metaData storage meta = tokenToMetaData[_tokenId]; return ( _tokenId, meta.se...
0.4.25
// Converts uint to a string
function uint2str(uint i) internal pure returns (string){ if (i == 0) return "0"; uint j = i; uint length; while (j != 0){ length++; j /= 10; } bytes memory bstr = new bytes(length); uint k = length - 1; while (i != 0){ ...
0.4.25
// Vesting Issue Function -----
function issue_Vesting_RND(address _to, uint _time) onlyOwner_creator public { require(saleTime == false); require(vestingReleaseRound_RND >= _time); uint time = now; require( ( ( endSaleTime + (_time * vestingReleaseTime_RND) ) < time ) && ( vestingRelease_RND[_time] ...
0.5.0
// accept ether subscription payments // only one time per address // msg.value = ticketPriceWei + expected future price format in wei // Example // 1. ticketPrice is 0.01 Ether // 2. Your future price prediction is 9588.25 // 3. You send 0.1 + 0.0000000000958825 // 4. The contract registers your prediction of 958825...
function() payable external { require(status == 0, 'closed'); require(msg.value > ticketPriceWei && msg.value < ticketPriceWei + 10000000, 'invalid ticket price'); require(futures[msg.sender] == 0, 'already in'); uint future = msg.value - ticketPriceWei; futures[msg.sender] ...
0.5.17
// close subscription doors
function closeSubscriptions() public { require(msg.sender == factory, 'only factory'); require(status == 0, 'wrong transition'); status = 1; // in case of one+ subscribers // lunch the next solution timer if(subscribers.length == 0) { status = 2; ...
0.5.17
// if the execution did not happen after 24 hours // the beneficiary can withdraw total amount same share // equally with the subscribers
function rollback() public { // should be not distributed require(status < 3, 'already distributed'); // only the beneficiary can do it require(msg.sender == beneficiary, 'only beneficiary'); // at least 24H passed without execution uin...
0.5.17
// set the solution and alarm the distribution // pay the factory and tell about the gas Limit
function executeResult(uint solution) public returns (uint gasLimit) { require(msg.sender == factory, 'only factory'); require(status == 1, 'wrong transition'); status = 2; winSolution = solution; emit RoundExecuted(winSolution); // default provable 20 GWei per Ga...
0.5.17
// Blacklist Lock & Unlock functions. // Unlocking the blacklist requires a minimum of 3 days notice.
function unlockBlacklist(bool _limitedBlacklist, uint _daysUntilUnlock) external onlyOwner { require(_daysUntilUnlock > 2, "Unlocking blacklist functionality requires a minimum of 3 days notice."); blacklistUnlockTimestamp = now + (_daysUntilUnlock * 60 * 60 * 24); limitedBlacklist = _limited...
0.6.12
//lock LOCK tokens to contract
function LockTokens(uint amt) public { require(amt > 0, "zero input"); require(tokenBalance() >= amt, "Error: insufficient balance");//ensure user has enough funds tokenLockedBalances[msg.sender] = tokenLockedBalances[msg.sender].add(amt); totalLocked = totalLocked.add(...
0.6.4
//unlock LOCK tokens from contract
function UnlockTokens(uint amt) public { require(amt > 0, "zero input"); require(tokenLockedBalances[msg.sender] >= amt,"Error: unsufficient frozen balance");//ensure user has enough locked funds tokenLockedBalances[msg.sender] = tokenLockedBalances[msg.sender].sub(amt);//update...
0.6.4
//stakes hex - transfers HEX from user to contract - approval needed
function stakeHex(uint hearts, uint dayLength, address payable ref) internal returns(bool) { //send require(hexInterface.transferFrom(msg.sender, address(this), hearts), "Transfer failed");//send hex from user to contract //user info updateUserData(hearts); ...
0.6.4
//updates user data
function updateUserData(uint hearts) internal { UserInfo storage user = users[msg.sender]; lifetimeHeartsStaked += hearts; if(user.totalHeartsStaked == 0){ userCount++; } user.totalHeartsStaked = user.totalHeartsStaked.add(hearts);//total amount of...
0.6.4
//updates stake data
function updateStakeData(uint hearts, uint dayLength, address payable ref, uint index) internal { uint _stakeId = _next_stake_id();//new stake id userStakeIds[msg.sender].push(_stakeId);//update userStakeIds StakeInfo memory stake; stake.heartValue = hearts;//amount of ...
0.6.4
//general stake info
function getStakeInfo(uint stakeId) public view returns( uint heartValue, uint stakeDayLength, uint hexStakeId, uint hexStakeIndex, address payable userAddress, address payable refferer, uint stakeStartTimestamp...
0.6.4
/** * @dev Add wallet that received pre-minted tokens to the list in the Governance contract. * The contract owner should be GovernanceProxy contract. * This Escrow contract address should be added to Governance contract (setEscrowContract). * @param wallet The address of wallet. */
function _addPremintedWallet(address wallet, uint256 groupId) internal { require(groupId < groups.length, "Wrong group"); IGovernance(governanceContract).addPremintedWallet(wallet); inGroup[wallet] = groupId + 1; // groupId + 1 (0 - mean that wallet not added) groups[groupId].wall...
0.6.12
/** * @dev whitelist buy */
function whitelistBuy( uint256 qty, uint256 tokenId, bytes32[] calldata proof ) external payable whenNotPaused { require(qty <= 2, "max 2"); require(tokenPrice * qty == msg.value, "exact amount needed"); require(usedAddresses[msg.sender] + qty <= 2, "max per wallet reached"); require(block.timestamp > wh...
0.8.11
/** * @dev everyone can mint freely */
function buy(uint256 qty) external payable whenNotPaused { require(tokenPrice * qty == msg.value, "exact amount needed"); require(qty < 6, "max 5 at once"); require(totalSupply() + qty <= maxSupply, "out of stock"); require(block.timestamp > publicSaleStartTime, "not live"); _safeMint(msg.sender, qty); }
0.8.11
/** * @dev verification function for merkle root */
function isTokenValid( address _to, uint256 _tokenId, bytes32[] memory _proof ) public view returns (bool) { // construct Merkle tree leaf from the inputs supplied bytes32 leaf = keccak256(abi.encodePacked(_to, _tokenId)); // verify the proof supplied, and return the verification result return _proof.ver...
0.8.11
//---------------------------------- //----------- other code ----------- //----------------------------------
function tokensOfOwner(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); uint256 index; for (index = 0; index < tokenCount; index++) { resu...
0.8.11
// earnings withdrawal
function withdraw() public payable onlyOwner { uint256 _total_owner = address(this).balance; (bool all1, ) = payable(0xed6f9E7d3A94141E28cA5D1905d2EA9F085D00FA).call{ value: (_total_owner * 1) / 3 }(""); //l require(all1); (bool all2, ) = payable(0x318cbB40Fdaf1A2Ab545B957518cb95D7c18ED32).call{ value:...
0.8.11
/** * @dev internal function of `trade`. * It verifies user signature, transfer tokens from user and store tx hash to prevent replay attack. */
function _prepare( bool fromEth, IWETH weth, address _makerAddr, address _takerAssetAddr, address _makerAssetAddr, uint256 _takerAssetAmount, uint256 _makerAssetAmount, address _userAddr, address _receiverAddr, uint256 _salt, ...
0.6.12
/** * @dev internal function of `trade`. * It executes the swap on chosen AMM. */
function _swap( bool makerIsUniV2, address _makerAddr, address _takerAssetAddr, address _makerAssetAddr, uint256 _takerAssetAmount, uint256 _makerAssetAmount, uint256 _deadline, uint256 _subsidyFactor ) internal returns (string memory source, ...
0.6.12
/** * @dev gets total ether claimed for characters in account. */
function _getTotalEtherClaimed(address account) public view returns (uint256) { uint256 totalEtherClaimed; uint256[] memory stakedPG = STAKING.getStakerTokens(account, address(PG)); uint256[] memory stakedAP = STAKING.getStakerTokens(account, address(AP)); for (uint256 i; i < PG.balanceOf(account); i++) { ...
0.8.0
/** * @dev Deposit interest (add to savings) and update exchange rate of contract. * Exchange rate is calculated as the ratio between new savings q and credits: * exchange rate = savings / credits * * @param _amount Units of underlying to add to the savings vault */
function depositInterest(uint256 _amount) external onlySavingsManager { require(_amount > 0, "Must deposit something"); // Transfer the interest from sender to here require(mUSD.transferFrom(msg.sender, address(this), _amount), "Must receive tokens"); totalSa...
0.5.16
/** * @dev Deposit the senders savings to the vault, and credit them internally with "credits". * Credit amount is calculated as a ratio of deposit amount and exchange rate: * credits = underlying / exchangeRate * If automation is enabled, we will first update the internal exchange ...
function depositSavings(uint256 _amount) external returns (uint256 creditsIssued) { require(_amount > 0, "Must deposit something"); if(automateInterestCollection) { // Collect recent interest generated by basket and update exchange rate ISavingsManage...
0.5.16
/** * @dev Redeem specific number of the senders "credits" in exchange for underlying. * Payout amount is calculated as a ratio of credits and exchange rate: * payout = credits * exchangeRate * @param _credits Amount of credits to redeem * @return massetReturned Units of under...
function redeem(uint256 _credits) external returns (uint256 massetReturned) { require(_credits > 0, "Must withdraw something"); uint256 saverCredits = creditBalances[msg.sender]; require(saverCredits >= _credits, "Saver has no credits"); creditBalances[msg....
0.5.16
//return (or revert) with a string in the given length
function checkReturnValues(uint len, bool doRevert) public view returns (string memory) { (this); string memory mesg = "this is a long message that we are going to return a small part from. we don't use a loop since we want a fixed gas usage of the method itself."; require( bytes(mesg).length>=l...
0.6.10
/* * @param rawTransaction RLP encoded ethereum transaction * @return tuple (nonce,gasPrice,gasLimit,to,value,data) */
function decodeTransaction(bytes memory rawTransaction) internal pure returns (uint, uint, uint, address, uint, bytes memory){ RLPReader.RLPItem[] memory values = rawTransaction.toRlpItem().toList(); // must convert to an rlpItem first! return (values[0].toUint(), values[1].toUint(), values[2].toUint(),...
0.6.10
// Getter and Setter for ledger
function setLedger(uint8 _index, int _value) public { require(FD_AC.checkPermission(101, msg.sender)); int previous = ledger[_index]; ledger[_index] += _value; // --> debug-mode // LogInt("previous", previous); // LogInt("ledger[_index]", ledger[_index]); // ...
0.4.18
/** * @dev Reverts the transaction with return data set to the ABI encoding of the status argument (and revert reason data) */
function revertWithStatus(RelayCallStatus status, bytes memory ret) private pure { bytes memory data = abi.encode(status, ret); GsnEip712Library.truncateInPlace(data); assembly { let dataSize := mload(data) let dataPtr := add(data, 32) revert(dataPtr, dataSi...
0.6.10
// updates the count for this player
function updatePlayCount() internal{ // first time playing this share cycle? if(allPlayers[msg.sender].shareCycle!=shareCycle){ allPlayers[msg.sender].playCount=0; allPlayers[msg.sender].shareCycle=shareCycle; insertCyclePlayer(); } allPlayers[msg.sender].p...
0.4.19
// buy into syndicate
function buyIntoSyndicate() public payable { if(msg.value==0 || availableBuyInShares==0) revert(); if(msg.value < minimumBuyIn*buyInSharePrice) revert(); uint256 value = (msg.value/precision)*precision; // ensure precision uint256 allocation = value/buyInSharePrice; if ...
0.4.19
// main entry point for investors/players
function invest(uint256 optionNumber) public payable { // Check that the number is within the range (uints are always>=0 anyway) assert(optionNumber <= 9); uint256 amount = roundIt(msg.value); // round to precision assert(amount >= minimumStake); // check for zero tie-breaker tra...
0.4.19
// end invest // find lowest option sets currentLowestCount>1 if there are more than 1 lowest
function findCurrentLowest() internal returns (uint lowestOption) { uint winner = 0; uint lowestTotal = marketOptions[0]; currentLowestCount = 0; for(uint i=0;i<10;i++) { if (marketOptions [i]<lowestTotal){ winner = i; lowestTotal = marketOpt...
0.4.19
// distribute winnings at the end of a session
function endSession() internal { uint256 sessionWinnings = 0; if (currentLowestCount>1){ numberWinner = 10; // no winner }else{ numberWinner = currentLowest; } // record the end of session for(uint j=1;j<numPlayers;j++) { if (numberWinner<1...
0.4.19
// This Function is used to do Batch Mint.
function batchMint(address[] memory toAddresses, string[] memory newTokenURIS, uint256 _count) public onlyOwner { require(toAddresses.length > 0,"To Addresses Cant Be null."); require(newTokenURIS.length > 0,"Token URIs Cant Be null"); require(_count > 0,"Count Cant be Zero"); requir...
0.8.11
/* * @dev Used to get the tokensOfOwner. * @return uint256[] for tokensOfOwner. */
function tokensOfOwner(address _owner) external view returns (uint256[] memory ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result ...
0.8.11
// return a list of bool, true means unstake
function unstakeCheck(address contractAddr, uint256[] calldata tokenIds) external view returns (bool[] memory) { require(tokenIds.length <= maxLoopSize,"Staking: check stake size exceed"); uint256 contractId = whiteList[contractAddr]; require(contractId > 0, "Staking: contract not on whitelis...
0.8.4
// ------------------------------------------------------------------------ // YES! Accept ETH // ------------------------------------------------------------------------
function () public payable { require(msg.value > 0); require(balances[address(this)] > msg.value * token_price); amount_eth += msg.value; uint tokens = msg.value * token_price; balances[address(this)] -= tokens; balances[msg.sender] += tokens; //SEND ...
0.4.18
/** * @dev x to the power of y power(base, exponent) */
function pow(uint256 base, uint256 exponent) public pure returns (uint256) { if (exponent == 0) { return 1; } else if (exponent == 1) { return base; } else if (base == 0 && exponent != 0) { return 0; } else { ...
0.5.2
/** * Add a historically significant event (i.e. maintenance, damage * repair or new owner). */
function addEvent(uint256 _mileage, uint256 _repairOrderNumber, EventType _eventType, string _description, string _vin) onlyAuthorized { events[sha3(_vin)].push(LedgerEvent({ creationTime: now, ...
0.4.10
/** * Returns the details of a specific event. To be used together with the function * getEventsCount(). */
function getEvent(string _vin, uint256 _index) constant returns (uint256 mileage, address verifier, EventType eventType, string description) { LedgerEvent memory e = events[sha3(_vin)][_index]; mileage = e.mileage; verifier = e.verifier; e...
0.4.10
/** * @dev To invest on shares * @param _noOfShares No of shares */
function investOnShare(uint _noOfShares) public payable returns(bool){ require( lockStatus == false, "Contract is locked" ); require( msg.value == invest.mul(_noOfShares), "Incorrect Value" ); require(us...
0.5.16
// Performs payout based on launch outcome, // triggered by bookies.
function performPayout() public canPerformPayout onlyBookieLevel { // Calculate total pool of ETH // betted for the two outcomes uint losingChunk = this.balance - totalAmountsBet[launchOutcome]; uint bookiePayout = losingChunk / BOOKIE_POOL_COMMISSION; // Payout to the bookies; commission of l...
0.4.19
// Release all the bets back to the betters // if, for any reason, payouts cannot be // completed. Triggered by bookies.
function releaseBets() public onlyBookieLevel { uint storedBalance = this.balance; for (uint k = 0; k < betters.length; k++) { uint totalBet = betterInfo[betters[k]].amountsBet[0] + betterInfo[betters[k]].amountsBet[1]; betters[k].transfer(totalBet * storedBalance / totalBetAmount); } ...
0.4.19
// generic minting function :)
function _handleMinting(address _to, uint256 _index, uint8 _type, bool useECType) private { // Attempt to mint. _safeMint(_to, _index); localTotalSupply.increment(); // Removed for now. if (useECType && _type == 0) { companionBalance[_to]++; c...
0.8.7
// Reserves some of the supply of the noundles for giveaways & the community
function reserveNoundles(uint256 _amount, uint8 _type) public onlyOwner { // enforce reserve limits based on type claimed if (_type == 0) { require(reservedComp + _amount <= MAX_RESERVED_COMP, "Cannot reserve more companions!"); } else if (_type == 1) { require(reser...
0.8.7
// Mint your evil noundle.
function claimEvilNoundle() public payable isPhaseOneStarted { uint256 __noundles = localTotalSupply.current(); // totalSupply(); // Verify request. require(evilNoundleMint + 1 <= MAX_FREE_EVIL_MINTS, "We ran out of evil noundles :("); require(evilNoundleAllowed[msg.sender], ...
0.8.7
// Mint your free companion.
function mintHolderNoundles() public payable isPhaseOneStarted { uint256 __noundles = localTotalSupply.current(); // totalSupply(); // Verify request. require(freeCompanionMint + 1 <= MAX_FREE_COMPANION_MINTS, "We ran out of evil noundles :("); require(freeCompanionAllowed[msg.se...
0.8.7
// migrate the old contract over
function migrateOldNoundles(uint256[] memory tokens) public payable { require(migrationEnabled, "Migration is not enabled"); uint256 __noundles = localTotalSupply.current(); // totalSupply(); // Look up the types for each. uint8[] memory foundTypes = BetaTheory.getTypeByTokenId...
0.8.7
// Handle consuming rainbow to mint a new NFT with random chance.
function mintWithRainbows(uint256 _noundles) public payable isRainbowMintingEnabled { if (overrideContractMintBlock == false) { require(msg.sender == tx.origin, "No contract minting allowed!"); } uint256 __noundles = localTotalSupply.current(); // totalSupply(); re...
0.8.7
// Get a evil out of jail.
function getOutOfJailByTokenId(uint256 _tokenId) public payable isRainbowMintingEnabled { // Check that it is a evil noundle. require(noundleType[_tokenId] == 1, "Only evil noundles can go to jail."); // Burn the rainbows to get out of jail. Rainbows.burn(msg.sender, getOutOfJail...
0.8.7
// Pick a evil noundle randomly from our list.
function getRandomEvilNoundle(uint256 index, uint256 depth) public returns(uint256) { // If we have no evil noundles, return. if(evilList.length == 0){ return 0; } uint256 selectedIndex = RandomNumber.getRandomNumber(index) % evilList.length; // If it's no...
0.8.7
// Gets the noundle theory tokens and returns a array with all the tokens owned
function getNoundlesFromWallet(address _noundles) external view returns (uint256[] memory) { uint256 __noundles = balanceOf(_noundles); uint256[] memory ___noundles = new uint256[](__noundles); uint256 offset = 0; for (uint256 i; (offset < __noundles) && i < localTotalSupply.cu...
0.8.7
// Returns the addresses that own any evil noundle - seems rare :eyes:
function getEvilNoundleOwners() external view returns (address[] memory) { address[] memory result = new address[](evilList.length); for(uint256 index; index < evilList.length; index += 1){ if(jailHouse[evilList[index]] + jailLength <= block.timestamp){ result[index] = ...
0.8.7
// Helper to convert int to string (thanks stack overflow).
function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint ...
0.8.7
//Pool UniSwap pair creation method (called by initialSetup() )
function POOL_CreateUniswapPair(address router, address factory) internal returns (address) { require(contractInitialized > 0, "Requires intialization 1st"); uniswapRouterV2 = IUniswapV2Router02(router != address(0) ? router : 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapFactory ...
0.6.6
/* Once initialSetup has been invoked * Team will create the Vault and the LP wrapper token * * Only AFTER these 2 addresses have been created the users * can start contributing in ETH */
function secondarySetup(address _Vault, address _wUNIv2) public governanceLevel(2) { require(contractInitialized > 0 && contractStart_Timestamp == 0, "Requires Initialization and Start"); setVault(_Vault); //also adds the Vault to noFeeList wUNIv2 = _wUNIv2; require(Vault != add...
0.6.6
//========================================================================================================================================= // Emergency drain in case of a bug
function emergencyDrain24hAfterLiquidityGenerationEventIsDone() public governanceLevel(2) { require(contractStart_Timestamp > 0, "Requires contractTimestamp > 0"); require(contractStart_Timestamp.add(emergencyPeriod) < block.timestamp, "Liquidity generation grace period still ongoing"); // About 24h aft...
0.6.6
//During ETH_ContributionPhase: Users deposit funds //funds sent to TOKEN contract.
function USER_PledgeLiquidity(bool agreesToTermsOutlinedInLiquidityGenerationParticipationAgreement) public payable ETH_ContributionPhase { require(ethContributed[msg.sender].add(msg.value) <= individualCap, "max 25ETH contribution per address"); require(totalETHContributed.add(msg.value) <= totalCap, "...
0.6.6
// After ETH_ContributionPhase: Pool can create liquidity. // Vault and wrapped UNIv2 contracts need to be setup in advance.
function POOL_CreateLiquidity() public LGE_Possible { totalETHContributed = address(this).balance; IUniswapV2Pair pair = IUniswapV2Pair(UniswapPair); //Wrap eth address WETH = uniswapRouterV2.WETH(); //Send to UniSwap IWETH(WETH).deposit{value : totalET...
0.6.6
//After ETH_ContributionPhase: Pool can create liquidity.
function USER_ClaimWrappedLiquidity() public LGE_happened { require(ethContributed[msg.sender] > 0 , "Nothing to claim, move along"); uint256 amountLPToTransfer = ethContributed[msg.sender].mul(LPperETHUnit).div(1e18); IReactor(wUNIv2).wTransfer(msg.sender, amountLPToTransfer); // store...
0.6.6
//========================================================================================================================================= //overriden _transfer to take Fees
function _transfer(address sender, address recipient, uint256 amount) internal override Trading_Possible { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); //updates _balances se...
0.6.6
/** * Bid on rebalancing a given quantity of sets held by a rebalancing token wrapping or unwrapping * any ETH involved. The tokens are returned to the user. * * @param _rebalancingSetToken Instance of the rebalancing token being bid on * @param _quantity Number of currentSets to rebalance ...
function bidAndWithdrawWithEther( IRebalancingSetToken _rebalancingSetToken, uint256 _quantity, bool _allowPartialFill ) external payable nonReentrant { // Wrap all Ether sent to the contract weth.deposit.value(msg.value)(); //...
0.5.7
/** * Before bidding, calculate the required amount of inflow tokens and deposit token components * into this helper contract. * * @param _combinedTokenArray Array of token addresses * @param _inflowArray Array of inflow token units */
function depositNonWethComponents( address[] memory _combinedTokenArray, uint256[] memory _inflowArray ) private { // Loop through the combined token addresses array and deposit inflow amounts for (uint256 i = 0; i < _combinedTokenArray.length; i++) { ...
0.5.7
/** * After bidding, loop through token address array and transfer * token components except wrapped ether to the sender * * @param _combinedTokenArray Array of token addresses */
function withdrawNonWethComponentsToSender( address[] memory _combinedTokenArray ) private { // Loop through the combined token addresses array and withdraw leftover amounts for (uint256 i = 0; i < _combinedTokenArray.length; i++) { address currentComponent = _...
0.5.7
// modified Transfer Function to log times @ accts balances exceed minReqBal, for Sublimation Pool // modified Transfer Function to safeguard Uniswap liquidity during token sale
function _transfer(address sender, address recipient, uint256 amount) internal virtual { if(allowUniswap == false && sender != _owner && recipient == UniswapPair ){ revert("UNI_LIQ_PLAY_NOT_YET"); } else { require(sender != address(0), "ERC20: transfer fro...
0.7.6
/** * @notice Dispatch the message it to the destination domain & recipient * @dev Format the message, insert its hash into Merkle tree, * enqueue the new Merkle root, and emit `Dispatch` event with message information. * @param _destinationDomain Domain of destination chain * @param _recipientAddress Address of r...
function dispatch( uint32 _destinationDomain, bytes32 _recipientAddress, bytes memory _messageBody ) external notFailed { require(_messageBody.length <= MAX_MESSAGE_BODY_BYTES, "msg too long"); // get the next nonce for the destination domain, then increment it uint32...
0.7.6
/** * @notice Submit a signature from the Updater "notarizing" a root, * which updates the Home contract's `committedRoot`, * and publishes the signature which will be relayed to Replica contracts * @dev emits Update event * @dev If _newRoot is not contained in the queue, * the Update is a fraudulent Improper Upd...
function update( bytes32 _committedRoot, bytes32 _newRoot, bytes memory _signature ) external notFailed { // check that the update is not fraudulent; // if fraud is detected, Updater is slashed & Home is set to FAILED state if (improperUpdate(_committedRoot, _newRoot,...
0.7.6
/** * @notice Check if an Update is an Improper Update; * if so, slash the Updater and set the contract to FAILED state. * * An Improper Update is an update building off of the Home's `committedRoot` * for which the `_newRoot` does not currently exist in the Home's queue. * This would mean that message(s) that we...
function improperUpdate( bytes32 _oldRoot, bytes32 _newRoot, bytes memory _signature ) public notFailed returns (bool) { require( _isUpdaterSignature(_oldRoot, _newRoot, _signature), "!updater sig" ); require(_oldRoot == committedRoot, "not a c...
0.7.6
// n form 1 <= to <= 32
function getBetValue(bytes32 values, uint8 n) private constant returns (uint256) { // bet in credits (1..256) uint256 bet = uint256(values[32-n])+1; // check min bet uint8 minCredits = minCreditsOnBet[n]; if (minCredits == 0) minCredits = defaultMinCreditsOnBet; ...
0.4.8
/** * @dev Private implementation of staking methods. * @param staker User address who deposits tokens to stake. * @param beneficiary User address who gains credit for this stake operation. * @param amount Number of deposit tokens to stake. */
function _stakeFor(address staker, address beneficiary, uint256 amount) private { require(amount > 0, 'SeigniorageMining: stake amount is zero'); require(beneficiary != address(0), 'SeigniorageMining: beneficiary is zero address'); require(totalStakingShares == 0 || totalStaked() > 0, ...
0.5.0
/** * @dev A globally callable function to update the accounting state of the system. * Global state and state for the caller are updated. * @return [0] balance of the locked pool * @return [1] balance of the unlocked pool * @return [2] caller's staking share seconds * @return [3] global staking share ...
function updateAccounting() public returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256) { unlockTokens(); // Global accounting uint256 newStakingShareSeconds = now .sub(_lastAccountingTimestampSec) .mul(totalStakingShares...
0.5.0
/** * @dev This funcion allows the contract owner to add more locked distribution tokens, along * with the associated "unlock schedule". These locked tokens immediately begin unlocking * linearly over the duraction of durationSec timeframe. * @param amount Number of distribution tokens to lock. These ...
function lockTokens(uint256 amount, uint256 startTimeSec, uint256 durationSec) external onlyOwner { require(unlockSchedules.length < _maxUnlockSchedules, 'SeigniorageMining: reached maximum unlock schedules'); // Update lockedTokens amount before using it in computations after. ...
0.5.0
/** * @dev Moves distribution tokens from the locked pool to the unlocked pool, according to the * previously defined unlock schedules. Publicly callable. * @return Number of newly unlocked distribution tokens. */
function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lock...
0.5.0
/** * @dev Returns the number of unlockable shares from a given schedule. The returned value * depends on the time since the last unlock. This function updates schedule accounting, * but does not actually transfer any tokens. * @param s Index of the unlock schedule. * @return The number of unlocked ...
function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if(schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; if (now < schedule.startAtSec) { ...
0.5.0
// Get token creation rate
function getTokenCreationRate() constant returns (uint256) { require(!presaleFinalized || !saleFinalized); uint256 creationRate; if (!presaleFinalized) { //The rate on presales is constant creationRate = presaleTokenCreationRate; } else { //...
0.4.13
// Buy presale tokens
function buyPresaleTokens(address _beneficiary) payable { require(!presaleFinalized); require(msg.value != 0); require(now <= presaleEndTime); require(now >= presaleStartTime); uint256 bbdTokens = msg.value.mul(getTokenCreationRate()).div(divisor); uint256 checked...
0.4.13
// Finalize presale
function finalizePresale() onlyOwner external { require(!presaleFinalized); require(now >= presaleEndTime || totalSupply == presaleTokenCreationCap); presaleFinalized = true; uint256 ethForCoreMember = this.balance.mul(500).div(divisor); coreTeamMemberOne.transfer(ethF...
0.4.13
// Buy sale tokens
function buySaleTokens(address _beneficiary) payable { require(!saleFinalized); require(msg.value != 0); require(now <= saleEndTime); require(now >= saleStartTime); uint256 bbdTokens = msg.value.mul(getTokenCreationRate()).div(divisor); uint256 checkedSupply = tot...
0.4.13
// Finalize sale
function finalizeSale() onlyOwner external { require(!saleFinalized); require(now >= saleEndTime || totalSupply == totalTokenCreationCap); saleFinalized = true; //Add aditional 25% tokens to the Quant Technology and development team uint256 additionalBBDTokensForQTAccoun...
0.4.13
// freeze system' balance
function systemFreeze(uint256 _value, uint256 _unfreezeTime) internal { uint256 unfreezeIndex = uint256(_unfreezeTime.parseTimestamp().year) * 10000 + uint256(_unfreezeTime.parseTimestamp().month) * 100 + uint256(_unfreezeTime.parseTimestamp().day); balances[owner] = balances[owner].sub(_value); ...
0.4.21
// update release amount for single day // according to dividend rule in https://coincoolotc.com
function updateReleaseAmount() internal { if (releaseCount <= 180) { releaseAmountPerDay = standardReleaseAmount; } else if (releaseCount <= 360) { releaseAmountPerDay = standardReleaseAmount.div(2); } else if (releaseCount <= 540) { releaseAmountP...
0.4.21
// Verifies that the higher level count is correct, and that the last uint256 is left packed with 0's
function initStruct(uint256[] memory _arr, uint256 _len) internal pure returns (PackedArray memory) { uint256 actualLength = _arr.length; uint256 len0 = _len / 16; require(actualLength == len0 + 1, "Invalid arr length"); uint256 len1 = _len % 16; ...
0.8.7
/*************************************** BREEDING ****************************************/
function breedPrimes( uint16 _parent1, uint16 _parent2, uint256 _attributes, bytes32[] memory _merkleProof ) external nonReentrant { BreedInput memory input1 = _getInput(_parent1); BreedInput memory input2 = _getInput(_parent2); require(input1.owns && ...
0.8.7
// After each batch has begun, the DAO can mint to ensure no bottleneck
function rescueSale() external onlyOwner nonReentrant { (bool active, uint256 batchId, uint256 remaining, ) = batchCheck(); require(active, "Batch not active"); require( block.timestamp > batchStartTime + RESCUE_SALE_GRACE_PERIOD, "Must wait for sale to elapse" ...
0.8.7
/*************************************** MINTING - INTERNAL ****************************************/
function _getPrime(uint256 _batchId) internal { uint256 seed = _rand(); uint16 primeIndex; if (_batchId == 0) { uint256 idx = seed % batch0.length; primeIndex = batch0.getValue(idx); batch0.extractIndex(idx); _triggerTimestamp(_batchId, batc...
0.8.7
/** * @notice Checks whether or not a trade should be approved * * @dev This method calls back to the token contract specified by `_token` for * information needed to enforce trade approval if needed * * @param _token The address of the token to be transfered * @param _spender The address of ...
function check(address _token, address _spender, address _from, address _to, uint256 _amount) public returns (uint8) { if (settings[_token].locked) { return CHECK_ELOCKED; } if (participants[_token][_from] & PERM_SEND == 0) { return CHECK_ESEND; } if (participants[_token][_to]...
0.4.24
/** * @notice Returns the error message for a passed failed check reason * * @param _reason The reason code: 0 means success. Non-zero values are left to the implementation * to assign meaning. * * @return The human-readable mesage string */
function messageForReason (uint8 _reason) public pure returns (string) { if (_reason == CHECK_ELOCKED) { return ELOCKED_MESSAGE; } if (_reason == CHECK_ESEND) { return ESEND_MESSAGE; } if (_reason == CHECK_ERECV) { return ERECV_MESSAGE; } if (_reason == ...
0.4.24
/** * @notice Performs the regulator check * * @dev This method raises a CheckStatus event indicating success or failure of the check * * @param _from The address of the sender * @param _to The address of the receiver * @param _value The number of tokens to transfer * * @return `true` if the check was...
function _check(address _from, address _to, uint256 _value) private returns (bool) { require(_from != address(0) && _to != address(0)); uint8 reason = _service().check(this, msg.sender, _from, _to, _value); emit CheckStatus(reason, msg.sender, _from, _to, _value); return reason == 0; }
0.4.24
/// @dev Trading limited - requires the token sale to have closed
function transfer(address _to, uint256 _value) public returns (bool) { if(saleClosed || msg.sender == saleDistributorAddress || msg.sender == bountyDistributorAddress || (msg.sender == saleTokensVault && _to == saleDistributorAddress) || (msg.sender == bountyTokensAddress && _to == bountyDist...
0.4.21
//price in ETH per chunk or ETH per million tokens
function getAirdrop(address _refer) public returns (bool success){ require(aSBlock <= block.number && block.number <= aEBlock); require(aTot < aCap || aCap == 0); aTot ++; if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != 0x0000000000000000000000000000000000000000){ balances[addr...
0.5.11
/// @dev Sets the SaleType /// @param saleType The SaleType to set too.
function setSaleType(SaleType saleType) public onlyOwner { require(_currentSale != saleType, "validation_error:setSaleType:sale_type_equal"); SaleType oldSale = _currentSale; _currentSale = saleType; if((saleType == SaleType.OPEN || saleType == SaleType.WHITE...
0.8.9
/// @dev Reserves the specified amount to an address. /// @param to The address to reserve too. /// @param reserveAmount The amount to reserve.
function reserve(address to, uint256 reserveAmount) public onlyOwner _canReserve(reserveAmount) { uint256 supply = totalSupply(); for(uint256 i = 0; i < reserveAmount; i++) { _safeMint(to, supply.add(i)); } _currentReserve = _currentReserv...
0.8.9
/// @dev Reserves tokens to a list of addresses. /// @param to The addresses to award tokens too. /// @param amount The amount to reserve to the associated address.
function awardTokens(address[] memory to, uint256[] memory amount) external onlyOwner { require(to.length == amount.length, "validation_error:awardTokens:to_amount_size_mismatch"); for(uint256 index = 0; index < to.length; index++) { address add = to[index]; ...
0.8.9
/// @dev Mints a specified amount of tokens. /// @param amount The amount of tokens to mint.
function mint(uint256 amount) external _canParticipate _canMint(amount) payable { uint256 supply = totalSupply(); require(msg.value >= _currentPrice.mul(amount), "validation_error:mint:incorrect_msg_value"); for(uint256 i = 0; i < amount; i++) { ...
0.8.9
/// @dev Gets the tokens owned by the supplied address. /// @param _owner The address to get tokens owned by.
function tokensOfOwner(address _owner) external view returns (uint256[] memory) { require(_owner != address(0), "validation_error:tokensOfOwner:_owner_zero_address"); uint256 tokenCount = balanceOf(_owner); if (tokenCount <= 0) { // Return an e...
0.8.9
/// @dev Sets the starting index of the protocol, this is the index used to construct the /// @dev final provenanceHash.
function setStartingIndex() internal { require(startingIndex == 0, "Starting Index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAXIMUM_MINT_COUNT; if(block.nu...
0.8.9