file_name
stringlengths
71
779k
comments
stringlengths
0
29.4k
code_string
stringlengths
20
7.69M
__index_level_0__
int64
2
17.2M
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import...
See {IERC721-isApprovedForAll}./
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return operatorApprovals_[owner][operator]; }
2,501,454
./full_match/80001/0x637b0Bdc8a450BCd96bf873f2fb1f57871C618A6/sources/_openzeppelin/contracts-upgradeable/governance/GovernorUpgradeable.sol
See {IGovernor-propose}./uint64 snapshot = starttime;block.number.toUint64() + votingDelay().toUint64();uint64 deadline = endtime;snapshot + votingPeriod().toUint64();
function propose( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description, uint64 starttime, uint64 endtime ) public virtual override returns (uint256) { require( getVotes(_msgSender(), block.numbe...
5,575,964
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e....
remove addresses from the whitelist addrs addresses/
function removeAddressesFromWhitelist(address[] memory addrs) external onlyOwner { _removeAddressesFromWhitelist(addrs); }
497,975
./full_match/5/0x3e004b1a415B45C8E2213CAc32a597FDee92BfC3/sources/contracts/StakingContract5.sol
Staking function Require statements Creates a new staker entry for the user which gets edited below with staker.
function stake(uint256 _amount, uint256 _days) external ifNotPaused { require(_amount > minAmount, "Must stake more!"); require(daysToAPY[_days] != 0, "Invalid number of days!"); require( audxContract.balanceOf(msg.sender) >= _amount, "Insufficient balance!" )...
1,854,361
// File: contracts/interfaces/IAMB.sol pragma solidity 0.4.24; interface IAMB { function messageSender() external view returns (address); function maxGasPerTx() external view returns (uint256); function transactionHash() external view returns (bytes32); function messageId() external view returns (byt...
Allows the current owner to transfer control of the contract to a newOwner. newOwner the address to transfer ownership to./
function transferOwnership(address newOwner) external onlyOwner { _setOwner(newOwner); }
52,046
./full_match/1/0xd7C0f19C4dB13F076802AEc732956eedBBafc370/sources/contracts/PriceFeed.sol
Return true if price has more than doubled, or more than halved.
function _chainlinkPriceChangeAboveMax(ChainlinkResponse memory _currentResponse, ChainlinkResponse memory _prevResponse) internal pure returns (bool) { uint256 currentScaledPrice = _scaleChainlinkPriceByDigits(uint256(_currentResponse.answer), _currentResponse.decimals); uint256 prevScaledPrice = _...
4,892,465
// SPDX-License-Identifier: MIT pragma solidity ^0.8.1; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/security/PullPayment.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract FoolRichPig is ERC721, PullPay...
single mint if not owner need mint price if user use eth to mint, send nft to the sender. deposit eth to owner
function singleMintTo(address recipient) public payable returns (uint256) { if (owner() != _msgSender()) { require(guestMint == 1, "Guest cant mint NFT."); require(msg.value == mintPrice, "Transaction value did not equal the mint price"); recipient = _msgSender(); } uint256 ne...
13,745,287
./full_match/4/0xd84F1fefe13E91C52C41998D06d9182e879cb649/sources/contracts/Tokens/StakingRewardFactory.sol
notify reward amount for an individual staking token. this is a fallback in case the notifyRewardAmounts costs too much gas to call for all contracts
function notifyRewardAmount(address stakingToken) public { require(block.timestamp >= stakingRewardsGenesis, 'StakingRewardsFactory::notifyRewardAmount: not ready'); StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken]; require(info.stakingRewards != address(0), ...
670,276
pragma solidity ^0.4.24; // 'ETHERCHAIN' CROWDSALE token contract // // Deployed to : 0x49F4B69FEf86C82c8e936Bfaf1b9E326bd1A20D0 // Symbol : ERH // Name : ETHERCHAIN TOKEN // Total supply: 1,000,000,000 // Decimals : 18 interface tokenRecipient { function receiveApproval(address _from, uint256 ...
Constrctor function Initializes contract with initial supply tokens to the creator of the contract/
function ERH() public { creator = msg.sender; }
10,849,313
./full_match/1/0xe5BB8654F698c5f021dA21146219f6a998F2aA99/sources/contracts/v3/tokens/ERC721LA.sol
Given a tokenId return editionId and tokenNumber. eg.: 3000005 => editionId 3 and tokenNumber 5/ Divide first to lose the decimal. ie. 1000001 / 1000000 = 1
function parseEditionFromTokenId(uint256 tokenId) public view returns (uint256 editionId, uint256 tokenNumber) { ERC721State.ERC721LAState storage state = ERC721State ._getERC721LAState(); editionId = tokenId / state._edition_max_tokens; tokenNumber = ...
3,137,199
pragma solidity ^0.4.18; // similar to ShrimpFarmer, with three changes: // 1. one third of your sperm die when you sell your cells // 2. the ownership of the devfee can transfer through sacrificing sperm // a. the new requirement will be how many remaining sperm you have after the sacrifice // b. you cannot s...
ALL HAIL THE SPERMLORD!
function buyCells() public payable { require(initialized); uint256 cellsBought = calculateCellBuy(msg.value, SafeMath.sub(this.balance, msg.value)); cellsBought = SafeMath.sub(cellsBought, devFee(cellsBought)); claimedCells[msg.sender] = SafeMath.add(claimedCells[msg.sender], cellsB...
924,536
./full_match/1/0xe5b9239A8be521C9A08ba9A4b925DFa86Ee19024/sources/contracts/CopyPasta.sol
Changes bot flag. Only callable by owner. Can only add bots to list if disableBlockListAdd() not called and theBot is not a liquidity pair (prevents honeypot behaviour) theBot The address to change bot of. toSet The value to set.
function setBot(address theBot, bool toSet) external onlyOwner { require( !mappedAddresses[theBot].isLPPair, "Cannot manipulate blocklist status of a liquidity pair." ); if (toSet) { require( !disableAddToBlocklist, "Blockli...
2,950,196
// SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMa...
----------------- MAIN STRATEGY FUNCTIONS ----------------- claim rewards from Aave's Liquidity Mining Program claim rewards from yVault Example: debtOutstanding 100, profit 50, _amountFreed 100, _loss 50 loss should be 0, (50-50) profit should endup in 0 Example: debtOutstanding 100, profit 50, _amountFreed 140, _loss...
function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { uint256 totalDebt = vault.strategies(address(this)).totalDebt; _claimRewards(); _tak...
1,105,734
./full_match/5/0xCec96f944C219ebb8f61527a51009f217950c6F8/sources/contracts/LooksRareExchange.sol
Verify the validity of the maker order makerOrder maker order orderHash computed hash for the order/ Verify whether order nonce has expired Verify the signer is not address(0) Verify the amount is not 0 Verify the validity of the signature Verify whether the currency is whitelisted Verify whether strategy can be exec...
function _validateOrder(OrderTypes.MakerOrder calldata makerOrder, bytes32 orderHash) internal view { require( (!_isUserOrderNonceExecutedOrCancelled[makerOrder.signer][makerOrder.nonce]) && (makerOrder.nonce >= userMinOrderNonce[makerOrder.signer]), "Order: Matching ...
7,066,188
pragma solidity ^0.5.17; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol"; import "../DarknodeRegistry/DarknodeRegistry...
Access storage outside of loop.
function withdrawToCommunityFund(address[] memory _tokens) public { address memoryCommunityFund = communityFund; address payable communityFundPayable = address(uint160(address(memoryCommunityFund))); for (uint256 i = 0; i < _tokens.length; i++) { address _token = _to...
14,024,723
./partial_match/1/0xf67afd75433fCcca272c3373592B4a082A7b9f77/sources/MarketUtilityV2_1.sol
leverageMultiplier = levergage + (leverage -1)0.05; Raised by 3 decimals i.e 1000 (amountsqrt(amount100)leverage100/(price10125000/1000));
function _calculatePredictionPoints(uint value, uint optionPrice, uint _leverage) internal pure returns(uint) { uint leverageMultiplier = 1000 + (_leverage-1)*50; value = value.mul(2500).div(1e18); return value.mul(sqrt(value.mul(10000))).mul(_leverage*100*leverageMultiplier).div(optionPrice.mul(1...
2,884,591
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.4; import 'hardhat/console.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '../base/SignatureVerifier.sol'; import '../erc721/Worlds.sol'; // Contract containing stats of a dystopian. // Can only be updated by the Dystopian owner or Worl...
read the data stored in the contract
function getDystopianData(uint256 _world) external view returns (Dystopian memory) { return worldData[_world]; }
6,355,556
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math64 { /** * @dev Returns the largest of two numbers. */ function max(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } ...
Returns the integer division of two unsigned integers, reverting with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consumi...
function div( uint64 a, uint64 b, string memory errorMessage ) internal pure returns (uint64) { unchecked { require(b > 0, errorMessage); return a / b; } }
7,307,349
./full_match/1/0xCEa4a5C2990F2C32d5B9cc7Dda2Ad7110E61c7c2/sources/contracts/atheneum.sol
Encodes some bytes to the base64 representation multiply by 4/3 rounded up Add some extra buffer at the end
function _beforeTokenTransfer( address from, address to, uint256 tokenId } function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; uint256 encodedLen = 4 * ((len + 2) / 3); bytes me...
9,677,546
// SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // File: Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is un...
Used to change `rewards`. EOA or smart contract which has the permission to pull rewards from the vault. This may only be called by the strategist. _rewards The address to use for pulling rewards./
function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); vault.approve(rewards, 0); rewards = _rewards; vault.approve(rewards, uint256(-1)); emit UpdatedRewards(_rewards); }
13,397,575
pragma solidity 0.6.12; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IERC20Burnable.sol"; import {YearnVaultAdapterWithIndirectio...
claims the base token after it has been transmutedThis function reverts if there is no realisedToken balance
function claim() public noContractAllowed() { address sender = msg.sender; require(realisedTokens[sender] > 0); uint256 value = realisedTokens[sender]; realisedTokens[sender] = 0; ensureSufficientFundsExistLocally(value); IERC20Burnable(token).saf...
2,510,716
// SPDX-License-Identifier: MIT pragma solidity =0.7.6; pragma experimental ABIEncoderV2; interface IERC20 { function totalSupply() external view returns (uint256 supply); function balanceOf(address _owner) external view returns (uint256 balance); function transfer(address _to, uint256 _value) exte...
Common interface for the Trove Manager. --- Events ---
interface ITroveManager { event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event PriceFeedAddressChanged(address _newPriceFeedAddress); event LUSDTokenAddressChanged(address _newLUSDTokenAddress); event ActivePoolAddressChanged(address _activePoolAddress); event D...
1,156,979
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contract...
update status of a pool. onlyOwner. okay to pause an official pool, wait 6k blocks and then convert it to synthetic unlisting a token allows creating a new pool of the same token. should move it to PAUSED if the goal is to blacklist the token forever
function updatePoolStatus(address _token, PoolStatus _status) external onlyOwner { PoolStatus poolStatus = pools[_token].status; if(poolStatus==PoolStatus.PAUSED){ require(block.number > lastTradedBlock[_token].add(6000), "MonoX:TOO_EARLY"); } else{ require(_status!=PoolStatus.SYNTHET...
12,002,975
./partial_match/1/0x15C702f2c01C109B3261EfFB0A6a48de0F3cEAE5/sources/CNFT.sol
contracts/Messages.sol
interface IWormhole { function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize } struct GuardianSet { address[] keys; uint32 expirationTime; } struct Signature { bytes32 r; bytes32 s; uint8...
9,172,994
./partial_match/1/0xF2e2e4B672c117Cbb97eDb9eF092cd5938cd5130/sources/NFTStaking.sol
Return all ctaked cards/
function stakedOf(address who) external view returns (uint256[] memory) { return staked[who]; }
9,238,824
/* * Simple Wallet Contract to be used for testing. * Copyright © 2016–2017 by ABDK Consulting. * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com> */ pragma solidity ^0.4.16; contract Wallet { /** * Whether wallet accepts incoming payments. */ bool acceptsPayments = false; /** * Default fu...
Execute transaction to given address with given data and value. _to address to execute transaction to _data transaction data _value transaction value return true if transaction was executed successfully, false otherwise/
function execute (address _to, bytes _data, uint256 _value) payable returns (bool success) { bool result = _to.call.value (_value)(_data); Result (result); return result; }
12,621,194
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "../libraries/SafeMathExt.sol"; import "../libraries/Utils.sol"; contract Tracer { using SafeMath for ...
Liquidity pool must call this method when changing its ownership to the new operator. Can only be called by a liquidity pool. This method does not affect 'ownership' or privileges of operator but only make a record for further query. liquidityPool The address of the liquidity pool. operator ...
function registerOperatorOfLiquidityPool(address liquidityPool, address operator) public onlyLiquidityPool { address prevOperator = _liquidityPoolOwners[liquidityPool]; _operatorOwnedLiquidityPools[prevOperator].remove(liquidityPool); _operatorOwnedLiquidityPools[operator...
12,750,662
./partial_match/1/0x59a79E83A2Bc84Abe2839F8Cd779181b551E6b89/sources/WeAreLand.sol
See {IERC165-supportsInterface}./
function totalSupply() external view returns (uint256); } pragma solidity ^0.8.0; function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; }
15,540,633
// Copyright (C) 2020 Argent Labs Ltd. <https://argent.xyz> // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Th...
Invoke the wallet to execute the refund transfer. _wallet The wallet _to The destination of the call _value The value of the call _data The data associated to the call/ solhint-disable-next-line no-inline-assembly
function invokeWallet( address _wallet, address _to, uint256 _value, bytes memory _data ) internal returns (bytes memory _res) { bool success; (success, _res) = _wallet.call(abi.encodeWithSignature("invoke(address,uint256,bytes)", _to, _value, ...
1,670,568
./partial_match/1/0xfE3bcF876C95e410c4D4a09d32515A4723C895A1/sources/CeaserParamaterStore.sol
rebaseFeeRate must be a number between 1 and 99 (in 18 decimal)
function changeRebaseFeeRate(uint256 newRebaseFeeRate) external onlyGovernor { require(newRebaseFeeRate < (100 ether) && newRebaseFeeRate > (0 ether), "New rebase fee rate out of range"); emit ParameterChange("rebaseFeeRate", newRebaseFeeRate, _rebaseFeeRate); _rebaseFeeRate = newRebaseFeeRa...
11,033,707
// Sources flattened with hardhat v2.8.4 https://hardhat.org // File @rari-capital/solmate/src/auth/Auth.sol@v6.2.0 // SPDX-License-Identifier: GNU AGPLv3 pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https...
Sets a new withdrawal stack. newStack The new withdrawal stack. Strategies that are untrusted, duplicated, or have no balance are filtered out when encountered at withdrawal time, not validated upfront. Ensure the new stack is not larger than the maximum stack size. Replace the withdrawal stack.
function setWithdrawalStack(Strategy[] calldata newStack) external requiresAuth { require(newStack.length <= MAX_WITHDRAWAL_STACK_SIZE, "STACK_TOO_BIG"); withdrawalStack = newStack; emit WithdrawalStackSet(msg.sender, newStack); }
314,960
/** *Submitted for verification at Etherscan.io on 2022-03-08 */ // File: elementix/libraries/ArrayUtils.sol pragma solidity ^0.8.0; library ArrayUtils { /** * Replace bytes in an array with bytes in another array, guarded by a bitmask * Efficiency of this function is a bit unpredictable because of ...
Cancel an order, preventing it from being matched. Must be called by the maker of the order order Order to cancel sig ECDSA signature/
function cancelOrder(DataType.Order memory order, DataType.Sig memory sig) public { bytes32 hash = requireValidOrder(order, sig); require(msg.sender == order.maker, "not maker"); cancelledOrFinalized[hash] = true; emit OrderCancelled(hash);
6,611,370
./full_match/1/0xCb6A39883Ae55F2b63CfdcA7b4e7928dAEe65c11/sources/browser/Adam.sol
See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}; Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for...
function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "Transfer amount exceeds allowance")); ...
3,177,021
pragma solidity ^0.4.24; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Owned { address private _owner; address private _newOwner; event TransferredOwn...
Unfreeze token transfers. May only be called by smart contract owner./
function unfreezeTransfers () public onlyOwner { if (frozen) { frozen = false; emit Unfreeze(); } }
1,166,926
./full_match/1/0x6E01d7EF4d94E12Ef191cf99BCf4b73A747274Bd/sources/browser/rnexttoken.sol
Destroys `_amount` tokens from `msg.sender`, reducing the total supply./
function burn(uint256 _amount) public { _burn(msg.sender, _amount); _moveDelegates(_delegates[msg.sender], address(0), _amount); }
8,455,344
pragma solidity 0.6.12; // Dependency file: @openzeppelin/contracts/GSN/Context.sol // pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should ...
PRIVILEGED GOVERNANCE FUNCTION. Allows governance to remove a Set _setToken Address of the SetToken contract to remove/
function removeSet(address _setToken) external onlyInitialized onlyOwner { require(isSet[_setToken], "Set does not exist"); sets = sets.remove(_setToken); isSet[_setToken] = false; emit SetRemoved(_setToken); }
188,050
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; /// @title Cr...
minting possible only by the migration bridge/
function mintMachine(address _owner, uint256 _tokenId) external returns (uint256) { require(msg.sender == BRIDGE, "Not Bridge"); require(_tokenId > 0 && _tokenId <= MONKS, "Token out of bound"); require(migrated <= MONKS, "Max supply reached"); require(TOKENIDS[_tokenId] == 0, "Exis...
15,610
./full_match/100/0xb091087E865d200c622241D1BC00A67Dd465e083/sources/contracts/rari-fuse/src/core/Comptroller.sol
Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert. Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying. cTokens The addresses of the markets (tokens) to change the supply...
function _setMarketSupplyCaps( CToken[] calldata cTokens, uint256[] calldata newSupplyCaps ) external { require( hasAdminRights() || msg.sender == borrowCapGuardian, "only admin or borrow cap guardian can set supply caps" ); uint256 numMarkets = c...
14,286,880
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contra...
Remove liquidity from Curve 3Pool, receiving a single underlying pool The Curve 3Pool index The index of underlying we want to withdraw amount The amount to withdraw maxBurn The max LP tokens to burn before the tx reverts (slippage)
function removeLiquidity( address pool, uint256 index, uint256 amount, uint256 maxBurn ) internal { uint256[3] memory amounts = [uint256(0), uint256(0), uint256(0)]; amounts[index] = amount; ICurve3Pool(pool).remove_liquidity_imbalance(amounts, maxBurn); ...
273,973
pragma solidity ^0.5.0; contract ERC20 { function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(ad...
delete all block from blocks array
function resetBlocks() public onlyOwner{ uint blocksLength = blocks.length; for(uint i=0;i<blocksLength;i++){ blocks.pop(); } }
7,293,209
./full_match/137/0xb493CBe66D3615E65185b796fc1A61c976Bcc872/sources/contracts/Manageable.sol
Adds authorized party
function rely(address party) external authorized { auth[party] = 1; emit Rely(party); }
3,737,000
./full_match/4/0xC5e79ae10a4923f458FF22664b7D114013E3Bd9B/sources/contracts/Dummy.sol
uint256 rand = random(string(abi.encodePacked('test')));uint256 greatness = rand % 51;
function tokenURI(uint256 tokenId) override public view returns (string memory) { string[23] memory parts; string memory output; uint256 greatness = 50; if (greatness > 40) { parts[1] = '<text x="30" y="45" class="base">Ssssssssssss _</text>'; ...
799,863
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error...
. / \ |.'.| |'.'| ,'| |`. |,-'-|-'-.| __|_| | _ _ _____ _ | ___ \| | | | | | ___ \ | | | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | | | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | | \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_| ...
interface AddressSetStorageInterface { function getCount(bytes32 _key) external view returns (uint); function getItem(bytes32 _key, uint _index) external view returns (address); function getIndexOf(bytes32 _key, address _value) external view returns (int); function addItem(bytes32 _key, address _value) ...
5,398,646
./full_match/1/0xa462127735352B1F03dA8Ab92a87803d05cc6a7B/sources/contracts/Augminted/ERC721ABase.sol
Token offset is added to the token ID (wrapped on overflow) to get metadata asset index/
function tokenOffset() public view returns (uint256) { if (_tokenOffset == 0) revert ERC721ABase_TokenOffsetNotSet(); return _tokenOffset; }
8,311,054
// contracts/Strawberries.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "./ISeeds.sol"; import "./FruitsLibrary.sol"; contract Strawberries is ERC721Enumerable { /** MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM...
Mints new tokens./
function mintStrawberry(uint256 _times) public payable { require((_times > 0 && _times <= 20) && (msg.value == _times * price) && (totalSupply() < MINTS_PER_TIER), "Check values."); for(uint256 i=0; i< _times; i++){ mintInternal(); } }
14,693,939
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppe...
---------------- ADMIN FUNCTIONS ---------------- Allows to update the value of distributed rewards _startTime Specifeies the new value of start staking time/
function setStartTime(uint256 _startTime) external onlyAdmin { require( block.timestamp < _startTime, "DAOvc Staking: Staking time has already come" ); startTime = _startTime; }
1,636,755
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./interfaces/ICumulativeMerkleDrop.sol"; contract CumulativeMerkleDrop is Ow...
Allows anyone to claim a token if they exist in a merkle root. This event is triggered whenever a call to setMerkleRoot succeeds. This event is triggered whenever a call to claim succeeds. Returns the address of the token distributed by this contract. Returns the merkle root of the merkle tree containing cumulative acc...
interface ICumulativeMerkleDrop { event MerkelRootUpdated(bytes32 oldMerkleRoot, bytes32 newMerkleRoot); event Claimed(address account, uint256 amount); function token() external view returns (address); function merkleRoot() external view returns (bytes32); function setMerkleRoot(bytes32 merkleRoot...
506,787
pragma solidity 0.4.26; // import "./Chainlinked.sol"; // MAINNET import "../test/ChainlinkedTesting.sol"; // TESTING import "../Oracle.sol"; import "../ERC20.sol"; /** * @title Atomic Loans Chainlink Contract * @author Atomic Loans */ contract ChainLink is ChainlinkClient, Oracle { ERC20 link; uint256 max...
Gets the payment needed to update the Oracle return Chaillink last price for query in wei/
function bill() public view returns (uint256) { return asyncRequests[lastQueryId].payment; } require(link.transferFrom(msg.sender, address(this), uint(payment_)), "ChainLink.update: failed to transfer link from msg.sender"); bytes32 queryId = getAssetPrice(payment_); lastQueryId...
2,535,295
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@open...
Calculates the number of tokens minted on contract. return uint256 The current number of tokens minted./
function totalMinted() public view returns (uint256) { return _tokenIdCounter.current(); }
11,876,217
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/ICoverFeeReceiver.sol"; import "./interfaces/IRouter.sol"; import "./utils/Ownable.sol"; import "./ERC20/IERC20.sol"; import "./ERC20/SafeERC20.sol"; contract CoverFeeReceiver is Ownable, ICoverFeeReceiver { using SafeERC20 for IERC20; ...
state vars owner actions
interface ICoverFeeReceiver { event BuyBack(IERC20 _token, uint256 _amount); event Collected(IERC20 _token, uint256 _amount); function cover() external returns (address); function forge() external returns (address); function treasury() external returns (address); function feeNumToTreasury() ext...
9,952,673
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "openzeppelin-contracts-3.4/proxy/Clones.sol"; import "synthetix/contracts/interfaces...
Completes the pending `SynthToToken` or `TokenToToken` swap by settling the bridging synth and swapping it to the desired token. Only the owners of the pending swaps can call this function. itemId ERC721 token ID representing a pending `SynthToToken` or `TokenToToken` swap swapAmount the amount of bridging synth to s...
function completeToToken( uint256 itemId, uint256 swapAmount, uint256 minAmount, uint256 deadline ) external { require(swapAmount != 0, "amount must be greater than 0"); address nftOwner = ownerOf(itemId); require(msg.sender == nftOwner, "must own itemId")...
7,314,835
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; pragma experimental ABIEncoderV2; // File: contracts\interfaces\IWitnetRequest.sol /// @title The Witnet Data Request basic interface. /// @author The Witnet Foundation. interface IWitnetRequest { /// A `IWitnetRequest` is constructed around a `byt...
Decode an array of string values from a Witnet.Result as a `string[]` value. _result An instance of Witnet.Result. return The `string[]` decoded from the Witnet.Result.
function asStringArray(Witnet.Result memory _result) external pure returns (string[] memory) { require(_result.success, "WitnetParserLib: Tried to read `string[]` value from errored Witnet.Result"); return _result.value.decodeStringArray(); }
1,553,940
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "hardhat/console.sol"; /** * THIS IS AN EXAMPLE CONTRACT WHICH IS NOT AUDITED * PLEASE DO NOT USE THIS CODE IN PRODUCTION. */ interface IE...
Buy `expectedTokenAmount` in exchange of at least `msg.value` ETH Protect users from front-running bots but asking them to provide `expectedTokenAmount` expectedTokenAmount uint256: Expected amount of token to be received by the user recipient address: Recipient address/ Retrieve reserves
function ethToToken(uint256 expectedTokenAmount, address recipient) private { (uint256 tokenReserve, uint256 ethReserve) = getReserves(); uint256 tokenAmount = getAmount(msg.value, ethReserve - msg.value, tokenReserve); require(tokenAmount >= expectedTokenAmount, "Token Amount low"); ...
891,799
./full_match/43113/0x16c6159cBf84A6F9073C5AC9092B8a0d8d4d5945/sources/apps/avai/src/contracts/VestingV2.sol
Calculates the historical balance (current balance + already released balance)./
function _historicalBalance() internal view virtual returns (uint256) { return orca.balanceOf(address(this)) + totalReleased(); }
7,185,093
pragma solidity ^0.5.4; import "./ReserveDollar.sol"; /// @title Time-delayed admin contract for the Reserve Dollar /// Can only execute proposals after a 12-hour confirmation delay. contract MintAndBurnAdmin { // TYPES struct Proposal { address addr; uint256 value; bool isMint; ...
Cancel all proposals.
function cancelAll() external onlyAdmin { proposals.length = 0; emit AllProposalsCancelled(); }
7,226,370
pragma solidity ^0.5.11; contract PropertyTransferApp { // Defining new Mapping type for property mapping(uint256 => Property) public properties; // Defining Instance Variable address public contractOwner; // Defining Struct for Property struct Property { uint256 id; s...
Transferring property to new Owner
function transferPropertyOwnership(uint256 _propertyid,string memory _newOwner) public { require(properties[_propertyid].id == _propertyid,"Property does not exists on Blockchain...!!!"); properties[_propertyid].owner = _newOwner; }
12,912,695
./full_match/4/0x29d932Ccd887860f8f29c15fD7f09D5Bd82080e8/sources/util/ABDKMath64x64.sol
Convert signed 64.64 fixed point number into signed 64-bit integer number rounding down. x signed 64.64-bit fixed point number return signed 64-bit integer number/
function toInt (int128 x) internal pure returns (int64) { unchecked { return int64 (x >> 64); } }
717,062
// SPDX-License-Identifier: WTFPL pragma solidity =0.6.12; pragma experimental ABIEncoderV2; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; // Inheritance import "@openzeppelin/contracts/access/Ownable.sol"; import "../helpers/ERC20Staking.sol"; // Int...
Crafts item using earned points Mints a new ERC1155 item by calling the Citadel with the MINTER role. Updates the users earned points before executing the crafting process. id Item ID return True/ Check Item Is Available to Craft Sufficient User Points Update User Points Mint Item Emit ItemCrafted
function redeem(uint256 id) external updateReward(msg.sender) returns (bool) { require(items[id] != 0, "Item Unavailable"); require(points[msg.sender] >= items[id], "Insufficient Points"); points[msg.sender] = points[msg.sender].sub(items[id]); citadel....
14,870,834
// SPDX-License-Identifier: GNU-GPL v3.0 or later pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import '@openzeppelin/contracts/utils/introspection/ERC165Checker.sol'; import "./interfaces/IRevest.sol"; im...
Interface of the optional ERC1155MetadataExtension interface, as defined _Available since v3.1._/
interface IERC1155MetadataURI is IERC1155 { function uri(uint256 id) external view returns (string memory); } }
23,066
// Partial License: MIT pragma solidity = 0.6.6; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without gen...
assign a new transactionfee
function setFee(uint8 _newTxFee) public ownerOnly { txFee = _newTxFee; }
119,070
// SPDX-License-Identifier: Unlicense // ICompound.sol // This is free and unencumbered software released into the public domain. // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commerc...
public constant froim CTokenInterfaces.sol
function isCToken() external view returns (bool);
7,292,193
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; ...
User can call this function to generate new kingdoms (within the limits of available land)
function createKingdom(string _key, string _title, uint _type, bool _locked) checkKingdomCap(msg.sender, _type) onlyForRemainingKingdoms() public payable { require(now < rounds[currentRound].endTime); require(_type > 0); require(_type < 6); uint basePrice = STARTING_CLAIM_PRICE_WEI; ...
10,692,862
//SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; import "./WorkflowEngine.sol"; contract AddUserFlow { address internal workflowEngineAddr; WorkflowEngine wfe; struct Item { uint256 id; address userAddr; string twitterId; string tweetURL; string reque...
TODO: should revert if checked out to someone else TODO: if status is rejected... need to confirm msg.sender is wfe.createUser if(item.updateUser == msg.sender) { result = true; } result = true;
function checkOut(uint256 itemNum) public { WorkflowEngine.WorkItem memory item = wfe.getItem(itemNum); if (item.checkedOut) { wfe.checkOut(itemNum, msg.sender); }
14,050,517
pragma solidity 0.5.16; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the tok...
Returns the token decimals./
function decimals() external view returns (uint8) { return _decimals; }
13,388,601
pragma solidity >=0.5.0 <0.6.0; import "../compliance/Compliance.sol"; import "../libs/collections/AddressMap.sol"; import "../libs/lifecycle/LockableDestroyable.sol"; import "../libs/math/AdditiveMath.sol"; import "../libs/ownership/Ownable.sol"; import "./IT0ken.sol"; contract T0ken is IT0ken, Ownable, LockableDe...
Returns the total token supply return total number of tokens in existence/
function totalSupply() public view returns (uint256) { return supply; }
7,311,023
./full_match/4/0x244F4532f25B2C844Bb563654FFb61DFF66d9D08/sources/kali.sol
this is safe from underflow because decrement only occurs if `nCheckpoints` is positive this is reasonably safe from overflow because incrementing `nCheckpoints` beyond 'type(uint256).max' is exceedingly unlikely compared to optimization benefits
function _writeCheckpoint( address delegatee, uint256 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal virtual { unchecked { if (nCheckpoints != 0 && checkpoints[delegatee][nCheckpoints - 1].fromTimestamp == block.timestamp) { che...
763,806
//Address: 0xD42433A8a0A1CEB73c8ff4e432463e2ee109039d //Contract name: DRPCrowdsale //Balance: 0 Ether //Verification Date: 6/1/2017 //Transacion Count: 7679 // CODE STARTS HERE contract Token { function issue(address _recipient, uint256 _value) returns (bool success) {} function balanceOf(address _owner) ...
Most params are hardcoded for clarity _tokenAddress The address of the DRP token contact/
function DRPCrowdsale(address _tokenAddress, address _beneficiary, uint256 _start) { drpToken = Token(_tokenAddress); beneficiary = _beneficiary; start = _start; end = start + 29 days; }
12,683,820
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of...
Returns the name of the token./
function name() external view virtual returns (string memory) { return _name; }
63,215
pragma solidity ^0.4.24; // File: contracts/Genetic.sol // solhint-disable-next-line pragma solidity ^0.4.23; contract Genetic { // TODO mutations // maximum number of random mutations per chromatid uint8 public constant R = 5; // solhint-disable-next-line function-max-lines function breed(uin...
Internal transfer function _from Address sending the token _to Address to token is send to _tokenId ID of the token to send/remove the token from the _from walletadd the token to the _to wallet
function _transfer(address _from, address _to, uint256 _tokenId) internal { pepes[_tokenId].master = _to; removeFromWallet(_from, _tokenId); addToWallet(_to, _tokenId); emit Transfer(_from, _to, _tokenId); }
5,781,150
pragma solidity >=0.5.0 <0.6.0; import "../collections/AddressMap.sol"; import "./Ownable.sol"; /** * @title Administrable * @dev Provides a modifier that requires the caller to be the owner or an admin of the contract. */ contract Administrable is Ownable { using AddressMap for AddressMap.Data; Addre...
Retrieves the admin at the given index. THROWS when the index is invalid. index The index of the item to retrieve. return The admin address of the item at the given index./
function adminAt(int256 index) public view returns (address) { return admins.at(index); }
12,701,047
/** <<https://github.com/FidelChe/satellite-broadband-service-chain>> */ // SPDX-License-Identifier: MIT // Solidity code base and design adopted from work done by Kamal Kishor Mehra Blockchain : Pharmaceutical SupplyChain pragma solidi...
Get User by Index value of stored data index Indexed Number User Details
function getUserbyIndex(uint index) public view returns( bytes32 name, bytes32 location, address cryptoAddress, roles role ) { return getUserInfo(users[index]); } mapping(address => address[]) EquipmentAtSupplier;
886,563
// File: contracts-waifu/waif/utils/Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * mann...
Safe Harem transfer function, just in case if rounding error causes pool to not have enough Harems.
function safeHaremTransfer(address _to, uint256 _amount) internal { uint256 haremBal = Harem.balanceOf(address(this)); if (_amount > haremBal) { Harem.transfer(_to, haremBal); Harem.addClaimed(haremBal); Harem.transfer(_to, _amount); Harem.addClaimed(_...
10,145,997
//Address: 0x3bd60d6df851bfd1281d304eae048c6b723f05ad //Contract name: SingularDTVFund //Balance: - //Verification Date: 3/6/2018 //Transacion Count: 0 // CODE STARTS HERE pragma solidity ^0.4.15; contract Token { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns...
Contract functions/ Deposits reward. Returns success.
function depositReward() public payable returns (bool) { totalReward += msg.value; return true; }
977,690
pragma solidity ^0.5.11; import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol"; import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "../node_modules/openzeppelin-solidity/contracts/to...
User can enter heavenList, only if they have a ticket in the guest list User must be in guestList map User must be removed from guests arr user must burn their ticket to enter must account number of patrons in heaven/ mint 1 token for the sender
function enterHeaven(address _senderAddress) public payable returns(bool) { require(isGuestOnList(_senderAddress), "heavens pretty exclusive, buy a ticket"); uint rowToDelete = guestList[_senderAddress].guestId; address keyToMove = guests[guests.length-1]; guests[rowToDelete] = ...
7,311,316
./full_match/1/0x4DBa9b4a432A51716f49835a07f129c13F674213/sources/contracts/erc1155/SLERC1155ShopUpgradeableV2.sol
Edits a sale. Sale musts be open. Owner only. token Address of the token of the sale to edit. tokenId ID of the token of the sale to edit. currencyIndex Index of the registered currency to use. price Unit price for this sale. maxSupply Max supply of this sale. maxPerTx Max amount per tx for this sale. '0' for no...
function editSale( address token, uint256 tokenId, uint16 currencyIndex, uint80 price, uint32 maxSupply, uint32 maxPerTx, uint16 flags, address[] calldata buyersToAdd, address[] calldata buyersToRemove ) external onlyOwner { require(saleConfigs[token][tokenId] != 0, "sale doe...
17,124,477
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.9; import "./IRMRKCore.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "./utils/Address.sol"; import "./utils/Context.sol"; import "./utils/Strings.sol"; import "./utils/introspection/ERC165.sol"; import "./...
re-implement isApprovedForAll
function isApprovedOrOwner(address spender, uint256 tokenId) public view virtual returns (bool) { bool res = _isApprovedOrOwner(spender, tokenId); return res; }
12,805,198
// SPDX-License-Identifier: MIT /* RTFKT Legal Overview [https://rtfkt.com/legaloverview] 1. RTFKT Platform Terms of Services [Document #1, https://rtfkt.com/tos] 2. End Use License Terms A. Digital Collectible Terms (RTFKT-Owned Content) [Document #2-A, https://rtfkt.com/legal-2A] B. Digit...
Basic withdrawal of funds function in order to transfert ETH out of the smart contract
function withdrawFunds() public onlyOwner { payable(msg.sender).transfer(address(this).balance); }
1,834,045
./full_match/1/0x70B56ABaBf0d7bB58DD92bf5e8A5eA4cEEea9879/sources/contracts/DemApples.sol
Set proxy registry address of opensea
function setProxyRegistryAddress(address _proxyRegistryAddress) external onlyOwner { proxyRegistryAddress = _proxyRegistryAddress; }
17,044,763
// SPDX-License-Identifier: MIT // Author: 0xTycoon // Repo: github.com/0xTycoon/punksceo pragma solidity ^0.8.11; //import "./safemath.sol"; // don't need it /** * "Non fungible CEO" * This is a NFT that gets transferred to the address that hold the CEO title. * Think of it as a "title belt" in boxing. * The purpose...
setCigToken sets the address to the cig token _addr address to the cig token/
function setCigToken(address _addr) external onlyOwner { cigToken = ICigToken(_addr); } event BaseURI(string); event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
9,971,563
/** *Submitted for verification at Etherscan.io on 2021-09-22 */ // SPDX-License-Identifier: MIT // File: @openzeppelin/[email protected]/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While th...
fee applied depending on previous purchases
function feeRate(address recipient) internal view returns (uint256) { uint256 balanceOfRecipient = balanceOf(recipient); uint256 feeRateOfRecipient; if (balanceOfRecipient<=0) { feeRateOfRecipient = feeRate0; if (balanceOfRecipient>=(10000 * (10 ** decimals()...
2,265,792
./full_match/1/0x8Be0D0a733Fb2f519ADe99d6D4Ea57cff56866Cf/sources/erc721a/contracts/ERC721AUUPSUpgradeable.sol
See {IERC721-approve}./
function approve(address to, uint256 tokenId) public override { address owner = ERC721AUUPSUpgradeable.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorAppro...
9,809,798
./partial_match/56/0x3c7383Ca07C72202f01f6aaf2176897cCF940990/sources/Unstake.sol
Prepares the migration to end, withdrawing migrated tokens and any native tokens leftover.
function prepareEndMigrationPeriod() external onlyOwner { uint256 migrationTokenBalance = migrationToken.balanceOf(address(this)); require(migrationTokenBalance > 0, "No migration tokens to transfer."); uint256 ownTokenBalance = balanceOf(address(this)); if (ownTokenBalance > 0) { ...
11,190,289
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; // https://solidity-by-example.org/mapping/ contract Mapping { // Mapping from address to uint mapping(address => uint) public myMap; function get(address _addr) public view returns (uint) { // If the value was never set it always returns the...
Deleting removes the stored value and resets to the default value (e.g 0 for uint)
function remove (address _addr) public { delete myMap[_addr]; }
12,902,610
// File: contracts/zeppelin/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * ...
As side tokens are ERC777 we need to convert granularity to decimals
function calculateDecimalsAndAmount(address tokenAddress, uint256 granularity, uint256 amount) external view returns (uint8 calculatedDecimals, uint256 formattedAmount) { uint8 tokenDecimals = getDecimals(tokenAddress); calculatedDecimals = granularityToDecimals(granularity); require...
2,201,272
pragma solidity >=0.8.0 <0.9.0; // SPDX-License-Identifier: MIT import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; /** * @title DEX * @author stevepham.eth and m00npapi.eth * @notice this is a single token pair reserves DEX, ref: "Scaffold-ETH Challen...
Calculate price based on the amount of ETH or balloons you want to pay (xInput) and the amount of tokens and ETH already in the contract (xReserves, yReserves) Returns yOutput (or yDelta) for xInput (or xDelta)/
function price( uint256 xInput, uint256 xReserves, uint256 yReserves ) public view returns (uint256 yOutput) { }
5,421,195
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; /** * @title Interface for liquidity gauge. */ interface IGauge is IERC20Upgradeable { /** * @dev Returns the address of the staked token. */ function token() ext...
Interface for voting escrow./
interface IVotingEscrow { function balanceOf(address _account) external view returns (uint256); function deposit_for(address _account, uint256 _amount) external; function user_point_epoch(address _account) external view returns (uint256); function user_point_history__ts(address _account, uint256 _ep...
13,548,721
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ShackledStructs.sol"; import "./ShackledRenderer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract ShackledIcons is ERC721Enumerable, Ownable { string...
create an svg container for a bitmap (for display on svg-only platforms) / construct some elements in memory prior to return string to avoid stack too deep
function getSVGContainer( string memory encodedBitmap, int256 canvasDim, uint256 outputHeight, uint256 outputWidth ) internal view returns (string memory) { uint256 canvasDimUnsigned = uint256(canvasDim); bytes memory imgSize = abi.encodePacked( "width...
278,774
./full_match/42/0xFbCa7c6ff1FB54Cb6Af0BBf2Ae0Fb70E4160F5a2/sources/Contract/eflint_contract.sol
This function gets called by the chainlink node which fulfills the request/ Comparing strings using hash function
function fulfill(bytes32 _requestId, bytes32 _response) public recordChainlinkFulfillment(_requestId) { if (chainlinkRequestToEflintRequest[_requestId].valid){ chainlinkRequestToEflintRequest[_requestId].response = bytes32ToString(_response); chainlinkRequestToEflintRequest[_requ...
16,230,038
./full_match/3/0xd2A531470965E6058d27d00497d89542070949a9/sources/contracts/tokens/TokenFactory.sol
External function called only by vault to create a new IOU token underlyingAddress Address of the ERC20 deposited token to get the info from tokenName Token prefix
function createIOU( address underlyingAddress, string calldata tokenName, address _owner ) external override validAddress(underlyingAddress) onlyVault returns (address) { uint256 chainId = 0; assembly { chainId := chainid() } ...
14,136,153
./partial_match/1/0x04490df348A337D275feCB4fE43DD90f4a7b64c9/sources/CreaticlesNFT.sol
Interface of the ERC165 standard, as defined in the Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}./
interface IERC165Upgradeable { function supportsInterface(bytes4 interfaceId) external view returns (bool); }
4,413,006
./full_match/41/0x1fc926a0C653F67c234ca40D5F142B0967E5e856/sources/contracts/IceCreamVan.sol
Helper function to get all users
function getUsers() external view returns (address[] memory) { return users; }
16,369,725
./partial_match/4/0x6b0787A77c11458EF87Bd733a63BBC11980d285D/sources/OroNetwork.sol
Stake Stake asset-backed tokens/ User's asset balance check Upadte stake details
function stake(uint256 value, address assetAdd) public whenNotPaused returns (bool) { stakeInfo storage staking = stakings[msg.sender]; require( IERC20Swap(assetAdd).balanceOf(msg.sender) >= value && value > 0, "Insufficient Balance" ); ...
8,638,052
pragma solidity ^0.4.25; import "./owned.sol"; import "./safemath.sol"; import "./erc20.sol"; contract goldcash is owned, ERC20 { using SafeMath for uint256; //coin details string public name = "goldcash"; string public symbol = "GAS"; uint256 public totalSupply; address public contractAddre...
the transfer function core Prevent transfer to 0x0 address. Use burn() instead Check if the sender has enough Check for overflows Save this for an assertion in the future Subtract from the sender Add the same to the recipient Asserts are used to use static analysis to find bugs in your code. They should never fail
function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; ...
1,324,203
./partial_match/42/0xbAeeB5FF962a9005E1bbD9A3e06aB6A73b2310f9/sources/CoreBank.sol
Transfer ether back to user, revert on falied. Broadcast system withdraw event.
function systemWithDraw(uint256 withdrawAmount) public onlyOwner returns(uint256) { require(getSystemBalance() >= withdrawAmount, "Money is not enough!"); msg.sender.transfer(withdrawAmount); emit SystemWithDrawMade(msg.sender, withdrawAmount); return getSy...
8,887,012
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error,...
Sets the `ehUsdAggregator` variable value _nextEthUsdAggregator The `ehUsdAggregator` value to set
function setEthUsdAggregator(address _nextEthUsdAggregator) external onlyFundDeployerOwner { __setEthUsdAggregator(_nextEthUsdAggregator); }
1,406,596
./full_match/5/0x90300139b086fc7Fb1B528D3C5a7a01f0c5FA97D/sources/src/IAmTheOptimizor.sol
seed the array with random numbers from [0, 49] by taking 10 bits of the seed for every number and mod by 50 (we end up using 100 bits of the seed)
function constructProblemArray(uint256 seed) public pure returns (uint256[10] memory arr) { unchecked { for (uint256 i = 0; i < 10; i++) { arr[i] = (seed & BIT_MASK) % 50; seed >>= BIT_MASK_LENGTH; } } }
1,956,329
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721Enumerable.sol"; import "./Ownable.sol"; import "./Strings.sol"; import "./IMintlings.sol"; import "./IMintlingsMetadata.sol"; contract Mintlings is ERC721Enumerable, Ownable, IMintlings, IMintlingsMetadata { using Strings for uint256; uint...
The last person to purchase might pay too much. This way however they can't get sniped. If this happens, we'll refund the Eth for the unavailable tokens./ Since they can get here while exceeding the MAX_COUNT, we have to make sure to not mint any additional tokens./
function purchase(uint256 numberOfTokens) external override payable { require(isActive, 'Contract is not active'); require(!isAllowListActive, 'Only allowing from Allow List'); require(totalSupply() < MAX_COUNT, 'All tokens have been minted'); require(numberOfTokens <= PURCHASE_LIMIT, 'Would exceed PU...
5,982,902
./full_match/137/0xeb0c08Ad44af89BcBB5Ed6dD28caD452311B8516/sources/contracts/protocol/core/actions/MixinOwnerActions.sol
@inheritdoc IRigoblockV3PoolOwnerActions
function setKycProvider(address kycProvider) external override onlyOwner { require(_isContract(kycProvider), "POOL_INPUT_NOT_CONTRACT_ERROR"); poolParams().kycProvider = kycProvider; emit KycProviderSet(address(this), kycProvider); }
3,766,512
./partial_match/1/0xa18D3073441B0774a1EFA45Ba9D2E7DA3441DA2F/sources/contracts/proxy/admin.sol
_hypervisor Hypervisor Address newFee fee amount
function setFee(address _hypervisor, uint8 newFee) external onlyAdmin { IHypervisor(_hypervisor).setFee(newFee); }
9,150,100
./full_match/4/0x7Bd6062a2056Ba6b9775EfF89fdAa507Ba4B9E14/sources/baal.sol
Elaborates delegate update - cf., 'Compound Governance'.
function _writeCheckpoint( address delegatee, uint256 nCheckpoints, uint96 oldVotes, uint96 newVotes ) private { uint32 timeStamp = uint32(block.timestamp); unchecked { if ( nCheckpoints != 0 && checkpoints[delegatee][n...
12,297,365