file_name stringlengths 71 779k | comments stringlengths 0 29.4k | code_string stringlengths 20 7.69M | __index_level_0__ int64 2 17.2M |
|---|---|---|---|
./partial_match/1/0x71E368Ed06814Bf35d4E663eFf946400a5BC8115/sources/Degrain.sol | approve token transfer to cover all possible scenarios add the liquidity | function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniswapV2Router), tokenAmount);
address(this),
tokenAmount,
owner(),
block.timestamp
);
}
| 3,693,754 |
pragma solidity ^0.5.0;
import "./ERCStaking.sol";
import "./Checkpointing.sol";
import "./res/Autopetrified.sol";
import "./res/IsContract.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
import "openzeppelin-solidity/contracts/tok... | Get the total amount of tokens staked by all users at block number `_blockNumber` _blockNumber Block number at which we are requesting return The amount of tokens staked at the given block number/ | function totalStakedAt(uint256 _blockNumber) external view returns (uint256) {
return totalStakedHistory.get(_blockNumber);
}
| 1,067,067 |
pragma solidity ^0.4.4;
import "zeppelin/contracts/SafeMath.sol";
import "zeppelin/contracts/ownership/Ownable.sol";
import "./PATToken.sol";
// This ICO contract has been inspired by the EOS one
// https://github.com/EOSIO/eos-token-distribution/blob/master/src/eos_sale.sol
contract ICOSale is Ownable {
using Sa... | Return the amount of tokens available We sell 2% of 42e9 the first two days, it means 1% a day First month: 8% of 42e9, (0.08/42e9)/30 = 112e6 Next 24 months: 1% a month (420e6), 14e6 a day | function tokensByDay(uint day) returns (uint) {
var nbDays = day.sub(startingAt);
if (nbDays < 0 || day > endDate) return 0;
if (nbDays <= 2) return 420e6;
if (nbDays <= 30) return 112e6;
if (nbDays <= 720) return 14e6;
}
| 12,668,759 |
//SPDX-License-Identifier: MIT
pragma solidity 0.8.11;
// Libraries / Interfaces
import "../interfaces/IBEP20.sol";
import "../utils/SafeBEP20.sol";
import "../utils/SafeMath.sol";
import "../helpers/Ownable.sol";
import "../utils/Utils360.sol";
// MLX Helpers
import "./MLXEvents.sol";
import "./MLXData.sol";
import ... | Transfer generated rewards | function safeMLXTransfer(address _to, uint256 _amount) internal {
mlxpos.safeMLXTransfer(_to, _amount);
}
| 2,541,343 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/// @custom:security-contact [email protected]
contract PeaceForUkraine is ERC1155, Ownable {
// Token URIs tokenId => URI
mapping (uint => ... | Withdraw of money from contract/ | function withdraw(address _receiver)
public
onlyOwner
{
uint _balance = address(this).balance;
address payable receiver = payable(_receiver);
receiver.transfer(_balance);
}
| 1,165,887 |
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* This smart contract code is Copyright 2017 TokenMarket L... | Add a presale participating allocation Cannot add new investors after the vault is locked Don't allow reset | function setInvestor(address investor, uint amount) public onlyOwner {
if(lockedAt > 0) {
throw;
}
if(balances[investor] > 0) {
throw;
}
balances[investor] = amount;
investorCount++;
tokensAllocatedTotal += amount;
Allocated(invest... | 4,811,300 |
./full_match/1/0xE292B17018189aDAc3321E95494520F35859b9df/sources/contracts/pool/DittoPoolMain.sol | @inheritdoc OwnerTwoStep | function acceptOwnership() public override (IOwnerTwoStep, OwnerTwoStep) nonReentrant onlyPendingOwner {
if(_isPrivatePool) {
revert DittoPoolMainInvalidOwnerOperation();
}
super.acceptOwnership();
_lpNft.emitMetadataUpdateForAll();
}
| 16,496,951 |
pragma solidity >0.5.0;
/** @title Classic QuickSort. See https://blog.cotten.io/thinking-in-solidity-6670c06390a9 */
contract QuickSort {
function sort(uint[] memory data) public pure returns(uint[] memory) {
quickSort(data, int(0), int(data.length - 1));
return data;
}
/** @dev Classic quicksort s... | Classic quicksort sorting algorithm. arr array to be sorted left left-most index of array items needing. Array items to the left of left are already sorted. right right-most index of array of items needing sorting. Array items to the right of right are already sorted./ | function quickSort(uint[] memory arr, int left, int right) internal pure {
int i = left;
int j = right;
if (i==j) return;
uint pivot = arr[uint(left + (right - left) / 2)];
while (i <= j) {
while (arr[uint(i)] < pivot) i++;
while (pivot < arr[uint(j)]) j--;
if (i <= j) {
... | 12,585,914 |
//SPDX-License-Identifier: Unlicense
pragma solidity 0.8.1;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./interfaces/... | if amount is zero return earlyif the current round does not exist create itif the round is already partially baked create a new round only push rounds we are actually in if full amount assigned to rounds break the loop | function _depositTo(uint256 _amount, address _to) internal {
if(_amount == 0) {
return;
}
uint256 currentRound = rounds.length - 1;
uint256 deposited = 0;
while(deposited < _amount) {
if(currentRound >= rounds.length) {
rounds.push();
}
if(rounds[currentRound].t... | 988,159 |
// SPDX-License-Identifier: MIT
// solhint-disable
/*
This is copied from OZ preset: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/release-v3.0.0/contracts/presets/ERC721PresetMinterPauserAutoId.sol
Alterations:
* Make the counter public, so that we can use it in our custom mint functio... | Enables the transfer of GFI rewards (referred to as a "grant"), if the grant details exist in this contract's Merkle root. | interface IMerkleDirectDistributor {
function gfi() external view returns (address);
function merkleRoot() external view returns (bytes32);
function isGrantAccepted(uint256 index) external view returns (bool);
function acceptGrant(
uint256 index,
uint256 amount,
bytes32[] calldata merkleProof
)... | 6,235,182 |
./full_match/80001/0x2aC04fc70D237f181BE0b33A53bB6Bb23CDa76E6/sources/project_/contracts/MysticGalacticMission1.sol | Mints new NFTs from the reserved supply for the caller. Can only be called by the reserve minter account and when the contract is not paused. bottles The number of NFTs to be minted from the reserved supply./ | function mintNFTReserved(uint256 bottles) public onlyReserveMinter whenNotPaused {
sm.mintFromReservedSupply(msg.sender, bottles);
}
| 9,432,021 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.6.4 <0.8.0;
pragma experimental ABIEncoderV2;
///
/// @dev EIP-1153 License Transaction Encoder Library
/// @author Tyler R. Drury <vigilstudios.td@gmail.com> (www.twitter.com/StudiosVigil) - copyright 29/8/2021, All Rights Reserved
///
library abiEncoderEIP1... | does client have authority to issue/revoke licenses | function hasAuthority(
address client
)internal pure returns(
bytes memory
){
return abi.encodeWithSignature(
STUB_HAS_AUTHORITY,
client
);
}
| 974,476 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.9; // code below expects that integer overflows will revert
import "./Vendor/openzeppelin-contracts-3dadd40034961d5ca75fa209a4188b01d7129501/token/ERC721/IERC721.sol";
import "./Vendor/openzeppelin-contracts-3dadd40034961d5ca75fa209a4188b01d7129501/access/Own... | The owner can set the fee portion newFeePortion the transaction fee (in basis points) as a portion of the sale price | function setFeePortion(uint256 newFeePortion) external onlyOwner {
require(newFeePortion <= 1000, "Exceeded maximum fee portion of 10%");
feePortion = newFeePortion;
}
| 5,460,796 |
./full_match/1/0x7e1e077b289c0153b5ceAD9F264d66215341c9Ab/sources/contracts/plugins/assets/compoundv3/WrappedERC20.sol | See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`./ | function transfer(address to, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
| 3,138,300 |
./full_match/5/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45/sources/contracts/V3SwapRouter.sol | @inheritdoc IV3SwapRouter | function exactOutput(ExactOutputParams calldata params) external payable override returns (uint256 amountIn) {
exactOutputInternal(
params.amountOut,
params.recipient,
0,
);
amountIn = amountInCached;
require(amountIn <= params.amountInMaximum, 'T... | 1,926,418 |
pragma solidity ^0.4.23;
//import "./Receiver_Interface.sol";
contract ContractReceiver {
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) public pure {
TKN memory tkn;
... | Function to access total supply of tokens . | function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
| 6,513,054 |
./full_match/4/0x5EAee32F7C74b3868ECb286112D72D549981317a/sources/contracts/OrangeadNFT.sol | return an URI for a given _tokenId _tokenId The ID of the desired NFT/ | function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(_tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealTime == 0) {
return unreveale... | 12,351,286 |
pragma solidity 0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
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;
}
functi... | function through which owner can remove an address from whitelisting/ | function addAddressToWhitelist(address _whitelist) public onlyOwner
{
isAddressWhiteListed[_whitelist]= true;
}
| 2,261,336 |
./full_match/4337/0xd71E61dde321dCDe58886479A47f1142bBF0C6d6/sources/contracts/paymaster/OpenfortPaymasterV2.sol | The new owner accepts the ownership transfer. If the new owner had some native tokens deposited to the Paymaster, they will now be part of the owner's deposit./ | function acceptOwnership() public override {
totalDepositorBalances -= depositorBalances[pendingOwner()];
depositorBalances[pendingOwner()] = 0;
super.acceptOwnership();
}
| 13,221,862 |
/// @title Marketplace: A marketplace for listing and buying products
/// @author John McCrae
/// @notice This contract inherits EmergencyStop, a contract that implements the circuit breaker design pattern
/// @dev This contract requires solidity compiler version 0.5 or higher.
pragma solidity ^0.5.0;
/// @dev This c... | withdrawStoreFunds() A function to withdraw store funds. Restricted to store owner (contract owner) return _amountWithdrawn | function withdrawStoreFunds()
public
verifyOwnerMarketplace
returns(uint _amountWithdrawn)
{
uint amountWithdrawn = address(this).balance;
emit LogStoreFundsWithdrawn(amountWithdrawn);
ownerMarketplace.transfer(amountWithdrawn);
return (amountWithdrawn);
... | 12,957,481 |
pragma solidity ^0.4.23;
/**
* @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens
*/
contract ERC721 {
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
event Approval(
address indexed owner,
address indexed approved,
uint256 in... | Check claimant address as token owner. _claimant The address we are validating against _tokenId Token id, only valid when > 0/ | function _owns(
address _claimant,
uint256 _tokenId
)
internal
view
returns (bool)
{
return tokenIndexToOwner[_tokenId] == _claimant;
}
| 5,995,115 |
./full_match/3/0x4388C22BE6667CCE325d0ab6C7869db25d12a6AA/sources/browser/Election.sol | require that they haven't voted before require a valid candidate record that voter has voted update candidate vote Count trigger voted event | function vote (uint _candidateId) public {
require(!voters[msg.sender]);
require(_candidateId > 0 && _candidateId <= candidatesCount);
voters[msg.sender] = true;
candidates[_candidateId].voteCount ++;
emit votedEvent(_candidateId);
}
| 8,110,917 |
pragma solidity ^0.4.4;
contract Meetup {
/**
* NOTES
*
* "organizer" is the person creating meetup.
*/
/**
* Meetup Events
*/
event _MeetupCreated(uint indexed id);
event _MeetupUpdated(uint indexed id);
struct MeetupPost {
uint id;
address organizer;
... | Create a new meetup post/ | function createMeetup(
string ipfsHash
) external {
address organizer = msg.sender;
seqId = seqId + 1;
meetups[seqId] = MeetupPost(seqId, organizer, ipfsHash);
_MeetupCreated(seqId);
}
| 1,759,461 |
./partial_match/1/0x020082A7a9c2510e1921116001152DEE4da81985/sources/src/v0.8/ccip/PriceRegistry.sol | Add and remove tokens from feeTokens set. feeTokensToAdd The addresses of the tokens which are now considered fee tokens and can be used to calculate fees. feeTokensToRemove The addresses of the tokens which are no longer considered feeTokens. | function _applyFeeTokensUpdates(address[] memory feeTokensToAdd, address[] memory feeTokensToRemove) private {
for (uint256 i = 0; i < feeTokensToAdd.length; ++i) {
if (s_feeTokens.add(feeTokensToAdd[i])) {
emit FeeTokenAdded(feeTokensToAdd[i]);
}
}
for (uint256 i = 0; i < feeTokensToR... | 3,968,935 |
./partial_match/3/0x2C02cD8a2645D97977E7ffE74Ed21a943ba465E0/sources/option.sol | get expiry date from round r/ | function getRoundExpiryDate(uint r) external override view returns(uint) {
return rounds[r].expiryDate;
}
| 5,241,104 |
pragma solidity ^0.4.11;
import "./Owned.sol";
contract CurrencyHedge is Owned {
struct Hedge {
address beneficiary;
uint hedgeStart; // Seconds in Unix Epoch (since Jan 1, 1970)
uint hedgeEnd; // Seconds in Unix Epoch
bytes3 homeCurr; // Denoted with three letters (e.g. ... | activateHedge: Activate a hedge and allow transactions to be recorded to it This should be verified outside of the contract. 'now' is an alias for block.timestamp, not current time | function activateHedge(address _beneficiary, uint256 _index) public onlyOwner {
allHedges[_index].active = true;
}
| 15,780,871 |
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// tested components for smartcontracts
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@... | Addresses allowed to mint early | function mintWhitelist() public payable {
require(_openWhitelistMint == true, "Rural&City: minting is closed");
require(whitelist[msg.sender] == true, "Rural&City: user must be whitelisted to mint");
require(msg.value == _price, "Rural&City: must send correct price");
require(_tokenIdTracker.current()... | 14,067,666 |
pragma solidity ^0.4.19;
import './Ownable.sol';
import './ERC884ForUser.sol';
contract IshuUser is ERC884ForUser, Ownable {
bytes32 constant private ZERO_BYTES = bytes32(0);
address constant private ZERO_ADDRESS = address(0);
mapping(address => bytes32) private verified;
modifier isVerifiedAddress... | Update the hash for a verified address known to the contract. addr The verified address of the person represented by the supplied hash. hash A new cryptographic hash of the address holder's updated verified information./ | function updateVerified(address addr, bytes32 hash)
public onlyOwner isVerifiedAddress(addr) {
require(hash != ZERO_BYTES);
bytes32 oldHash = verified[addr];
if (oldHash != hash) {
verified[addr] = hash;
}
emit VerifiedAddressUpdated(addr, oldHash, hash, msg.... | 6,439,408 |
./partial_match/4/0x9e4Da12D3cC45896fd1E548E2cAbE69d44EecA5D/sources/animalMain.sol | TO DO使用亂數來產生DNA, 星級, 動物種類動手玩創意,可以限制每次建立動物需要花費多少ETH | function createAnimal() public payable {
bytes32 dna;
uint star;
uint roletype;
dna = random();
uint ram = uint(random())%100;
if ( ram < 40 ) star = 1;
else if ( ram < 65 ) star = 2;
else if ( ram < 85 ) star = 3;
else if ( ram < 95 ) star = 4;
... | 8,727,437 |
/**
*Submitted for verification at Etherscan.io on 2021-04-27
*/
/**
*Submitted for verification at Etherscan.io on 2021-04-13
*/
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
// SPDX-License-Identifier: MIT
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an ... | Receive state sync from matic contracts This method will be called by Matic chain internally. This is executed without transaction using a system call./ | function onStateReceive(uint256, bytes memory message) public onlyStateSyncer{
_processMessageFromRoot(message);
}
| 520,506 |
./full_match/41/0xB59b7c521223bfB1a9b428ae1117733Cc027Af29/sources/contracts/Smart_Contract.sol | Add Payment Add Limiting of Supply | function publicMint() public payable{
require(publicMintOpen, "Public Mint Closed");
require(msg.value == 0.01 ether, "Not Enough Funds");
require(totalSupply() < maxSupply, "Sold Out!");
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeM... | 16,380,038 |
./full_match/137/0xD12345Cd15352ef5d4259BD2a918Fcb6943ce7a4/sources/contracts/core/connext/helpers/StableSwap.sol | Return A, the amplification coefficient n (n - 1) See the StableSwap paper for details return A parameter/ | function getA() external view override returns (uint256) {
return swapStorage.getA();
}
| 4,729,521 |
./full_match/43114/0x46655CE994041664163489B278CF0eE576322118/sources/project_/contracts/MasterChef.sol | Update reward variables of the given pool to be up-to-date. Dev does not take any emission Accounts for Total Supply together with rewards | function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.timestamp <= pool.lastRewardTime) {
return;
}
if (pool.lpSupply == 0 || pool.allocPoint == 0) {
pool.lastRewardTime = block.timestamp;
return;
}
... | 4,559,559 |
./full_match/97/0xFa65FeB730Bc85214eB4e7C07e4810ca8381A5aE/sources/project_/contracts/LakeToken.sol | 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, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "LAKE::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return ... | 3,284,442 |
pragma solidity ^0.4.24;
import "@aragon/os/contracts/apps/AragonApp.sol";
import "@aragon/os/contracts/lib/math/SafeMath.sol";
import "./interfaces/IVICoinAdjustable.sol";
import "@nomiclabs/buidler/console.sol";
contract VCommunityApp is AragonApp {
using SafeMath for uint256;
/// Events
event SetVICoi... | Unapprove account `_account` so that it no logner receives basic income/ | function unapproveAccount(address _account)
external
auth(UNAPPROVEACCOUNT)
{
viCoin.unapproveAccount(_account);
emit UnapproveAccount(_account);
}
| 12,656,060 |
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
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 ... | Get pending address abstract. Needs child implementation return pending address Sign current transaction and add it to transaction pending queue return code | function getPendingManager() public view returns (address);
function _multisig(bytes32 _args, uint _block) internal returns (uint _code) {
bytes32 _txHash = _getKey(_args, _block);
address _manager = getPendingManager();
_code = PendingManager(_manager).hasConfirmedRecord(_txHash);
... | 259,246 |
pragma solidity ^0.4.11;
interface CommonWallet {
function receive() external payable;
}
library StringUtils {
function concat(string _a, string _b)
internal
pure
returns (string)
{
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
... | Number of tokens minted for bounty campaign | function totalBountyCount()
public view returns(uint256)
{
return bountyCount_;
}
| 5,397,228 |
./partial_match/1/0xB5E2C8fa04Ae426167490a0437c4F20556c9B07C/sources/AggKeyNonceConsumer.sol | Update KeyManager reference. Used if KeyManager contract is updated sigData Struct containing the signature data over the message to verify, signed by the aggregate key. keyManager New KeyManager's address omitChecks Allow the omission of the extra checks in a special case/ Check that the new Ke... | function updateKeyManager(
SigData calldata sigData,
IKeyManager keyManager,
bool omitChecks
)
external
override
nzAddr(address(keyManager))
consumesKeyNonce(sigData, keccak256(abi.encode(this.updateKeyManager.selector, keyManager, omitChecks)))
{
... | 2,813,187 |
./partial_match/1/0xa202D5B0892f2981bA86C981884cebA49B8AE096/sources/DigitalaxGenesisStaking.sol | Unstake without caring about rewards. EMERGENCY ONLY. | function emergencyUnstake(uint256 _tokenId) external {
require(
tokenOwner[_tokenId] == msg.sender,
"DigitalaxGenesisStaking._unstake: Sender must have staked tokenID"
);
_unstake(msg.sender, _tokenId);
emit EmergencyUnstake(msg.sender, _tokenId);
}
| 2,671,400 |
./partial_match/1/0xDB0655752A3CD23B8fD360aF596E71EE924c5253/sources/contracts/v2-migration/V2ToV3Rollover.sol | Callback function for flash loan. The caller of this function must be the lending pool. assets The ERC20 address that was borrowed in Flash Loan. amounts The amount that was borrowed in Flash Loan. feeAmounts The fees that are due to the lending pool. params ... | function receiveFlashLoan(
IERC20[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata feeAmounts,
bytes calldata params
) external nonReentrant {
if (msg.sender != address(VAULT)) revert R_UnknownCaller(msg.sender, address(VAULT));
OperationData mem... | 4,068,944 |
./partial_match/421613/0xF5f25AC08eA0FA565Be14fBe1136f2B38b073ABA/sources/contracts/libraries/LibDiamond.sol | add new facet address if it does not exist | function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {
require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
DiamondStorage storage ds = diamondStorage();
require(_facetAddress != address(0), "LibDiamondCut: Add facet ... | 16,826,025 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ILootComponents.sol";
contract LootStats {
struct Item {
uint256 hp;
uint256 armor;
uint256 attack;
uint256 agility;
uint256 dexterity;
}
address public lootComponentsAddress;
constructor(addres... | Item memory neckStats = _getTotalStat( neckComponents, Item(0, 0, 0, 0, 0) ); Item memory ringStats = _getTotalStat( ringComponents, Item(0, 0, 0, 0, 0) ); | function getAccessoryStats(uint256 tokenId)
public
view
returns (Item memory)
{
ILootComponents components = ILootComponents(lootComponentsAddress);
uint256[5] memory neckComponents = components.neckComponents(tokenId);
uint256[5] memory ringComponents = componen... | 12,882,696 |
// File: @openzeppelin\contracts\token\ERC20\IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
functio... | Converts inputCurrency to Dai on Uniswap and buys IdeaTokens inputCurrency The input currency ideaToken The IdeaToken to buy amount The amount of IdeaTokens to buy fallbackAmount The amount of IdeaTokens to buy if the original amount cannot be bought cost The maximum cost in input currency lockDuration The durati... | function convertAndBuy(address inputCurrency,
address ideaToken,
uint amount,
uint fallbackAmount,
uint cost,
uint lockDuration,
address recipient) extern... | 410,147 |
pragma solidity ^0.4.23;
/**xxp
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
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;
}
fun... | Calculates the amount that has already vested./uint256 currentBalance = balanceOf(_beneficiary); | function vestedAmount(address _beneficiary) public view returns (uint256) {
tokenToVest storage value = vestToMap[_beneficiary];
uint256 totalBalance = value.torelease;
if (block.timestamp < value.cliff) {
return 0;
return totalBalance;
return totalBalance.mul(block.timestamp.sub(value... | 10,987,965 |
./partial_match/1/0x09a516356F393442BA03AC1eEBE12479c2b5819e/sources/contracts/BallsLife/BallIsLife.sol | Changed visibility of burn to external as per good practices | function burn(uint256 amount) external {
require(amount != 0);
require(amount <= balances[msg.sender]);
_totalSupply = SafeMath.sub(_totalSupply, amount);
balances[msg.sender] = SafeMath.sub(balances[msg.sender], amount);
emit Transfer(msg.sender, address(0), amount);
}
| 3,615,220 |
pragma solidity 0.5.16;
import "../../base/snx-base/interfaces/SNXRewardInterface.sol";
import "../../base/snx-base/SNXRewardStrategy.sol";
contract FloatStrategyMainnet_WBTC is SNXRewardStrategy {
address public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public wbtc = address(0x2260FAC5... | Withdraws all the asset to the vault/ | function withdrawAllToVault() public restricted {
if (address(rewardPool) != address(0)) {
if (rewardPool.balanceOf(address(this)) > 0) {
rewardPool.exit();
}
}
_liquidateReward();
if (IERC20(underlying).balanceOf(address(this)) > 0) {
IERC20(underlying).safeTransfer(vault, I... | 11,869,753 |
pragma solidity 0.5.6;
// Copyright BigchainDB GmbH and Ocean Protocol contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0
import './Condition.sol';
/**
* @title Hash Lock Condition
* @author Ocean Protocol Team
*
* @dev Implementation of the Hash Lock ... | fulfill the condition by calling check the the hash and the pre-image bytes32 value _agreementId SEA agreement identifier return condition state/ | function fulfill(
bytes32 _agreementId,
bytes32 _preimage
)
external
returns (ConditionStoreLibrary.ConditionState)
{
return _fulfill(generateId(_agreementId, hashValues(_preimage)));
}
| 12,648,548 |
/**
*Submitted for verification at Etherscan.io on 2021-08-20
*/
// Sources flattened with hardhat v2.4.3 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/[email protected]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in th... | Disable changes for baseURI/ | function disableBaseURIChanges() external onlyOwner {
require(canChangeBaseURI, "The owner can't change the baseURI anymore");
canChangeBaseURI = false;
}
| 2,425,312 |
pragma solidity ^0.4.18;
/**
* @author Emil Dudnyk
*/
contract ETHPriceWatcher {
address public ethPriceProvider;
modifier onlyEthPriceProvider() {
require(msg.sender == ethPriceProvider);
_;
}
function receiveEthPrice(uint ethUsdPrice) external;
function setEthPriceProvider(address provider) ... | if crowdsale is unsuccessful, investors can claim refunds here/ | function refund() public whenNotPaused {
require(state == SaleState.REFUND);
require(registry.getContributionETH(msg.sender) > 0);
require(!hasRefunded[msg.sender]);
uint ethContributed = registry.getContributionETH(msg.sender);
if (!msg.sender.send(ethContributed)) {
ErrorSendingETH(msg.se... | 10,112,648 |
// Copyright © 2021 Treum.io, a ConsenSys AG company. All rights reserved.
// BY USING THIS SMART CONTRACT, INCLUDING TO BUY, SELL, CREATE, BURN OR USE TOKENS, YOU AGREE TO EULERBEATS’ TERMS OF SERVICE, AVAILABLE HERE: HTTPS://EULERBEATS.COM/TERMS-OF-SERVICE AND IN THE TRANSACTION DATA OF 0x56ff8befa16e6720f9cf54146c9c... | See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length./ | function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory ... | 20,104 |
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.7.6;
pragma abicoder v2;
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {OwnableUp... | Lock ERC20 tokens in the vault access control: called by delegate with signed permission from owner state machine: anytime state scope: - insert or update _locks - increase _nonce token transfer: none token Address of token being locked amount Amount of tokens being locked permission Permission signature payload get... | function lock(
address token,
uint256 amount,
bytes calldata permission
)
external
override
onlyValidSignature(getPermissionHash(LOCK_TYPEHASH, msg.sender, token, amount, _nonce), permission)
{
bytes32 lockID = calculateLockID(msg.sender, token);
... | 6,862,012 |
./partial_match/1/0x7d1bA2c18CbDE0D790Cc1d626F0c70b3c13C9eec/sources/src/Curve.sol | approves a user to spend curve tokens on their behalf _spender the account to allow to spend from msg.sender _amount the amount to specify the spender can spend return success_ the success bool of this call | function approve(address _spender, uint256 _amount)
public
nonReentrant
noDelegateCall
returns (bool success_)
{
success_ = Curves.approve(curve, _spender, _amount);
}
| 4,158,774 |
./full_match/1/0x6C0ABAfC02A031c6240462F8707C0913A930091E/sources/Bios.sol | mint new Bios tokens to provided address Requirements: - private sale should be active - sender should have private sale minting slots - sender should pay BIOS price for each token numberOfTokens is an amount of tokens to mint/ | function mintPrivate(uint8 numberOfTokens) public payable {
require(_privateSale, "Private sale is not active!");
require(numberOfTokens > 0, "Number of tokens must be more than 0!");
require(totalSupply() + numberOfTokens <= maxTotalSupply, "Total supply limit have reached!");
require(numbe... | 16,605,470 |
/**
*Submitted for verification at Etherscan.io on 2021-05-17
*/
// File: contracts/interface/ICoFiXV2VaultForTrader.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.6.12;
interface ICoFiXV2VaultForTrader {
event RouterAllowed(address router);
event RouterDisallowed(address router);
... | msg.value = amountIn + oracle fee | {
require(msg.value > amountIn, "CRouter: insufficient msg.value");
address pair = pairFor(factory, token);
assert(IWETH(WETH).transfer(pair, amountIn));
uint oracleFeeChange;
uint256[5] memory tradeInfo;
IWETH(WETH).deposit{value: amountIn}();
function addLiquid... | 6,573,594 |
./partial_match/1/0x21114F10332585C5223963FFa384E112C88459EB/sources/@gearbox-protocol/integrations-v2/contracts/adapters/curve/CurveV1_3.sol | Sends an order to remove liquidity from a Curve pool in exact token amounts amounts Amounts of coins to withdraw `max_burn_amount` is ignored since the calldata is routed directly to the target Internal implementation details in CurveV1Base | function remove_liquidity_imbalance(
uint256[N_COINS] calldata amounts,
uint256
) external virtual override nonReentrant {
_remove_liquidity_imbalance(
amounts[0] > 1,
amounts[1] > 1,
amounts[2] > 1,
false
}
| 4,213,725 |
pragma solidity ^0.4.22;
import "./IDaoBase.sol";
import "./DaoBase.sol";
import "./ImpersonationCaller.sol";
import "./utils/UtilsLib.sol";
/**
* @title DaoBaseImpersonated
* @dev This contract is a helper that will call the action is not allowed directly (by the current user) on behalf of the other user.
* It ... | _hash hash of the message which account sign _sig signature of the account which have rights for action needed _newMc new DaoBase instance (address) this function allow any account upgrade DAO contract on behalf by account which have needed rights by signing specified message/ | function upgradeDaoContractImp(bytes32 _hash, bytes _sig, address _newMc) public {
bytes32[] memory params = new bytes32[](1);
params[0] = bytes32(_newMc);
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(daoBase).UPGRADE_DAO_CONTRACT(),
"upgradeDaoContractGeneric(bytes32[])",
params
);
}
| 12,672,342 |
// SPDX-License-Identifier: MIT
pragma solidity 0.6.6;
import "./lib/@defiat-crypto/interfaces/IDeFiatPoints.sol";
import "./interfaces/IAnyStake.sol";
import "./interfaces/IAnyStakeMigrator.sol";
import "./interfaces/IAnyStakeVault.sol";
import "./utils/AnyStakeUtils.sol";
contract AnyStake is IAnyStake, AnyStakeUt... | Governance - Set Pool Charge Fee | function setPoolVipAmount(uint256 _pid, uint256 _vipAmount) external onlyGovernor {
require(poolInfo[_pid].vipAmount != _vipAmount, "SetVipAmount: No amount change");
poolInfo[_pid].vipAmount = _vipAmount;
emit PoolVipAmountUpdated(msg.sender, _pid, _vipAmount);
}
| 13,947,632 |
/*
* This file was generated by MyWish Platform (https://mywish.io/)
* The complete code could be found at https://github.com/MyWishPlatform/
* Copyright (C) 2018 MyWish
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as publis... | override hasEnded to add minimal value logic return true if remained to achieve less than minimal/ | function hasEnded() public view returns (bool) {
bool remainValue = cap.sub(weiRaised) < 100000000000000000;
return super.hasEnded() || remainValue;
}
| 1,681,173 |
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity ^0.6.12;
import "./Interfaces/LiquidityMathModelInterface.sol";
import "./MToken.sol";
import "./Utils/ErrorReporter.sol";
import "./Utils/ExponentialNoError.sol";
import "./Utils/AssetHelpers.sol";
import "./Moartroller.sol";
import "./... | Transfers collateral tokens (this market) to the liquidator. Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another MToken. Its absolutely critical to use msg.sender as the seizer mToken and not a parameter. seizerToken The contract seizing the collateral (i.e. borrowed mT... | function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) {
uint allowed = moartroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);
if (allowed != 0) {
return failOpaque(Error.MOARTROLLER_RE... | 11,818,093 |
./full_match/1/0xFb8F626AD693ad0AF769ddB265084E8973f63a3C/sources/contracts/BlockHistory.sol | Parses a merkle inclusion proof from the bytes proof the encoded merkle inclusion proof return result the array of proof hashes/ solidity doesn't support getting calldata outputs from abi.decode but we can decode it; calldata arrays are just (offset,length) | function parseMerkleProof(bytes calldata proof)
internal
pure
returns (bytes32[] calldata result)
{
require(proof.length % 32 == 0);
require(proof.length >= 32);
assembly {
result.offset := add(proof.offset, 0x20)
result.length := calldata... | 4,930,395 |
./full_match/4/0xc70D7E1432449a14A7A7aC88B43ddDFdE7B305E6/sources/browser/MolVault_v2.sol | Deposit NFT Set sale status | function deposit(
address _tokenAddress,
uint256 _tokenId,
uint256 _ethPrice,
uint256 _tokenPrice,
uint8 _forSale)
public onlyWhitelisted {
require(IERC721(_tokenAddress).ownerOf(_tokenId) == msg.sender, "!owner");
bytes memory tokenKey = getTokenKey(_to... | 701,603 |
./partial_match/1/0x323a60675142021Adc78B147C72D479de923f4a5/sources/JWCToken.sol | Get token exchange rate Note: just use when ICO/ | function getTokenExchangeRate() public constant returns(uint256 rate) {
rate = tokenExchangeRate;
if(now<phasePresale_To){
if(now>=phasePresale_From)
rate = 10000;
rate = 7000;
}
} else if(now<phasePublicSale3_To){
}
| 2,581,004 |
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c =... | Gets the balance of the specified address. _owner The address to query the the balance of. return A uint256 representing the amount owned by the passed address./ | function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner].add(calculateReward(_owner));
}
| 13,740,169 |
./partial_match/4/0x4a6948a622C2B4DB9aee84B35c3bEC8F64442956/sources/MyDefiProject.sol | Solidity can't return string arrays. So we'll have to provide the _dataIndex Of the piece of data we want | function getUserData(uint256 _id, uint256 _dataIndex) public view returns (string memory) {
return users[_id].data[_dataIndex];
}
| 8,508,630 |
./full_match/43114/0xff164Ede3E7C375E8764E9e3a22D3E35F780EEBC/sources/home/pedro/Documents/projects/avalabs/party-swap/party-swap-periphery/contracts/PartyRouter.sol | refund dust eth, if any | function swapAVAXForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable virtual override ensure(deadline) returns (uint256[] memory amounts) {
require(path[0] == WAVAX, 'PartyRouter: INVALID_PATH');
amounts = Pa... | 4,528,070 |
./full_match/1/0x4D654112663ea69d6f836f67EEB4BEd3793e5605/sources/browser/FrenchWineToken.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
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())... | 9,744,205 |
/**
*Submitted for verification at Etherscan.io on 2021-03-22
*/
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <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() ... | Add a new lp to the pool. Can only be called by the owner. | function add(uint256 _allocPoint, IERC20 _lpToken, address _moneyToken, bool _withUpdate, uint256 _buybackRatio, uint256 _type) public {
require(msg.sender == owner() || msg.sender == devaddr, "!dev addr");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock =... | 6,515,646 |
// Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/blob/v3.0.0/contracts/Initializable.sol
// Added public isInitialized() view of private initialized bool.
// SPDX-License-Identifier: MIT
pragma solidity 0.6.10;
/**
* @title Initializable
*
* @dev Helper contract to support ini... | Liquidate the loan if it has defaulted/ | function liquidate() external override onlyDefaulted onlyLiquidator {
status = Status.Liquidated;
emit Liquidated(status);
}
| 1,718,006 |
pragma solidity >= 0.5.0 < 0.7.0;
// pragma experimental ABIEncoderV2; // To support struct as return value
// WifiAllocation.sol: Performs bandwidth allocation according to the proportional rule
// Based on the previous version, and added support for requesting both (1) bandwidth and (2) burst data volume
contract Wi... | Perform bandwidth allocation depending on the demand and supply | function performAllocation() public {
if(totalDesiredBandwidth <= totalBandwidth) {
demandNotExceedSupply();
demandExceedSupply();
}
}
| 6,478,407 |
/**
*Submitted for verification at Etherscan.io on 2021-11-10
*/
/* SPDX-License-Identifier: GPL-3.0
████████╗██╗░░██╗███████╗░░██████╗░░█████╗░███╗░░██╗░██████╗░░█████╗░███████╗███╗░░██╗░██████╗
╚══██╔══╝██║░░██║██╔════╝░░██╔══██╗██╔══██╗████╗░██║██╔════╝░██╔══██╗██╔════╝████╗░██║██╔════╝
░░░██║░░░███████║█████╗░░░... | Overrides the tokenURI method tokenId ID of the token return string preRevealURI if not revealed else baseURI/ | function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(!revealed) {
return preRevealURI;
... | 2,412,646 |
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
// SPDX-License-Identifier: MIT OR Apache-2.0
import "./ReentrancyGuard.sol";
import "./SafeMath.sol";
import "./SafeMathUInt128.sol";
import "./SafeCast.sol";
import "./Utils.sol";
import "./Storage.sol";
import "./Config.sol";
import "./Events.sol";
im... | Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see {ERC20Detailed}./ | interface IERC20 {
function symbol() external pure returns (string memory);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowan... | 72,361 |
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;
import "../interfaces/IStrategy.sol";
import "../interfaces/IVault.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin... | harvest() function that takes care of logging. Subcontracts should override _harvestCore() and implement their specific logic in it./ | function harvest() external override whenNotPaused {
_harvestCore();
if (block.timestamp >= harvestLog[harvestLog.length - 1].timestamp + harvestLogCadence) {
harvestLog.push(
);
}
lastHarvestTimestamp = block.timestamp;
emit StratHarvest(msg.sender)... | 6,344,748 |
./partial_match/4/0xF559B56a101f3120CB811E571a8c1fA77F640015/sources/LexLocker.sol | get total resolutions passed by LXL `resolver`s | function resolutionCount() external view returns (uint256) { | 8,601,420 |
./full_match/1/0x51aD7fE22a4a7Cef856F655cd2FF8E1D492fB8b0/sources/src/contracts/onft/OmniseaUniversalONFT721.sol | not enough gas to complete transfers, store to be cleared in another tx | function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64, /*_nonce*/
bytes memory _payload
) internal virtual override {
(bytes memory toAddressBytes, uint[] memory tokenIds, BasicCollectionParams memory _collectionParams, bytes32 _collectionId... | 17,045,295 |
./full_match/5/0x295193366E9dA65fB198A3c88AE01BF64E284AAc/sources/contracts/CrowdFunding.sol | is everything okay? | function createCampaign(address _owner, string memory _title, string memory _description,
uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Campaign storage campaign = campaigns[numberOfCampaigns];
require(campaign.deadline < block.timestamp, "The dea... | 1,958,089 |
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
library EnumerableCardNFT {
struct CardEntry {
bytes32 _tokenId;
uint256 _star;
// 剩余粉尘
uint256 _tokenVal;
uint256[] _cardType;
// 词条
uint256[] _cardEntrys;
string _uri;
add... | Returns true if the key is in the map. O(1)./ | function _contains(CardMap storage map, bytes32 key)
private
view
returns (bool)
{
return map._indexes[key] != 0;
}
| 907,733 |
./full_match/44787/0xc7f5366f1255e50FFA5F6cDC9959adEF5E312715/sources/contracts/CarbonPathToken.sol | See {ERC20-_beforeTokenTransfer}. Requirements: - the contract must not be paused./ | function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), 'CarbonPathToken: token transfer while paused');
}
| 13,291,661 |
./full_match/2222/0xB5fa77E3929fe198a86Aa40fd6c77886785bCd0e/sources/contracts/libraries/Allowance.sol | Sets the allowed amount and expiry of the spender's permissions on owner's token. Nonce does not need to be incremented. If the inputted expiration is 0, the allowance only lasts the duration of the block. | function updateAmountAndExpiration(
IAllowanceTransfer.PackedAllowance storage allowed,
uint160 amount,
uint48 expiration
) internal {
allowed.expiration = expiration == 0 ? uint48(block.timestamp) : expiration;
allowed.amount = amount;
}
| 7,102,796 |
pragma solidity ^0.4.24;
//-----------------------------------------------------------------------------
/// @title TOY Ownership
/// @notice defines TOY Token ownership-tracking structures and view functions.
//-----------------------------------------------------------------------------
contract ToyOwnership {... | ------------------------------------------------------------------------- Withdraw Ether from approved TOY Token to TOY Token's owner Throws if Ether to withdraw is zero. Throws if sender is not an approved operator for TOY Token `_fromUid`. Throws if TOY Token `_fromUid` has insufficient balance to withdraw. _fro... | function withdrawEther(
uint _fromUid,
uint _amount
) external canOperate(_fromUid) notZero(_amount) {
require (
externalTokenBalances[address(this)][_fromUid] >= _amount,
"Insufficient Ether to withdraw"
);
externalTokenBalances[address(this)][_f... | 935,254 |
./full_match/43114/0x21a5e0Fc127C246030Fe12fd8bad711a06601A9b/sources/contracts/Hayden2V3Staker.sol | @inheritdoc IUniswapV3Staker | function withdrawToken(
uint256 tokenId,
address to,
bytes memory data
) external override {
require(to != address(this), 'Hayden2V3Staker::withdrawToken: cannot withdraw to staker');
Deposit memory deposit = deposits[tokenId];
require(deposit.numberOfStakes == 0,... | 4,602,583 |
pragma solidity ^0.4.24;
// File: openzeppelin-solidity/contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns... | Add a new payee to the contract. _payee The address of the payee to add. _cheques The number of _cheques owned by the payee./ | function addPayee(address _payee, uint _cheques) onlyAdmin canMint public {
require(_payee != address(0));
require(_cheques > 0);
require(balances[_payee] == 0);
MintableToken(this).mint(_payee, _cheques);
}
| 1,224,430 |
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.6.11;
pragma experimental ABIEncoderV2;
// ============ Internal Imports ============
import {Home} from "../Home.sol";
import {Version0} from "../Version0.sol";
import {XAppConnectionManager, TypeCasts} from "../XAppConnectionManager.sol";
import {IMes... | Handle message setting the router address for a given domain _msg The message/ | function _handleSetRouter(bytes29 _msg)
internal
typeAssert(_msg, GovernanceMessage.Types.SetRouter)
{
uint32 _domain = _msg.domain();
bytes32 _router = _msg.router();
_setRouter(_domain, _router);
}
| 9,926,142 |
./full_match/5/0xFF66BF2e58234FD609a7C2D783237999D1fAA785/sources/project_/contracts/ExchangeDeposit.sol | Internal function for getting the sendTo address for gathering ERC20/ETH. If the contract is dead, they will be forwarded to the adminAddress. return address payable for sending ERC20/ETH/ Use exDepositor to perform logic for finding send address If ExchangeDeposit is killed, use adminAddress, else use coldAddress | function getSendAddress() internal view returns (address payable) {
ExchangeDeposit exDepositor = getExchangeDepositor();
address payable coldAddr = exDepositor.coldAddress();
address payable toAddr =
coldAddr == address(0) ? exDepositor.adminAddress() : coldAddr;
return ... | 1,849,891 |
./full_match/137/0xDF092237F7D15B88B3C03f4836536E2B242018a8/sources/Contract_Deploy/Mainnet/boltr-audit-paladin/BoltrSwap.sol | Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {KRC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have a... | function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(subtractedValue, "KRC20: decreased allowance below zero")
);
return true;
}
| 4,709,670 |
./full_match/56/0x5DD9707a433ffC4bf37BFD1AA81677f50Af13dc4/sources/contracts/BSCGlyphs.sol | // Bids Refund the failing bid | function enterBidForGlyph(uint glyphIndex) payable {
require(glyphIndex<=TOKEN_LIMIT, "Invalid glyph id/index");
require(glyphIndex<=numTokens, "Glyph has not been minted yet");
require(idToOwner[glyphIndex] != msg.sender, "Cannot bid on your own glyph");
require(msg.value>0, "Send B... | 3,236,691 |
./full_match/4/0xDD3B44C4e8D167D5577AaD8BaE0c1c83f0D97428/sources/CurrencyConverter.sol | find data feed address for your mainnet/testnet at https:docs.chain.link/docs/ethereum-addresses/ | function getVersion() public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(
0x8A753747A1Fa494EC906cE90E9f37563A8AF630e
);
return priceFeed.version();
}
| 653,483 |
pragma solidity 0.4.26;
/**
* @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, which is the standard behavior in high l... | Buyer confirms receipt from seller; Ether 'price' is transferred to seller./ | function confirmReceipt() public onlyBuyer inState(State.Confirmed) {
state = State.Completed;
seller.transfer(address(this).balance);
emit Completed(address(this), seller);
}
| 5,342,828 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import {Math} from '../utils/math/Math.sol';
import {Pausable} from './Pausable.sol';
import {IARTH} from '../Arth/IARTH.sol';
import {IERC20} from '../ERC20/IERC20.sol';
import {SafeMath} from '../utils/math/SafeMath.sol';
impo... | If this were not internal, and sourceAddress had an infinite approve, this could be exploitable (pull funds from sourceAddress and stake for an arbitrary stakerAddress) Pull the tokens from the sourceAddress Staking token supply and boosted supply Staking token balance and boosted balance | function _stakeLocked(
address stakerAddress,
address sourceAddress,
uint256 amount,
uint256 secs
) internal nonReentrant updateReward(stakerAddress) {
require(
(paused == false && migrationsOn == false) ||
validMigrators[msg.sender] == true,
... | 2,546,599 |
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
* error, which is the standard behavior in high l... | Change the _lowerTransferLimit which is the minimum threshold any single swap can be newLimit new limit in FET 1018 Owner only/ | function setLowerTransferLimit(uint256 newLimit)
external
onlyOwner()
belowEqualValue(newLimit, _upperTransferLimit)
{
_lowerTransferLimit = newLimit;
emit ChangeLowerTransferLimit(newLimit);
}
| 12,799,887 |
pragma solidity ^0.4.13;
library Math {
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal pure returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal pure returns (uint256) {
... | internal functions -------------------------------------------------------- | function _rateFromDay(uint256 day) internal pure returns(uint256) {
if (day < 1) {
return 0;
}
uint256 rate = _safeSub(START_RATE, (day.sub(1)).mul(ADJ_RATE));
return END_RATE > rate ? END_RATE : rate;
}
| 11,725,315 |
./full_match/1/0xcccd6EC6F4705292f07eE4a9a8F1F120963358c5/sources/contracts/bridgeToken/adapters/ccip/CCIPBridgeAdapter.sol | Executable by Chainlink router, Bridge funds in and mint/give BIFI to the user message Bridge message/ | function ccipReceive(
IRouterClient.Any2EVMMessage memory message
) external onlyBridge {
if (!whitelistedChains[message.sourceChainSelector]) revert InvalidChain();
if (abi.decode(message.sender, (address)) != address(this)) revert WrongSourceAddress();
(address _user, uint256 _a... | 4,982,837 |
./full_match/288/0xD05b8fD53614e1569cAC01c6D8d41416d0a7257E/sources/contracts/DAO/governance/GovernorBravoDelegate.sol | Initiate the GovernorBravo contract Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count/ | function _initiate() external {
require(msg.sender == admin, "GovernorBravo::_initiate: admin only");
require(initialProposalId == 0, "GovernorBravo::_initiate: can only initiate once");
proposalCount = 0;
initialProposalId = 1;
timelock.acceptAdmin();
}
| 7,103,792 |
//! Casper Interface /* && Casper Interface contract */.
//! By Gabriele Rigo (RigoBlock, Rigo Investment Sagl), 2017.
//! Released under the Apache Licence 2.
pragma solidity ^0.4.15;
//this is the Casper Interface
interface Casper {
//EVENTS
//NON-CONSTANT METHODS
function initiate(uint... | EVENTSNON-CONSTANT METHODSCONSTANT METHODSfunction balance_of(address validator) constant returns (uint) {} would be nice to have balances by address in addition of balances by validator_index | interface Casper {
function initiate(uint _epoch_length, uint _withdrawal_delay, address _owner, address _sighasher, address _purity_checker, uint8 _base_interest_factor, uint8 _base_penalty_factor);
function initiate_epoch(uint epoch);
function logout(bytes logout_msg);
function proc_re... | 896,686 |
pragma solidity ^0.4.0;
contract fsmp {
struct SellOrder{
uint id; //Sell Order Id (auto increment)
address DSO; //Data Storage Owner address of the contract
uint volumeGB; //Volume of disk space, which DSO is ready to sell.
uint pricePerGB; // Min price in wei DSO ready to get for... | check if user can cancel an order | function cancelSellOrder(uint sellOrderIndex, uint sellOrderID){
if(sellOrderArr[sellOrderIndex].DSO == msg.sender && sellOrderArr[sellOrderIndex].id == sellOrderID){
deleteSellOrderFromArray(sellOrderIndex);
return;
throw;
}
}
| 6,380,631 |
./full_match/4/0xCbd380E055A76940fa46bD3Ec85524EF09dE647D/sources/lexlocker.sol | Registers an account to serve as a potential `resolver`. active Tracks willingness to serve - if 'true', can be joined to a locker. fee The divisor to determine resolution fee - e.g., if '20', fee is 5% of locker. | function registerResolver(bool active, uint8 fee) external cooldown nonReentrant {
require(fee != 0, "FEE_MUST_BE_GREATER_THAN_ZERO");
resolvers[msg.sender] = Resolver(active, fee);
lastActionTimestamp[msg.sender] = block.timestamp;
emit RegisterResolver(msg.sender, active, fee);
... | 721,004 |
pragma solidity ^0.5.0;
import "./AbstractWrapper.sol";
contract DigitalArtCollectibleERC1155Wrapper is AbstractWrapper {
function initialize() internal {
create(1, 1, "ipfs://QmWAP5TQokmAXWw7mYFapCdDa9piYZE2kVJiqP53NqoQD2");
create(4, 50, "ipfs://Qmf3UT9mmzPZwgf3cSQDEa7ZBji8ntZskrLDBEN1gVscpp");... | / mint 0 just to let explorers know it exists emit TransferSingle(msg.sender, address(0), msg.sender, _id, 0); | function create(uint256 _id, uint256 _totalSupply, string memory _uri) internal {
require(tokenSupply[_id] == 0, "id already exists");
tokenSupply[_id] = _totalSupply;
metadatas[_id] = _uri;
emit URI(_uri, _id);
}
| 7,031,661 |
pragma solidity ^0.5.12;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol";
contract minterests is Ownable, ReentrancyGuard {
using SafeMath for uint256;
/**
* @dev Re... | This functions is called after the investor expressed its desire to redeem its bonds using the above function (claimBonds). It needs to be called __before__ the third party pays the investor its bonds in fiat. claimedAmount The balance of the investor on the redeemed partition./ This function is only for mid... | function payBonds (address investor, uint256 claimedAmount) external nonReentrant {
investors[investor].claimingBonds.claiming = false;
bytes32 partition = investors[investor].claimingBonds.partitionNameInHex;
require ((partition[0] == "m" && partition[1] == "i" && partition[2] == "d")
|| (... | 5,449,914 |
pragma solidity ^0.4.13;
interface IAffiliateList {
/**
* @dev Sets the given address as an affiliate.
* If the address is not currently an affiliate, startTimestamp is required
* and endTimestamp is optional.
* If the address is already registered as an affiliate, both values ar... | Walks through the list of TokenLots for the given address, attempting to find `amount` tokens that can be transferred. It uses the given `lockoutTime` if the supplied value is not zero. If `removeTokens` is true the tokens are actually removed from the address, otherwise this function acts as a dry run. ... | function walkTokenLots(address from, address to, uint amount, uint lockoutTime, bool removeTokens,
bool newTokensAreRestricted, bool preservePurchaseDate)
internal returns (uint numTransferrableTokens)
{
TokenLot[] storage fromTokenLots = tokenLotsOf[from];
for(uint i=0; i<fromTo... | 10,472,433 |
./full_match/42/0xCB75bC96a0005568F256ffa7D337753C32bF2D9d/sources/hw.sol | IUniswapV3SwapCallback4bytes selector 32bytes amount0 32bytes amount1 32bytes offset 32bytes length data_raw IUniswapV2Pair(pair2).swap(0,uint(amount1Delta),msg.sender,new bytes(0)); IUniswapV2Pair(pair2).swap(uint(amount0Delta),0,msg.sender,new bytes(0)); IUniswapV2Pair(pair2).swap(0,uint(amount1Delta)+amount2,address... | function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata _data
) external override {
if( tx.origin != owner)
{
revert("");
}
assembly {
let calldata32bytes := calldata... | 16,254,093 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/... | Calculate the reward for a give stake if withdrawn at 'targetTime' / | function computeReward(
uint256 applicableReward,
uint256 targetTime,
uint256 stakaAmount,
uint256 rewardStartDate,
bool existingStake
) private view returns (uint256) {
uint256 mulltiplier = stakaAmount
.mul(applicableReward)
.mul(targetTi... | 13,461,776 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.