file_name
stringlengths
71
779k
comments
stringlengths
0
29.4k
code_string
stringlengths
20
7.69M
__index_level_0__
int64
2
17.2M
./full_match/1/0x70182C93914848c7A02a6302f4e4ed4938CDef25/sources/contracts/CampaignContract.sol
no whitelist, everyone can mint
function buyTokenWithEth( uint32 _campaignId, uint256 _amount, bytes32[] memory _proof ) public payable nonReentrant { require(_campaignId < campaignNum, 'Invalid campaign ID'); CampaignTrack storage campaign = campaigns[_campaignId]; require(_validateBuyToken(_c...
17,016,901
./partial_match/1/0x56146633c6C9D3536eEBbf0bcB1D5F20A788B82a/sources/ETHRegistrarController.sol
v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId); Returns whether the given spender can transfer a given token ID spender address of the spender to query tokenId uint256 ID of the token to be transferred return bool whether...
function _beforeTokenTransfer( address from, address to, uint256 tokenId function _afterTokenTransfer( address from, address to, uint256 tokenId } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view override returns (bool) { a...
4,197,998
pragma solidity ^0.6.11; //certo c063v200826 noima (c) all rights reserved 2020 /// @title A CertoProof Of existence smartcontract /// @author Mauro G. Cordioli ezlab /// @notice Check the details at https://certo.legal/smartcontract/v63 contract ProofCertoChainContract { int256 public constant Version = 0x6320...
Notarize both hashes and emit block timestamps hashproof The proof sha256 hash to timestamp hashmeta The metadata sha256 hash to timestamp
function NotarizeProofMetaTimeStamp(bytes32 hashproof, bytes32 hashmeta) public onlyBy(owner) { uint256 tsproof = CertoLedgerTimestamp[hashproof]; if (tsproof == 0) { tsproof = block.timestamp; CertoLedgerTimestamp[hashproof] = tsproof; } ...
1,827,802
./full_match/1/0xE8CC47323867A3b15E27c986A92a0e4edB078848/sources/contracts/DAXLicensing.sol
We use the "userPaid" modifier and we allow only users with valid subscriptions to call this function
function increaseC() public userPaid { c++; }
8,379,092
./full_match/3/0x64BE47D36d703e36d87BBd58287A5f5a55f512ad/sources/contracts/LightningProtocol.sol
after 156, the protocol reaches its final stage fees will be set to 0 and the remaining total supply will be 550,000
function _rebase(uint256 supplyDelta) internal { _lightningCycle = _lightningCycle.add(1); _tTotal = _tTotal.add(supplyDelta); if(_lightningCycle > 156 || _tTotal <= 550000 * _DECIMALFACTOR){ _initializeFinalStage(); } }
8,129,614
pragma solidity ^0.5.0; import "truffle/Assert.sol"; import "truffle/DeployedAddresses.sol"; import "../contracts/FundMarketplace.sol"; import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol"; contract TestFundMarketplace { //State Variables //FundMarketplace contract FundMarketplace ...
Test for both a partial and a full withdrawalInvestor's pre-withdrawal balancePartial withdrawal amountinvestor withdraw a portion of his fundsTestsinvestor withdraws remainder of fundsTestsTestsconfirm fees were refunded
function testWithdrawFunds() public { uint preBalance = investorAddr.balance; uint amount = 1 ether; uint currentFees; (,,currentFees) = fm.getFundDetails2(fundNum, investorAddr); investor.withdrawFunds(fm, fundNum, amount); uint midBalance = investorAddr.balance; ...
5,460,860
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; contract Candidate { /* Structs */ struct CandidateDetails { uint256 id; string name; string nic; string party; } /* Storage */ /** @dev Number of candidates added. */ address[] private candidateAddre...
Get total candidate count. Returns total candidate count./
function getCandidateCount() public view returns (uint256 count_) { count_ = candidateAddresses.length; }
13,115,270
./full_match/11155111/0xc9241Cf4cD7d9569cA044d8202EF1080405Bc6C9/sources/src/Drips.sol
Calculates the time range in the future in which a receiver will be dripped to. receiver The drips receiver maxEnd The maximum end time of drips
function _dripsRangeInFuture(DripsReceiver memory receiver, uint32 updateTime, uint32 maxEnd) private view returns (uint32 start, uint32 end) { return _dripsRange(receiver, updateTime, maxEnd, _currTimestamp(), type(uint32).max); }
3,827,234
//SPDX-License-Identifier: mit pragma solidity 0.7.6; import "./AvaToken.sol"; contract Wrapper { AvaToken public tokenC; constructor (address _tokenC) { tokenC = AvaToken(_tokenC); } /** * Convert an amount of input token_ to an equivalent amount of the output token * * @param...
Convert an amount of the output token to an equivalent amount of input token_ token_ address of token to receive amount amount of token to swap/receive/
function unswap(address token_, uint amount) external { require(amount > 0, "Wrapper: not zero"); uint senderBalance = IERC20(tokenC).balanceOf(address(msg.sender)); require(senderBalance >= amount, "Wrapper: insufficient balance"); tokenC.transferFrom(msg.sender, address(this), amou...
7,289,135
./partial_match/4/0xC7d16FC032Dd0037aACfa038539c4B49Ee798850/sources/Emeth.sol
Job Functions Requester
function request(bytes16 _jobId, uint256 _programId, string calldata _programLink, string calldata _param, uint256 _gas) external returns (bool) { require(!jobs[_jobId].exist, "Job ID already exists"); IERC20 token = IERC20(tokenAddress); require(token.balanceOf(msg.sender) >= _gas); ...
8,783,787
./full_match/1/0x5577e86C4d41e86e2729B9c3Ed4bBEb8f4a54AEf/sources/contracts/liquidation.sol
call on the comptroller contractget the exact amount of collateral to be liquidated
function amountToBeLiquidatedSieze(address _cToken, address _cTokenCollateral, uint _actualRepayAmount) external view returns (uint) { (uint error, uint cTokenCollateralAmount) = comptroller .liquidateCalculateSeizeTokens( _cToken, _cTokenCollateral, _actualRepayAmount ); require(err...
4,935,769
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; pragma abicoder v2; import "./interfaces/IUniswapV3Factory.sol"; import "./interfaces/INonfungiblePositionManager.sol"; import "./interfaces/IUniswapV3PoolActions.sol"; import "./interfaces/ISwapRouter.sol"; import "./interfaces/IERC20.sol"; import "./inte...
Approve poolContract to spend two erc20 tokens
function approval(address _token0, address _token1, uint24 _fee) public override { token0.approve(getPair(_token0, _token1, _fee), uint(-1)); token1.approve(getPair(_token0, _token1, _fee), uint(-1)); }
7,319,871
// SPDX-License-Identifier: MIT pragma solidity >=0.8.4; import {SDaoRegistrar} from '../SDaoRegistrar.sol'; import {ISDaoRegistrarLimited} from './interfaces/ISDaoRegistrarLimited.sol'; /** * @title SDaoRegistrarLimited contract. * @dev Implementation of the {ISDaoRegistrarLimited}. */ abstract contract SDaoRegis...
Update limit registration number. Can only be called by owner. registrationLimit The limit of registration number./
function updateRegistrationLimit(uint256 registrationLimit) public override onlyOwner { _updateRegistrationLimit(registrationLimit); }
13,039,322
pragma solidity >=0.4.0; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 ...
ensure that at least one full period has passed since the last update overflow is desired, casting never truncates cumulative price is in (uq112x112 price seconds) units so we simply wrap it after division by time elapsed
function update() external override returns (bool) { (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(PAIR)); if (timeElapsed < PERIOD) return false; price0Average = FixedPoint.uq112x112( ...
6,081,077
./full_match/8453/0x02F55D53DcE23B4AA962CC68b0f685f26143Bdb2/sources/contracts/Swap.sol
Swap tokenX for tokenY, given amount of tokenY user desires. swapParams params(for example: desired amount in above line), see SwapParams for more
function swapX2YDesireY( SwapParams calldata swapParams ) external payable checkDeadline(swapParams.deadline) { require(swapParams.tokenX < swapParams.tokenY, "x<y"); address poolAddr = pool(swapParams.tokenX, swapParams.tokenY, swapParams.fee); address payer = msg.sender; ...
11,552,132
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "../SocialTokenNFT/ERC721.sol"; import "../SocialTokenNFT/SizeSortedList.sol"; import "../SocialTokenNFT/ISocialTokenNFT.sol"; import "../...
This version takes the id numbers of two NFTs to be forged together. The NFTs must be owned by the caller and of the same level. The first id number passed in will be advanced to the next level higher, while the second will be burned. Check constraints ownerOf takes care of checking that the ID has actually been min...
function forge(uint256 chosenNftId, uint256 scrappedNftId) public { NFTData memory forgedItem = dataMap[chosenNftId]; NFTData storage material = dataMap[scrappedNftId]; address caller = _msgSender(); require(ownerOf(chosenNftId) == caller, NOT_APPROVED); require(ownerOf(scra...
2,536,295
./full_match/1/0x1d737B886D195715dc0d6f82637dd48408eFB84B/sources/taoli.sol
Converts an internal asset cash value to its underlying token value. assetRate exchange rate assetBalance amount to convert to underlying Calculation here represents: rate balance internalPrecision / rateDecimals underlyingPrecision
function convertToUnderlying(int256 assetBalance, int256 assetRate, int256 underlyingDecimals) internal pure returns (int256) { int256 underlyingBalance = assetRate .mul(assetBalance) .div(ASSET_RATE_DECIMAL_DIFFERENCE) .div(underlyingDecimals)...
8,449,073
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; pragma experimental ABIEncoderV2; //Openzeppelin import "./openzeppelin-solidity/contracts/SafeMath.sol"; import "./openzeppelin-solidity/contracts/ERC20/SafeERC20.sol"; import "./openzeppelin-solidity/contracts/ERC1155/IERC1155.sol"; import "./openzeppelin-soli...
Sets the marketplace listing's 'exists' variable to false and resets quantity. user Address of the seller. poolAddress Address of the pool's token. index Index of the marketplace listing./
function _removeListing(address user, address poolAddress, uint index) internal { marketplaceListings[index].exists = false; marketplaceListings[index].numberOfTokens = 0; userToListingIndex[poolAddress][user] = 0; }
1,753,838
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./interfaces/IERC20.sol"; import "./interfaces/IWrappedPosition.sol"; import "./interfaces/ITranche.sol"; import "./interfaces/ITrancheFactory.sol"; import "./interfaces/IInterestToken.sol"; import "./libraries/ERC20Permit.sol"; import "./librarie...
Sn internal version of the above function 'encodeAndWriteTimestamp' solhint-disable-next-line Cast the prefix string to a byte array Cast the output string to a byte array Copy the bytes from the prefix onto the byte array NOTE - IF PREFIX CONTAINS NON-ASCII CHARS THIS WILL CAUSE AN INCORRECT STRING LENGTH
function _encodeAndWriteTimestamp( string memory _prefix, uint256 _timestamp, string storage _output ) internal { bytes memory bytePrefix = bytes(_prefix); bytes storage bytesOutput = bytes(_output); for (uint256 i = 0; i < bytePrefix.length; i++) { by...
44,266
./partial_match/7700/0xCD9A55aa5C890b132700Ef9aA8218Db2F55327d8/sources/src/Reservoir.sol
Drips the maximum amount of wcantos to match the drip rate since inception Note: this will only drip up to the amount of wcantos available. return The amount of wcantos dripped in this call/ First, read storage into memory Next, calculate intermediate values Finally, write new `dripped` value and transfer wcantos to t...
function drip() public returns (uint) { WETH wcanto_ = wcanto; uint dripRate_ = dripRate; uint dripStart_ = dripStart; uint dripped_ = dripped; address target_ = target; uint blockNumber_ = block.number; uint dripTotal_ = mul(dripRate_, blockNumber_ - dripStart_, "dripTotal overflow"); ...
3,508,545
pragma solidity ^0.5.0; /// @title Provides helper functions to determine the validity of passed signatures. /// @author Noah Zinsmeister /// @dev Supports both prefixed and un-prefixed signatures. contract SignatureVerifier { /// @notice Determines whether the passed signature of `messageHash` was made by the pri...
Common logic for all address removal.
function removeAssociatedAddress(uint ein, address addressToRemove) private { identityDirectory[ein].associatedAddresses.remove(addressToRemove); delete associatedAddressDirectory[addressToRemove]; }
5,497,692
pragma solidity ^0.4.2; //Art class for artwork contract DigiArtPlat{ // function DigiArtPlat() public{ // } address[9] public userDat; address[9] public buyerDat; uint[9] public prices; uint[9][3] public status1; enum ArtStates { hold, selling, auctioning, renting} struct Art{ ...
require(_to != address(this) && _to != arts[ID].owner); require(arts[ID].state == ArtStates.hold); arts[ID].state = ArtStates.renting; arts[ID].targetRenter = _to; arts[ID].currentRent = _rent;
function initialRent(uint ID, uint _rent /*, address _to*/) public onlyOwner(arts[ID]){ require(ID >= 0 && ID <= 9); prices[ID] = _rent; status1[ID][1] = 1; }
13,063,368
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; // Sources flattened with hardhat v2.8.4 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.5.0 // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) /** * @dev Interface of the ERC20 standard as de...
Sets the stored oracle and LINK token contracts with the addresses resolved by ENS Accounts for subnodes having different resolvers ensAddress The address of the ENS contract node The ENS node hash/
function useChainlinkWithENS(address ensAddress, bytes32 node) internal { s_ens = ENSInterface(ensAddress); s_ensNode = node; bytes32 linkSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_TOKEN_SUBNAME)); ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode)); setCha...
1,301,102
pragma solidity ^0.4.21; // File: contracts/CCLToken.sol // modified from Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. // The MIT Licence. contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(u...
check the signaturebytes32 hash = sha256("Eidoo icoengine authorization", this, buyerAddress, buyerId, maxAmount);
function buyImplementation(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) private returns (bool) { bytes32 hash = sha256(abi.encodePacked("Eidoo icoengine authorization", this, buyerAddress, buyerId, maxAmount)); emit ThisCheck(this, msg.sender); ...
12,140,601
./full_match/1/0x6b0648729571c881Eb6D36cC12DCA04767Ee6706/sources/contracts/v1/MinterV1.sol
Returns remaining mints for a given address. Returns 0 if no maximum per address is set for collection `_collectionId`. Note that max mints per address can be changed at any time by the owner. Also note that all max mints per address are limited by a collections's maximum mints as defined on the core contract. This fun...
function collectionRemainingMintsForAddress( uint256 _collectionId, address _address ) external view onlyValidCollectionId(_collectionId) returns ( uint256 mintsRemaining, bool hasLimit ) { uint256 maxMintsPerAddress = c...
8,415,610
./full_match/1/0x3829943c53F2d00e20B58475aF19716724bF90Ba/sources/src/contracts/adapters/ccip/CCIPAdapter.sol
@inheritdoc IAny2EVMMessageReceiver
function ccipReceive(Client.Any2EVMMessage calldata message) external onlyRouter { address srcAddress = abi.decode(message.sender, (address)); uint256 originChainId = nativeToInfraChainId(message.sourceChainSelector); require( _trustedRemotes[originChainId] == srcAddress && srcAddress != address(0...
17,138,072
./partial_match/1/0xFaDBCa1DCA714B8Dec5535b0f2BcdFC89E6494c5/sources/SHIB2020.sol
exclude from paying fees or having max transaction amount
constructor() ERC20("Shiba Inu 2020", "SHIB2020") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Fa...
4,335,397
/** * PERSONO.ID is WEB 3.0 cornerstone. * Human first. UBI out of the box. Inevitable. * This contract is a crowdsale of transitional GUT tokens for ETH. * Join early. Don't miss the rise of the great, and impressive bounties. * Open site() at GUT token address 0xbA01AfF9EF5198B5e691D2ac61E3cC126F25491d...
Extend parent behavior requiring purchase to respect the funding cap. beneficiary Token purchaser weiAmount Amount of wei contributed/
function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal view { require(capNotReached(),"Hardcap is reached."); require(notClosed(), "TCO is finished, sorry."); super._preValidatePurchase(beneficiary, weiAmount); }
980,131
pragma solidity ^0.4.24; contract SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) { if (x > MAX_UINT256 - y) revert(); return x + y; } ...
Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) { return totalSupply; }
6,843,179
./partial_match/56/0x281A38643783fCb7DF16f24978b95A2FA2C741dE/sources/StrategyBerryLP.sol
Function that has to be called as part of strat migration. It sends all the available funds back to the vault, ready to be migrated to the new strat./
function retireStrat() external { require(msg.sender == vault, "!vault"); IChefMaster(masterchef).withdrawLPToken(poolId, balanceOfPool()); uint256 pairBal = IERC20(lpPair).balanceOf(address(this)); IERC20(lpPair).transfer(vault, pairBal); }
11,183,539
/** *Submitted for verification at Etherscan.io on 2020-02-11 */ // File: @aragon/os/contracts/common/EtherTokenConstant.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; // aragonOS and aragon-apps rely on address(0) to denote native ETH, in // contracts where both tokens and ETH are accept...
Change minimum acceptance quorum to `@formatPct(_minAcceptQuorumPct)`% _minAcceptQuorumPct New acceptance quorum/
function changeMinAcceptQuorumPct(uint64 _minAcceptQuorumPct) external authP(MODIFY_QUORUM_ROLE, arr(uint256(_minAcceptQuorumPct), uint256(minAcceptQuorumPct))) { require(_minAcceptQuorumPct <= supportRequiredPct, ERROR_CHANGE_QUORUM_PCTS); minAcceptQuorumPct = _minAcceptQuorumPc...
451,051
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/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 these are generally available * via msg.sender and msg.data, they should no...
Set provenance hash when it's calculated
function setProvenanceHash(string memory provenanceHash) public onlyOwner { RABBIT_PROVENANCE = provenanceHash; }
6,333,845
./partial_match/4/0xC828Ad244D4Bb8464802718ffCD801E0D272b40B/sources/animalMain.sol
TO DO 請使用require判斷要轉的動物id是不是轉移者的增加受贈者的擁有動物數量減少轉出者的擁有動物數量動物所有權轉移
function transfer(address _to, uint256 _tokenId) public { require(msg.sender == ownerOf(_tokenId)); ownerAnimalCount[_to]=ownerAnimalCount[_to].add(1); ownerAnimalCount[msg.sender] = ownerAnimalCount[msg.sender].sub(1); animalToOwner[_tokenId] = _to; emit Transfer(msg.sender...
8,513,307
./full_match/100/0x2B71f718182C1577D2F732f57a561B8eeBd6123c/sources/DXSwapFeeReceiver.sol
Done with code from DXswapRouter and DXswapLibrary, removed the deadline argument
function _swapTokens(uint amountIn, address fromToken, address toToken) internal returns (uint256 amountOut) { IDXswapPair pairToUse = IDXswapPair(_pairFor(fromToken, toToken)); (uint reserve0, uint reserve1,) = pairToUse.getReserves(); (uint reserveIn, uint reserveOut) = fromTo...
14,288,482
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) 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 re...
get the value of the strategy shares in the underlying tokens shares Number of shares return amount Underling amount representing the `share` value of the strategy/
function _getSharesToAmount(uint256 shares) internal virtual returns(uint128 amount) { amount = Math.getProportion128( getStrategyBalance(), shares, strategies[self].totalShares ); }
18,198
./full_match/1/0x8C4ABFbFb81eEcC37313EBe8cc4e0a202637F675/sources/contracts/IPWrapper.sol
@inheritdoc NFAiGatewayInterface/
function depositPrizeTokens(uint256 amount) external override onlyOwner { IERC20 token = IERC20(nFAiStakingLottery.getRegisteredToken()); token.safeTransferFrom(msg.sender, address(this), amount); token.safeIncreaseAllowance(address(nFAiStakingLottery), amount); nFAiStakingLott...
2,989,751
./partial_match/42/0xb1ae3AC28a49F8fbbE2C4c5826d5B36327A77497/sources/CeresTestPresaleStage1.sol
claim your purchased tokenssolium-disable-next-line update user and stats send owed tokens
function claim(uint256 _period) public { require(block.number > ends, "presale has not yet ended"); require(block.number > claimBlocks[_period], "claim period is not live yet"); require(investors[msg.sender].periods[_period] == 0, "Tokens already claimed for this period"); uint256 a...
3,303,988
pragma solidity ^0.4.20; // File: contracts/ERC20Token.sol library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b...
OPERATOR ----------------------------------------------------------------
function addMilestonesAndSeal(uint[] _etherAmounts, uint[] _tokenAmounts, uint[] _startTimes, uint[] _durations) public notSealed only(operator) { require(_etherAmounts.length == _tokenAmounts.length); require(_startTimes.length == _durations.length); require(_durations.length == _etherAmounts.length); for ...
10,340,349
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; // Part: OpenZeppelin/openzeppelin-contracts@4.3.2/Address /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is un...
Returns the addresses of token owners (max of TH_THIRD_PRIZE_MAX_WINNERS) internally called by owner of the tokens/
function getAddressesFromTokens(uint256 [] memory _tokens) internal returns (address [] memory) { address [] memory ret = new address[](_tokens.length); for(uint256 i=0;i<_tokens.length;i++) { address _tokenOwner = ownerOf(_tokens[i]); ret[i] = _...
586,495
// SPDX-License-Identifier: MIT pragma solidity 0.6.2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/acces...
Compounds the strategy's earnings and charges fees /
function _harvest(address caller) internal whenNotPaused { if (caller != vault) { require(!Address.isContract(msg.sender), "!auth Contract Harvest"); } IMasterChef(masterchef).deposit(poolId, 0); if (balanceOf() != 0) { chargeFees(caller); addLiqui...
999,544
pragma solidity ^0.4.24; // THE LAST SMART CONTRACT HAD SOME SECURITY HOLES // THIS IS THE SECOND SMART CONTRACT FOR THE LIKE FEATURE // OLD CONTRACT CAN BE SEEN AT https://etherscan.io/address/0x6acd16200a2a046bf207d1b263202ec1a75a7d51 // DATA IS IMPORTED FROM THE LAST CONTRACT // BIG SHOUTOUT TO CASTILLO NETWORK FOR...
update heart count send 50% of the money to the last person
function update(uint256 dapp_id) public payable { require(msg.value >= 2000000000000000); require(dapp_id > 0); totals[dapp_id] = totals[dapp_id].add(msg.value); lastAddress = msg.sender; lastAddress.transfer(msg.value.div(2)); }
13,998,166
/*************************************************************************************************** * * * (c) 2018, 2019 Quantstamp, Inc. This content and its use are governed by the license terms at * * <https://raw.gi...
addr is of type Address which is 20 Bytes, but the TCR expects all entries to be of type Bytes32. addr is first cast to Uint256 so that it becomes 32 bytes long, addr is then shifted 12 bytes (96 bits) to the left so the 20 important bytes are in the correct spot. addr The address of the person who may be an expert. r...
function isExpert(address addr) public view returns(bool) { return registry.isWhitelisted(bytes32(uint256(addr) << 96)); }
5,426,983
./full_match/80001/0x8d05DE3858a4d3Fdca1aC41b80481339a47a1eba/sources/@thirdweb-dev/contracts/extension/upgradeable/AccountPermissions.sol
/// Returns whether the given account is an admin.
View functions function isAdmin(address _account) public view virtual returns (bool) { AccountPermissionsStorage.Data storage data = AccountPermissionsStorage.accountPermissionsStorage(); return data.isAdmin[_account]; }
5,559,736
./partial_match/1/0xD82f93E193526975d4783604dC9490B916Dd0b0C/sources/contracts/p1/mixins/RecollateralizationLib.sol
Prefer selling assets in this order: DISABLED -> SOUND -> IFFY. return If we prefer to sell `status2` over `status1` NOTE: If we change the CollaetralStatus enum then this has to change!
function preferToSell(CollateralStatus status1, CollateralStatus status2) private pure returns (bool) { if (status1 == CollateralStatus.DISABLED) return false; if (status1 == CollateralStatus.SOUND) return status2 == CollateralStatus.DISABLED; return status2 != Co...
16,032,466
/** *Submitted for verification at Etherscan.io on 2020-09-12 */ /** *Submitted for verification at Etherscan.io on 2020-09-05 */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** ...
Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance at return The number of votes the account had as...
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "LOB::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nChe...
8,017,731
./partial_match/1/0x4f19e6A97778417C33AA6034089378b093619fe5/sources/src/MultiPoolStrategyFactory.sol
/ Setters for adapter factory addresses
function setConvexAdapterImplementation(address _newConvexAdapterImplementation) external onlyOwner { convexAdapterImplementation = _newConvexAdapterImplementation; }
4,075,285
./full_match/1/0x3c95775ba56bFcd337998CC84f0388251d6AEC7B/sources/contracts/modules/RangeEditionMinterV2_1.sol
@inheritdoc IRangeEditionMinterV2_1/
function mintInfo(address edition, uint128 mintId) external view returns (MintInfo memory info) { BaseData storage baseData = _getBaseData(edition, mintId); EditionMintData storage mintData = _editionMintData[_baseDataSlot(baseData)]; info.startTime = baseData.startTime; info.endTim...
2,925,082
// SPDX-License-Identifier: MIT pragma solidity >=0.8.6 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./libs/String.sol"; import "./libs/Bytes32.sol"; /** * @dev NFT Regi...
Adds a token to a service. tokenId - The IFPS hash of the asset serviceName - The service name which uses the token/ add service to token relationship. add token to service relationship.
function _useToken(bytes32 tokenId, string calldata serviceName) private { services[serviceName].tokenIds.add(tokenId); uses[tokenId].add(serviceName.toBytes32()); emit TokenUsed(tokenId, serviceName); }
6,358,109
./partial_match/1/0xC74ECe7F996e9315386dD31B7291D55e83c1F98B/sources/OxOPool.sol
Verifies the ring signature/ Step 1 Extract out public key bytes
function verify( bytes memory message, uint256 c0, uint256[2] memory keyImage, uint256[] memory s, uint256[2][] memory publicKeys ) public view returns (bool) { require(publicKeys.length >= 2, "Signature size too small"); require(publicKeys.len...
2,885,085
pragma solidity ^0.4.15; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256...
Thaw an account - Un-freeze a previously frozen account _addr address The address to thaw/
function thawAddress (address _addr) onlyOwner returns (bool) { require(_addr != address(0)); frozen[_addr] = 0; return true; }
10,599,933
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/Reentrancy...
sets maps token to its price _tokenId uint256 token ID (token number) _sale bool token on sale _price unit256 token price Requirements: `tokenId` must exist `price` must be more than 0 `owner` must the msg.owner/
function setTokenSale(uint256 _tokenId, bool _sale, uint256 _price) public { require(_exists(_tokenId), "Sale set of Non Existent Token"); require(_price > 0, "Price for sale needs to bigger than 0 ether"); require(ownerOf(_tokenId) == _msgSender()); _tokenMeta[_tokenId].sale = _sal...
1,840,440
pragma solidity ^0.4.23; /* Controls state and access rights for contract functions * @title Operational Control * @author Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) * Inspired and adapted from contract created by OpenZeppelin * Ref: https://github.com/OpenZeppelin/zeppelin-solidity/ */ contract Operational...
Function sets the starting price / reset price
function setVendingStartPrice (uint256 _collectibleType, uint256 _startingPrice) external onlyManager { vendingPrice[_collectibleType] = _startingPrice; }
14,742,953
./full_match/5/0x877E3Ba57c79eC457702d9cfa7A1C1D45178efc2/sources/contracts/Fundme.sol
Creates a new fundraising campaign with the specified title, funding goal and deadline. _title The title of the fundraising campaign. _amountNeeded The funding goal of the campaign. _deadline The deadline for the campaign in days./ A time conversion factor in solidity Check that the goal and deadline are valid
function createCampaign(string memory _title, uint _amountNeeded, uint _deadline) public{ campaignInfo storage c = Contributions[campaignCount]; uint mydeadline = block.timestamp + (86400 * _deadline); require(mydeadline > block.timestamp, "The deadline should be in the future"); ...
1,882,475
./partial_match/1/0xDe02aB0EC610D5B82073D39C9F92b27478DC076e/sources/packages/contracts/src/DIRTONCHAIN.sol
Set new name for a given token ID tokenId to get new or updated name _name to be used
function ownerSetName(uint256 tokenId, string calldata _name) public onlyOwner { emit Events.NameChanged(tokenId, names[tokenId], _name); names[tokenId] = _name; }
2,740,563
// SPDX-License-Identifier: MIT pragma solidity ^0.8.1; //import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; //https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol interface AggregatorV3Interface { function decimals() ext...
Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `sender` cannot be the zero address. - `recipient` cannot be the zero address. - `sender`...
function _transfer(address sender, address recipient, uint256 amount) internal virtual returns(bool){ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amou...
14,024,802
pragma solidity ^0.4.0; /* * Token - is a smart contract interface * for managing common functionality of * a token. * * ERC.20 Token standard: https://github.com/eth ereum/EIPs/issues/20 */ contract TokenInterface { // total amount of tokens uint totalSupply; /** ...
getVotingStart - the voting starts 1 week after the event starts/
function getVotingStart() constant returns (uint result){ return eventStart+ T_1_WEEK; }
940,520
./full_match/11155111/0x05968f40939fdc016AD58F82Cd08dA884825aD55/sources/project_/contracts/StandardController.sol
Approves a spender [ERC20]. Note that using the approve/transferFrom presents a possible security vulnerability described in: Use transferAndCall to mitigate. caller Address of the caller passed through the frontend. spender The address of the future spender. amount The allowance of the spender./
function approve_withCaller( address caller, address spender, uint amount ) public onlyFrontend returns (bool ok) { return token.approve(caller, spender, amount); }
3,813,275
pragma solidity ^0.5.0; import "./interfaces/IComponentsRegistry.sol"; import "../../common/component/interfaces/IComponent.sol"; import "../../request-verification-layer/permission-module/PermissionModuleMetadata.sol"; import "../../request-verification-layer/permission-module/interfaces/IPermissionModule.sol"; impor...
Remove component from the system componentAddress Address of the component which will be removed/
function removeComponent(address componentAddress) public verifyPermission(msg.sender, msg.sig) { require(componentAddress != address(0), "Invalid address."); bytes4 id = componentsIds[componentAddress]; require(id != bytes4(""), "Component not found."); uint ...
6,415,001
./full_match/1/0xD634626DE5C6237CE3eaa6805B102Bb8CE9a0e9E/sources/contracts/ClayMatic.sol
Used to add new Validators creating a new StakingNode entry. Allows to add same validator multiple times, thus ensures complies with protocol rules. Requirements: - `validators` length should be equal to `points` length. - `validators` cannot be zero address. - `validators` should be valid & cannot be locked. validat...
function addNodes(address[] calldata validators, uint256[] calldata points) external onlyRole(TIMELOCK_ROLE) { require(validators.length == points.length, "CO08"); uint256 newPoints = 0; uint256 newCountNodes = countStakingNodes; StakeManager stakeManager_ = stakeManager; for...
9,774,122
// Sources flattened with hardhat v2.1.2 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.0.0 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implemente...
Returns true if an amulet has been revealed. If this returns false, we cannot be sure the amulet even exists! Don't accept an amulet from someone if it's not revealed and they won't show you the text of the amulet./
function isRevealed(uint256 tokenId) external override view returns(bool) { (address owner, uint64 blockRevealed,) = getData(tokenId); require(owner != address(0), "ERC721: isRevealed query for nonexistent token"); return blockRevealed > 0; }
14,021,812
pragma solidity ^0.8.0; import "../client/node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../client/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../client/node_modules/@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; contract TokenSwap { ...
View functions for the front-end.
function getBalance() public view returns(uint) { return ETHBalance[msg.sender]; }
12,840,154
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol"; /*/contract owned { address public cowne...
emit Transfer(amount);
function withdrawAmount2(uint256 amount) public { require(amount <= getContractBalance()); msg.sender.transfer(amount); }
15,827,458
pragma solidity ^0.4.24; /* ---------------------------------------------------------------------------- Client contract. This contract is generated for each user (user account). All the transactions of a user are executed from this contract. Only Aion smart contract can interact with the user account and only whe...
This function allows the owner of the contract to retrieve the fees and the gas price
function withdraw() public { require(msg.sender==owner); owner.transfer(address(this).balance); }
12,547,898
./full_match/1313161554/0xe3f848dB36FdC40162ce055b2d6e0696566a78ca/sources/contracts/ChToken/ChErc20Delegator.sol
Called by the admin to update the implementation of the delegator implementation_ The address of the new implementation for delegation allowResign Flag to indicate whether to call _resignImplementation on the old implementation becomeImplementationData The encoded bytes data to be passed to _becomeImplementation/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public { require(msg.sender == admin, "ChErc20Delegator::_setImplementation: Caller must be admin"); if (allowResign) { delegateToImplementation(abi.encodeWithSignature("_resign...
13,234,675
./full_match/5/0xe09E9F9F3Ba7Ba465323C9850bf0618EfdCD007d/sources/contracts/Counter.sol
We don't use the checkData in this example. The checkData is defined when the Upkeep was registered.
function checkUpkeep(bytes calldata /* checkData */) external view override returns (bool upkeepNeeded, bytes memory /* performData */) { upkeepNeeded = (block.timestamp - lastTimeStamp) > interval; }
7,064,002
pragma ton-solidity >= 0.6.0; pragma AbiHeader expire; pragma AbiHeader time; pragma AbiHeader pubkey; contract Giver { mapping (uint256 => bool) allowedPubkeys; constructor() public { tvm.accept(); allowedPubkeys.add(msg.pubkey(), true); } function addAllowedPubkey(uint256 pubkey) pu...
require(address(this).balance > amount, 101);
function sendGrams(address dest, uint64 amount) public view pubkeyInAllowed { tvm.accept(); }
971,723
// SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./interfaces/IBancorXUpgrader.sol"; import "./interfaces/IBancorX.sol"; import "../utility/ContractRegistryClient.sol"; import "../utility/TokenHolder.sol"; import "../token/SafeERC...
allows the owner to set/remove reporters Requirements: - the caller must be the owner of the contract/
function setReporter(address reporter, bool active) external ownerOnly { _reporters[reporter] = active; }
12,723,860
./full_match/11155111/0x1A1F1D20C404D9C2399a56166256d25fe3e2A93D/sources/contracts/SubscriptionsCollection.sol
See {IERC165-supportsInterface}. /
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId); }
3,804,132
./full_match/1/0x79f1A89b5E1168d4de4D3Fa62C7FE1852Fa82c58/sources/contracts/Token.sol
Get a breakdown of send and tax amounts amount The amount to tax in wei return send The raw amount to send return taxAmounts The raw tax amounts
function _getTaxAmounts(uint256 amount, bool buying) internal view returns (uint256 send, uint256[2] memory taxAmounts) { if (buying) { taxAmounts = [ (amount * buyTaxes[0]) / BPS_DENOMINATOR, (amount * buyTaxes[1]) / BPS_DENOMINATOR ]; ...
17,001,155
pragma solidity ^0.5.0; contract Delivery { /* Owner of the contract */ address owner; /* Circuit breaker toggle */ bool private stopped = false; /* Name of the farm (used for the verification of the provenance) Note: In a future version, this ought to be replaced by a the public key of an RFID tag ...
Marks the basket as received at the end of the delivery /
function receiveBasket(uint sku) public shipped(sku) verifyCaller(msg.sender) { items[sku].state = State.Received; emit Received(sku); }
994,536
pragma solidity 0.4.24; // produced by the Solididy File Flattener (c) David Appleton 2018 // contact : <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3b7b2a5b693b2b8bcbeb1b2fdb0bcbe">[email&#160;protected]</a> // released under Apache 2.0 licence contract ERC20Basic { function totalSupply(...
------------------------------------------------------------------------ Edit an API listing ------------------------------------------------------------------------ prevent editing an empty api (effectively listing an api) require that sender is the original api lister, or the contract owner the contract owner clause ...
function editApi(uint apiId, uint pricePerCall, address sellerAddress, string docsUrl) public { require(apiId != 0 && pricePerCall != 0 && sellerAddress != address(0)); APIForSale storage api = apis[apiId]; require( api.pricePerCall != 0 && api.sellerUsername != "" && api.apiNa...
2,307,762
./partial_match/1/0x47179dBD96fa51E090E111A04a2086b15b2e4cde/sources/STEST22Token.sol
Allow `_target` make token tranfers
function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; }
15,779,475
./full_match/1/0xb27e1b2c43803fF063184B8ae03791ea36De3B84/sources/src/MembershipManager.sol
Applies the unwrap penalty. Always lose at least a tier, possibly more depending on percentage of deposit withdrawn _tokenId The ID of the membership NFT. _prevAmount The amount of ETH that the NFT was holding _withdrawalAmount The amount of ETH that is being withdrawn point deduction if we kick back to start of pr...
function _applyUnwrapPenalty(uint256 _tokenId, uint256 _prevAmount, uint256 _withdrawalAmount) internal { TokenData storage token = tokenData[_tokenId]; uint8 prevTier = token.tier > 0 ? token.tier - 1 : 0; uint40 curTierPoints = token.baseTierPoints; uint40 degradeTierPenalty = cur...
4,849,171
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ contract SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } f...
Check investor address and tokens.Not allow 0 value Assign tokens to the investor
function assignTokenIJK(address _userAddress,uint256 _tokens) external { require(msg.sender == walletAddresses[8] || msg.sender == walletAddresses[9] || msg.sender == walletAddresses[10]); require(_userAddress != address(0) && _tokens > 0); assignTokensWallet(msg.sender,_userAddress, _tokens...
2,132,460
./full_match/43113/0xBf8D6bf3Bb1E16416CbB9B577dcF4A96073E13B0/sources/_contracts/rain-protocol/contracts/pool/RedeemableERC20Pool.sol
https://balancer.finance/whitepaper/ Spot = ( Br / Wr ) / ( Bt / Wt ) => ( Bt / Wt ) = ( Br / Wr ) / Spot => Wt = ( Spot x Bt ) / ( Br / Wr ) Valuation = Spot Token supply Valuation / Supply = Spot => Wt = ( ( Val / Supply ) x Bt ) / ( Br / Wr ) Bt = Total supply => Wt = ( ( Val / Bt ) x Bt ) / ( Br / Wr ) => Wt = Val...
function valuationWeight(uint256 reserveInit_, uint256 valuation_) private pure returns (uint256) { uint256 weight_ = valuation_ .mul(IBalancerConstants.BONE) .div(reserveInit_); require( weight_ >= IBalancerConstants.MIN_WEIGHT, ...
7,166,388
./partial_match/5/0xA7702cB0922979fd1a9b456f76600c0E914c11A5/sources/contracts/Governance/DAOToken.sol
Delegates votes from signatory to `delegatee` delegatee The address to delegate votes to nonce The contract state required to match the signature expiry The time at which to expire the signature v The recovery byte of the signature r Half of the ECDSA signature pair s Half of the ECDSA signature pair/
function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, ...
16,875,589
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import "./IEIP20.sol"; // Implementation of eip20 standard. // https://eips.ethereum.org/EIPS/eip-20. contract EIP20 is IEIP20 { mapping(address => uint256) private _balanceOf; mapping(address => mapping(address => uint256)) private _allowances; string pri...
Returns the amount which _spender is still allowed to withdraw from _owner.
function allowance(address _owner, address _spender) public view virtual override returns (uint256) { return _allowances[_owner][_spender]; }
6,388,421
./partial_match/1/0xc5Be5F4B9aeEC885D8c9E506901477A950663BC3/sources/contracts/InpulseX.sol
Transfer tokens from one address to another and then execute a callback on recipient. sender The address which you want to send tokens from recipient The address which you want to transfer to amount The amount of tokens to be transferred data Additional data with no specified format return A boolean that indicates ...
function transferFromAndCall( address sender, address recipient, uint256 amount, bytes memory data ) public returns (bool) { transferFrom(sender, recipient, amount); require( _checkAndCallTransfer(sender, recipient, amount, data), "ERC1363:...
9,337,361
pragma solidity 0.4.24; import "zeppelin-solidity/contracts/math/SafeMath.sol"; import "zeppelin-solidity/contracts/ownership/Ownable.sol"; import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import 'zeppelin-solidity/contracts/lifecycle/Destructible.sol'; import "./SwapController.sol"; contract SwapContrac...
get controller token address return address of the original token address/
function getControllerTokenAddress() public view returns (address) { return controllerTokenAddress; }
14,070,648
/* Copyright 2021 Pulsar Trading Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agree...
Withdraw ETH from a PowerPerpetual, by first withdrawing and unwrapping WETH. perpetual Address of the PowerPerpetual contract to withdraw from. account The account on the PowerPerpetual to withdraw from. destination The address to send the withdrawn ETH to. amount The amount of ETH/WETH to withd...
function withdrawEth( address perpetual, address account, address payable destination, uint256 amount ) external nonReentrant { WETH9 weth = _WETH_; address marginToken = I_PowerPerpetual(perpetual).getTokenContract(); require( ...
6,347,663
./full_match/1/0x9c597c4DA5e8F052182fE9B3D12af7E61e8d809B/sources/Users/kaichen/workspace/Tokenlon/tokenlon-contracts/contract-mmproxy/contract-utils/Zerox/LibBytes.sol
Solidity does not require us to clean the trailing bytes. We do it anyway
function readBytes2( bytes memory b, uint256 index ) internal pure returns (bytes2 result) assembly { result := mload(add(b, index)) result := and(result, 0xFFFF000000000000000000000000000000000000000000000000000000000000) } ...
4,834,832
./partial_match/42/0x30E761d94E357ABD4C15878ae795312868F1c32B/sources/Perifi.sol
Note: use public visibility so that it can be invoked in a subclass
function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { addresses = new bytes32[](6); addresses[0] = CONTRACT_PYNTHETIXSTATE; addresses[1] = CONTRACT_SYSTEMSTATUS; addresses[2] = CONTRACT_EXCHANGER; addresses[3] = CONTRACT_ISSUER; addre...
3,299,404
// SPDX-License-Identifier: MIT pragma solidity =0.6.12; pragma experimental ABIEncoderV2; // File: @kobeswap/core/contracts/uniswapv2/libraries/SafeMath.sol // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMathUniswap { function add(uint x, ...
Returns the hash of the input arguments (which make an order)
function hashOfOrder( address maker, address fromToken, address toToken, uint256 amountIn, uint256 amountOutMin, address recipient, uint256 deadline ) public pure returns (bytes32) { return Orders.hash(maker, fromToken, toToken, amountIn, amountOut...
2,558,807
pragma solidity ^0.4.21; import "zeppelin-solidity/contracts/lifecycle/Pausable.sol"; import "zeppelin-solidity/contracts/math/SafeMath.sol"; import "zeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "./ArbiterStaking.sol"; import "./NectarToken.sol"; contract BountyRegistry is Pausable { using Safe...
Function to check if an address is a valid arbiter addr The address to check return true if addr is a valid arbiter else false/
function isArbiter(address addr) public view returns (bool) { return arbiters[addr] && staking.isEligible(addr); }
13,128,707
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import "@...
Withdraw staked tokens and collect reward tokens _amount: amount to withdraw (in rewardToken)/
function withdraw(uint256 _amount) external nonReentrant { require(_amount > 0, "Error: Invalid amount"); UserInfo storage user = userInfo[msg.sender]; require(user.amount >= _amount, "Amount to withdraw too high"); _updatePool(); uint256 pendingToken1 = user .am...
15,872,109
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; contract Empty { // Gas : 67066 } contract Enum { // Gas : 67066 enum Statuses { Pending, Confirmed, Cancelled } } contract DefinedEnum { // Gas : 67066 enum Statuses { ...
Execution cost : 43774
function nextStage() external { status = Statuses(uint256(status) + 1); }
6,390,890
pragma solidity 0.4.24; import "./LibMath.sol"; // Field modulo the NIST-P384 / secp384r1 prime contract FieldP384 { // Field order prime number p uint256 constant phi = 0xffffffffffffffffffffffffffffffff; uint256 constant plo = 0xfffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff; ...
In place inversion: a' = 1 / a (mod p) 83 727 gas Use EIP 198 Big integer modular exponentiation precompile and the Fermat-Euler-Carmichael theorem. We need to raise to the power p - 2. See https:eips.ethereum.org/EIPS/eip-198
function finv( uint256 ahi, uint256 alo) public view returns (uint256 hi, uint256 lo) { (hi, lo) = LibMath.powmod384( ); }
13,141,249
./full_match/1/0x775ee21953f2aDD4006eAA60Bb25F683668de8b6/sources/@openzeppelin/contracts/token/ERC721/ERC721.sol
See {IERC721Metadata-tokenURI}./
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(),".json")) : ""; }
17,058,644
./full_match/1/0x3642189B7754302DF84B6F3FE1aE34D2026647A7/sources/src/ConveyorRouterV1.sol
Function to set referrer mapping.
function initializeReferrer() external payable { if (referrerIndex[msg.sender] != 0) { revert ReferrerAlreadyInitialized(); } uint16 tempReferrerNonce = referrerNonce; referrers[tempReferrerNonce] = msg.sender; referrerIndex[msg.sender] = uint16(tempReferrerNonce)...
3,016,311
./partial_match/5/0xA109b34B1974C1f6BA554607F46E202926728E14/sources/src/CDPVault.sol
Calculates the amount of assets (credit + outstanding debt incl. interest) and liabilities (debt + protocol fee) this vault has update the global rate accumulator liquid credit reserves + total amount of credit we expect to be returned by borrowers amount of credit used, extended to the vault by the CDM + amount of acc...
function _calculateAssetsAndLiabilities(uint256 totalNonFixedCreditWithheld) internal returns ( uint256 assets, uint256 liabilities, uint256 credit, uint256 creditLine ) { (int256 balance, uint256 debtCeiling) = cdm.accounts(address(this)); credit = getCredit(balance); creditLine...
16,850,844
./partial_match/1/0x2b99bEdE91684F28D9e9D04EF7558643e4EdD4D0/sources/@gearbox-protocol/core-v2/contracts/core/ACL.sol
Returns true if the address is unpausable admin and false if not addr Address to check
function isUnpausableAdmin(address addr) external view override returns (bool) { }
15,998,325
./full_match/1/0x7DBF07Ad92Ed4e26D5511b4F285508eBF174135D/sources/contracts/MessengerGateway.sol
Sets the Wormhole Messenger contract address. wormholeMessenger_ The address of the WormholeMessenger contract./
function setWormholeMessenger(WormholeMessenger wormholeMessenger_) external onlyOwner { wormholeMessenger = wormholeMessenger_; }
17,168,725
pragma solidity 0.5.17; import "./MToken.sol"; import "./MomaMasterStorage.sol"; import "./MomaFactoryInterface.sol"; /** * @title Moma's Token Farming Contract * @author moma */ contract FarmingDelegate is MomaMasterV1Storage, MomaMasterErrorReporter, ExponentialNoError { /// @notice Emitted when a new tok...
Claim all the token have been distributed to user user The address to claim token for token The token address to claim/
function claim(address user, address token) internal { uint accrued = farmStates[token].accrued[user]; uint notClaimed = grantTokenInternal(token, user, accrued); farmStates[token].accrued[user] = notClaimed; uint claimed = sub_(accrued, notClaimed); emit TokenClaimed(token, ...
7,271,639
./full_match/80001/0x906025e41867007F8C67efE436ee19012761D5F6/sources/contracts/DatahotpotMarketplace.sol
The buyer pays the royalty fee to the owner of the NFT Regards the marketplace with listingPrice
function createMarketSale(address nftContract, uint256 itemId, uint256 price) public payable nonReentrant { uint256 itemPrice = idToMarketItem[itemId].price; uint256 tokenId = idToMarketItem[itemId].tokenId; require(itemPrice == price, "Please submit the asking price in order to complete the...
5,654,756
pragma solidity ^0.4.21; /** * @title Maths * A library to make working with numbers in Solidity hurt your brain less. */ library Maths { /** * @dev Adds two addends together, returns the sum * @param addendA the first addend * @param addendB the second addend * @return sum the sum of the equation (e....
Returns the greater of two values. a the first value b the second value return result the greater of the two values/
function max( uint256 a, uint256 b ) public pure returns (uint256 result) { result = a >= b ? a : b; return result; }
564,971
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally ava...
See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address./
function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; }
96,490
./full_match/80001/0x8f1Ba75A0DCfF83d45a9e1feeB9f88bD9182d300/sources/contracts/upgradeable/WheelcoinProxyAdmin.sol
solhint-disable-next-line ordering
function transferOwnership(address newOwner) public override onlyRole(ADMIN_ROLE) { require(newOwner != address(0), "Ownable: must have owner"); _transferOwnership(newOwner); }
5,638,791
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, s...
see _createNFT./
function createNFT(address collectorAddress, string memory metadataIPFSHash) external onlyOwner { _createNFT(collectorAddress, metadataIPFSHash); }
15,333,971
./full_match/1/0x968603e045d0a9DC1b3F055C2076B5e201A8541D/sources/src/Index.sol
cannot update weights without using timelock as an anti rug measure
function updateWeights(IndexComponent[] calldata newComponents) external { require(timelock != address(0) && msg.sender == timelock, "!timelock"); uint8 totalWeight; for (uint8 i = 0; i < newComponents.length; ) { totalWeight += newComponents[i].weight; unchecked { i++; } } ...
4,944,791
./partial_match/1/0x29aCCfB6B1b2d0502e4CfCE39833095548297660/sources/LnSimpleStakingNew.sol
To calcuate the old staking in the new period rewards
function _calcOldStakingNewReward(uint256 curBlock, address _user) internal view returns (uint256) { uint256 oldStaking = mOldSimpleStaking.stakingBalanceOf(_user); PoolInfo storage pool = mPoolInfo; UserInfo storage user = userInfo[_user]; uint256 accRewa...
15,533,269