file_name stringlengths 71 779k | comments stringlengths 0 29.4k | code_string stringlengths 20 7.69M | __index_level_0__ int64 2 17.2M |
|---|---|---|---|
pragma solidity ^0.5.2;
interface Token {
function transfer(address to, uint256 value) external returns (bool);
function balanceOf(address who) external view returns (uint256);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function allowance(address owner, addr... | Values must be in the minimal unit (in wei in case of 18 decimals). Set the allowance to the contract be able to do the transfer / | function sendAmountAllowance(address[] memory _users, uint256[] memory _values) public returns(bool){
require(_users.length == _values.length, "Lenght of users and values must be equal");
require(msg.sender != address(0));
uint256 total_balance = 0;
for(uint i=0; i< _values.length; i++){
total_... | 12,611,323 |
// File: @openzeppelin/upgrades/contracts/Initializable.sol
pragma solidity >=0.4.24 <0.6.0;
/**
* @title Initializable
*
* @dev Helper contract to support initializer functions. To use it, replace
* the constructor with a function that has the `initializer` modifier.
* WARNING: Unlike constructors, initializer... | Internal function to process withdrawals. | function processWithdrawals() internal {
uint256 numberOfWithdrawals = Math.min(withdrawals.length, maxWithdrawalsPerTx);
uint256 startingIndex = withdrawals.length;
uint256 endingIndex = withdrawals.length.sub(numberOfWithdrawals);
for (uint256 i = startingIndex; i > endingIndex; i... | 6,063,618 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.6;
/**
* @dev Foo dev
* @notice Foo userdoc
*/
contract Foo {
/**
* @dev Foo.bar devdoc
* @notice Foo.bar userdoc
*/
function bar() external view returns (uint256) {
return 0;
}
/**
* @dev Foo.foo devdoc
* @notice Foo.foo userdoc
*/
... | Foo.foo devdoc Foo.foo userdoc/ | function foo() external view returns (uint256) {
return 0;
}
| 1,838,571 |
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
/**
* @title EternalStorage
* @dev An ownable contract that can be used as a storage where the variables
* are stored in a set of mappings indexed by hash names.
*/
contract EternalStorage {
struct Storage {
mapp... | Allows the owner to set a value for a boolean variable h The keccak256 hash of the variable name v The value to be stored/ | function _setUint(bytes32 h, uint256 v) internal {
s._uint[h] = v;
}
| 6,382,847 |
//Address: 0x84119cb33e8f590d75c2d6ea4e6b0741a7494eda
//Contract name: GigaWattToken
//Balance: 0 Ether
//Verification Date: 8/10/2017
//Transacion Count: 13493
// CODE STARTS HERE
/*
* Giga Watt Token Smart Contract. Copyright © 2016 by ABDK Consulting.
* Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>... | Maximum allowed tokens in circulation (2^64 - 1)./ Address of the owner of the contract./ Whether transfers are currently frozen./ Instantiate the contract and make the message sender to be the owner./ | function StandardToken () {
owner = msg.sender;
}
| 5,503,199 |
pragma solidity >=0.4.21 <0.6.0;
import "../interfaces/IPToken.sol";
import "./BaseRecipe.sol";
contract BuyPTokenRecipe is BaseRecipe {
constructor(address _token, address _underlying) BaseRecipe(_token, _underlying) public {
}
function tokensReceived(
address _operator,
address _from,
... | TODO consider getting max price from some oracle | function tokensReceived(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes calldata _userData,
bytes calldata _operatorData
) external {
_tokensReceived(_to);
token.redeem(address(this), token.balanceOf(address(this)));
... | 15,863,774 |
./partial_match/5/0x7aAC0f092F7b961145900839Ed6d54b1980F200c/sources/PostageStamp.sol | Create a new batch. At least `_initialBalancePerChunk2^depth` number of tokens need to be preapproved for this contract. _owner The owner of the new batch. _initialBalancePerChunk The initial balance per chunk of the batch. _depth The initial depth of the new batch. _batchId The batchId being copied (from previous... | function copyBatch(
address _owner,
uint256 _initialBalancePerChunk,
uint8 _depth,
uint8 _bucketDepth,
bytes32 _batchId,
bool _immutable
) external whenNotPaused {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "only administrator can use copy method");
... | 16,885,240 |
pragma solidity 0.4.24;
import "openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "openzeppelin-solidity/contracts/crowdsale/validation/WhitelistedCrowdsale.sol";
import "./SolidToken.sol";
import "./Distributable.sol";
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
con... | Finalizes the bonussale and sets up the break and public sales/ | function finalizePresale() atStage(Stages.BONUSSALE) internal{
bonussale_EndDate = now;
mainSale_StartDate = now;
mainSale_EndDate = mainSale_StartDate + MAINSALE_MAX_DURATION;
mainSale_TokenCap = mainSale_TokenCap.add(bonussale_TokenCap.sub(bonussale_TokesSold));
mainSale_Cap = mainSale_Cap.add(b... | 2,541,224 |
./full_match/80001/0xe5904022b45A537722d689894ba02D541c991C0D/sources/contracts/FractionCalculator.sol | Convert decimal string to integer Multiply fraction by variable | function calculateFraction(string memory decimalStr, uint256 variable) public pure returns (uint256) {
(uint256 numerator, uint256 denominator) = parseDecimal(decimalStr);
uint256 result = numerator * variable / denominator;
return result;
}
| 9,474,076 |
/**
*Submitted for verification at Etherscan.io on 2018-10-26
*/
pragma solidity ^0.4.24;
// File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function totalSupply() external view returns (uint25... | return the number of decimals of the token./ | function decimals() public view returns(uint8) {
return _decimals;
}
| 192,419 |
./full_match/1/0x873847b829a33C87c1fb227367D7b28a7DF979b4/sources/contracts/radiant/staking/ChefIncentivesController.sol | Ending reward distribution time./ | function endRewardTime() public returns (uint256) {
uint256 unclaimedRewards = availableRewards();
uint256 extra = 0;
uint256 length = poolLength();
for (uint256 i; i < length; ) {
PoolInfo storage pool = poolInfo[registeredTokens[i]];
if (pool.lastRewardTime > lastAllPoolUpdate) {
extra +=
((p... | 3,223,484 |
./partial_match/1/0x6b3ede185cA3079800390534313a130Ac4975D1e/sources/MarsRulerRegistry.sol | // Usage Functions // Validate Ownership Validate Augments Consume $MES Set Gear Config Emit GearChange Event | function setGear(uint256 tokenId_, GearConfig memory gearConfig_) external {
require(msg.sender == Martians.ownerOf(tokenId_),
"You are not the owner!");
require(10 == CS.characters(tokenId_).augments_,
"Your Martian is not a Ruler yet!");
bool _... | 4,103,112 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
import "./KindlyMarketplaceInterface.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/ER... | on removal of staked kindly in the marketplace the owner of the nft will lose the extra stakedKindly emit StatsChanged(_holder, mappingAddressDeeds[_holder].id); TODO: on stake the kindly on hold changes. Need to update the holders kindly balance | function removeStakedkindly(address _holder, uint256 balance) public {
require(_holder != address(0), "Address should not be 0x");
mappingAddressDeeds[_holder].stakedKindly = mappingAddressDeeds[_holder].stakedKindly.sub(balance);
}
| 7,216,183 |
./full_match/1/0x2741d68d12b9Ba83c0f8779193EE88b2fA359705/sources/BOUNTY.sol | exclude from paying fees or having max transaction amount | constructor() ERC20("bounty.tech", "BOUNTY") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair =... | 9,785,984 |
//SPDX-License-Identifier: MIT
pragma solidity 0.8.11;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import './lib/ERC721X.sol';
contract ShinobiBunny is ERC721X, Ownable {
using ECDSA fo... | Transfers `tokenId` from `from` to `to`. As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements: - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. Emits a {Transfer} event./ Clear approvals from the previous owner | function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721X.ownerOf(tokenId) == from, 'ERC721: transfer of token that is not own');
require(to != address(0), 'ERC721: transfer to the zero address');
_beforeTokenTransfer(from... | 13,992,847 |
/**
*Submitted for verification at Etherscan.io on 2020-02-25
*/
pragma solidity ^0.5.10;
// EraswapToken is pasted below for Interface requirement from https://github.com/KMPARDS/EraSwapSmartContracts/blob/master/Eraswap/contracts/EraswapToken/EraswapToken.sol
pragma solidity ^0.5.9;
contract ERC20Basic {
funct... | this is an internal functionality that is only for bet contracts to emit a event when a new bet is placed so that front end can get the information by subscribing to contract | function emitNewBettingEvent(address _bettorAddress, uint8 _choice, uint256 _betTokensInExaEs) public onlyBetContract {
emit NewBetting(msg.sender, _bettorAddress, _choice, _betTokensInExaEs);
}
| 13,072,601 |
./full_match/7700/0x9B2a63F27661A468E2da22226b64A4914144f195/sources/contracts/mixins/AgentMask.sol | Approves an external router or agent to act on a user's behalf. router The address of the external agent. nCalls The number of calls the external router is authorized to make. Set to uint32.max for unlimited. callPath The specific proxy sidecar callpath that the router is approved for / | function approveAgent (address router, uint32 nCalls, uint16 callPath) internal {
bytes32 key = agentKey(lockHolder_, router, callPath);
UserBalance storage bal = userBals_[key];
bal.agentCallsLeft_ = nCalls;
}
| 4,651,160 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import... | See {IERC721-setApprovalForAll}./ | function setApprovalForAll(
address operator
, bool approved
)
public
virtual
override
{
_setApprovalForAll(
_msgSender()
, operator
, approved
);
}
| 1,049,347 |
pragma solidity ^0.5.7;
/**
* Math operations with safety checks
*/
library SafeMath {
function mul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal pure returns (uint) {
// assert(b > 0)... | update token address/ | function updateTokenAddress(address payable _tokenAddress, uint _tokenIndex) public
onlyEscrow
{
require(_tokenAddress != address(0));
TokenAddress[_tokenIndex] = _tokenAddress;
}
| 6,365,886 |
./full_match/1/0xf83c53c080E48e78A6B114eAB682d528562d33B5/sources/contracts/v2/OperatorFilterer/FairxyzOperatorFiltererUpgradeable.sol | See {IFairxyzOperatorFiltererUpgradeable-toggleOperatorFilterDisabled}./ | function toggleOperatorFilterDisabled()
external
virtual
override
onlyOperatorFilterAdmin
{
bool disabled = !operatorFilterDisabled;
operatorFilterDisabled = disabled;
emit OperatorFilterDisabled(disabled);
}
| 3,850,765 |
pragma solidity ^0.5.2;
import "../openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "../openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../openzeppelin-solidity/contracts/token/ERC721/ERC721Holder.sol";
import "../openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import ".... | / Shift entire array :( | function _removeTokenFromBarn(uint tokenId, address barnAddress) internal {
uint256[] storage barnArray = userBarn[barnAddress];
require(barnArray.length > 0,"No tokens to remove");
int index = _indexOf(tokenId, barnArray);
require(index >= 0, "Token not found in barn");
@d... | 2,521,517 |
./full_match/1/0x657859E9d8fC27E2a9c72660db3938f83f368Ce0/sources/contracts/ELEMENTALPUNKS23.sol | Verify whitelist requirements | function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof)
public
payable
mintCompliance(_mintAmount)
mintPriceCompliance(_mintAmount)
{
require(whitelistMintEnabled, "The whitelist sale is not enabled!");
require(totalSupply() + _mintAmount <= w... | 9,781,630 |
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
/*
██████╗ ███████╗ █████╗ ██╗ ██╗████████╗██╗ ██╗ ██████╗ █████╗ ██████╗ ██████╗ ███████╗
██╔══██╗██╔════╝██╔══██╗██║ ██║╚══██╔══╝╚██╗ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝
██████╔╝█████╗ ███████║██║ ██║ ██║ ╚████╔╝ ██║ ██████... | pays out winnings, or returns funds | function withdraw() external override {
_checkState(States.WITHDRAW);
require(!userAlreadyWithdrawn[msgSender()], "Already withdrawn");
userAlreadyWithdrawn[msgSender()] = true;
if (card[winningOutcome].totalTimeHeld > 0) {
_payoutWinnings();
_returnRent();
... | 12,778,634 |
/**
*Submitted for verification at Etherscan.io on 2022-01-19
*/
//SPDX-License-Identifier: lgplv3 OR MIT
// File: @openzeppelin/contracts/proxy/Proxy.sol
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all ca... | Web3 call functions/ Returns number of confirmations of a transaction. transactionId Transaction ID. return count Number of confirmations. | function getConfirmationCount(uint transactionId)
public
view
returns (uint count)
{
for (uint i = 0; i < owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
| 2,278,059 |
//Address: 0x92736b3bff1bbd72a72478d78f18a6ab9b68b791
//Contract name: SatisfactionToken
//Balance: 0 Ether
//Verification Date: 5/15/2018
//Transacion Count: 2
// CODE STARTS HERE
pragma solidity ^0.4.23;
library Math {
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b... | _owner The address that's balance is being requested return The balance of `_owner` at the current block/ | function balanceOf(address _owner) public view returns (uint256) {
return balanceOfAt(_owner, block.number);
}
| 1,027,655 |
pragma solidity ^0.4.0;
import {ScryptFramework} from "./scryptFramework.sol";
contract ScryptRunner is ScryptFramework {
function initMemory(State memory state) pure internal {
state.fullMemory = new uint[](4 * 1024);
}
function run(bytes input, uint upToStep) pure public returns (uint[4] vars... | The proof for reading memory consists of a list of proof from leaf to root plus the four values read from memory. | function readMemory(State memory state, uint index, Proofs memory proofs) pure internal returns (uint a, uint b, uint c, uint d) {
require(index < 1024);
uint pos = 0x20 * 4 * index;
uint[] memory fullMem = state.fullMemory;
assembly {
pos := add(pos, 0x20)
a ... | 12,703,872 |
/**
* Lucky Block Network Project Smart-Contracts
* @authors https://grox.solutions
*/
pragma solidity 0.5.7;
library SafeMath {
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(u... | Vote to pause any transfer of tokens. Called by a owner to unpause, triggers normal state./ | function unpause() public onlyOwner {
if (_vote(unpauseProp, "unpause", address(0), address(0), 0, "")) {
super.unpause();
}
}
| 922,399 |
./full_match/80001/0x8794b656d34B4895a16823fF0943d4942d9FBC59/sources/contracts/NFTAttack2.sol | Internal function to perform a defense defender The defender's address attacker The attacker's address/ Only a grumpy cat owner can defend Find the highest-level cat owned by the defender | function _defend(address defender, address attacker) internal {
require(balanceOf[defender][1] > 0, "You need a Grumpy cat to defend!");
uint256 highestLevelCat;
for (uint256 i = 2; i >= 0; i--) {
if (balanceOf[defender][i] > 0) {
highestLevelCat = i;
... | 851,148 |
// SPDX-License-Identifier: MIT
pragma solidity =0.8.4;
import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {
SafeERC20
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {
ReentrancyGuardU... | Remove addresses from depositors list excludeDepositor is the address to exclude from the depositors list/ | function _removeDepositor(address excludeDepositor) internal {
address[] storage array = depositorsArray;
uint256 arrayLength = array.length;
require(depositorsMap[excludeDepositor], "Depositor does not exist");
depositorsMap[excludeDepositor] = false;
for (uint256 i = 0; ... | 6,258,000 |
pragma solidity ^0.4.25;
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract FlightSuretyData {
using SafeMath for uint256;
/********************************************************************************************/
/* DATA VA... | Transfers eligible payout funds to insuree/ | function pay(
address airline,
string flight,
uint256 ts,
address passenger,
uint256 payout
) external requireIsOperational requireIsAuthorized {
bytes32 flightkey = getKeyOfFlight(airline, flight, ts);
payoutOfInsurance[flightkey][passenger] = payout;
... | 1,783,614 |
./full_match/137/0x9D5b588E5DaAC8055886D055418425c96faF9F56/sources/Special_Pool_V2.sol | reward = (pendingReward.div(90 days).mul(time)); | function calculateRewards(address _stakerAddress) public view returns(uint256 reward) {
UserData storage _userData = userData[_stakerAddress];
_userData.user == _stakerAddress;
uint256 time = block.timestamp.sub(_userData.intialTimestamp);
if (block.timestamp <= _userData.intial... | 4,773,755 |
// File: contracts/VeloxTransferHelper.sol
// SPDX-FileCopyrightText: © 2020 Velox <code@velox.global>
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.0;
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library VeloxTransferHelper {
funct... | bytes4(keccak256(bytes('approve(address,uint256)'))); | function safeApprove(address token, address to, uint value) internal {
require(token != address(0), 'VeloxTransferHelper: ZERO_ADDRESS');
require(to != address(0), 'VeloxTransferHelper: TO_ZERO_ADDRESS');
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, ... | 10,282,638 |
./full_match/5/0x0a643414b7392BA34a6D464d0704178eB1A2868d/sources/project_/contracts/Payant.sol | Allows the deposits of funds into the contract for a specified invoice. Get the invoice Update the status | function deposit(uint256 _invoiceId) public payable returns (Invoice memory) {
require(_invoiceId >= 0, "Invalid invoice id.");
require(_invoiceId < nextInvoiceId, "Invalid invoice id.");
Invoice storage _invoice = invoices[_invoiceId];
require(_invoice.amount + DEPOSIT_FEES <= msg.v... | 1,893,577 |
./full_match/1/0xFb8F626AD693ad0AF769ddB265084E8973f63a3C/sources/contracts/lib/FactSigs.sol | Produce the fact signature data for an account's code hash blockNum the block number to look at codeHash the codeHash for the account/ | function accountCodeHashFactSigData(uint256 blockNum, bytes32 codeHash)
internal
pure
returns (bytes memory)
{
return abi.encode("AccountCodeHash", blockNum, codeHash);
}
| 4,930,627 |
./full_match/1/0x6e0d0C6a2445F21157dF96B2b6119BF757C42a5F/sources/contracts/MyContract.sol | Parses a revert reason that should contain the numeric quote | function parseRevertReason(bytes memory reason) private pure returns (uint256) {
if (reason.length != 32) {
if (reason.length < 68) revert('Unexpected error');
assembly {
reason := add(reason, 0x04)
}
revert(abi.decode(reason, (string)));
... | 8,369,733 |
// SPDX-License-Identifier: MIT
// Developer: @Brougkr
pragma solidity 0.8.10;
import '@openzeppelin/contracts/interfaces/IERC721Receiver.sol';
import '@openzeppelin/contracts/interfaces/IERC721.sol';
import '@openzeppelin/contracts/interfaces/IERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@... | Mints Galactican From ArtBlocks Minting Contract | function _mintGalactican() private returns (uint tokenID) { return IArtBlocks(_ArtBlocksMintingContractAddress).purchase(_ArtBlocksProjectID); }
| 567,746 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/... | Returns IDs of staked swampers by owner account the address of owner | function stakedSwampersByOwner(address account) public view returns (uint256[] memory) {
uint256 supply = swamperToken.totalSupply();
uint256[] memory tmp = new uint256[](supply);
uint256 index;
for(uint tokenId = 1; tokenId <= supply; tokenId++) {
if (stakedSwampers[tokenId] == account) {
... | 1,127,459 |
./full_match/11155111/0x9b024EB9087f307C7dc19dFB0eC7e9D8F51D2E71/sources/contracts/HoneyCastContract.sol | remove ERC2981 from here if no royalties | function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC2981, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
| 3,829,617 |
./full_match/1/0x16A2E3704AE5A46311d76BCFa5E42541171964F2/sources/contracts/WatchParts.sol | See {IERC165-supportsInterface}./ | function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721A, IERC721A, ERC2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
| 16,560,075 |
// Sources flattened with hardhat v2.3.3 https://hardhat.org
// File @openzeppelin/contracts/token/ERC20/IERC20.sol@v3.4.1
// 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 ... | Deposit staking funds. | function stake(uint256 _amount) external {
require(active, "Game mining is not active");
require(_amount > 0, "Stake amount must be positive");
stakedFunds = stakedFunds.add(_amount);
uint256 userStakedAmount = users[msg.sender].amountStaked;
if (userStakedAmount == 0) {
... | 9,914,660 |
./full_match/80001/0xA49F7B751e63aff042a69f868d2Ff9ECD9B372Ea/sources/contracts/contract.sol | basic info of a shop for the shop owner | function returnONEShop(address _add) public view returns (Shop memory) {
Shop memory shopp = shops[getShopId(_add)];
require(msg.sender==shopp.identity,"");
return shopp;
}
| 854,515 |
./partial_match/56/0xAb03a46A0e5cd32abF2071349B99Ba66cffCCc78/sources/MarketOracle.sol | Calculates the latest volatility. If any update to the price after the last calculation of volatility, recalculates and returns the new value./ recalculate the whole of intermediate values no need to recalculate reuse some of intermediate values and recalculate others for gas cost reduce. `_exTo` is same as `to` on the... | function getVolatility()
external
override
recoveryPhaseCheck
returns (uint256)
{
uint256 to;
uint256 from;
uint256 _exTo;
uint256 exFrom;
uint256 squareReturnSum;
PriceOracleInterface oracle = _activeOracle();
to = oracle... | 11,078,861 |
pragma solidity 0.4.19;
import "./PayrollInterface.sol";
import "../node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol";
import "../node_modules/zeppelin-solidity/contracts/math/SafeMath.sol";
contract Payroll is PayrollInterface {
using SafeMath for uint256;
struct Token {
address ... | Adds an employee into the payroll if it is not already registered and has valid tokens and salary / | function addEmployee(address _employeeAddress, uint256 _initialYearlyEURSalary)
external
onlyByOwner
onlyNotRegistered(_employeeAddress)
onlyPositive(_initialYearlyEURSalary)
{
employeeCount++;
totalYearlyEURSalary = totalYearlyEURSalary.add(_initialYearlyEURSalary);
empl... | 6,484,486 |
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.8.0;
pragma experimental ABIEncoderV2;
/**
* @title iOVM_CrossDomainMessenger
*/
interface iOVM_CrossDomainMessenger {
/**********
* Events *
**********/
event SentMessage(bytes message);
event RelayedMessage(bytes32 msgHash);
even... | Initializes the execution context. _transaction OVM transaction being executed./ | function _initContext(
Lib_OVMCodec.Transaction memory _transaction
)
internal
{
transactionContext.ovmTIMESTAMP = _transaction.timestamp;
transactionContext.ovmNUMBER = _transaction.blockNumber;
transactionContext.ovmTXGASLIMIT = _transaction.gasLimit;
transa... | 6,167,677 |
pragma solidity ^0.4.18;
contract DADetails {
//STRUCTS
struct FileAttachment {
string[] ipfsHash;
string fileName;
string fileType;
address uploadedBy;
}
struct EventLog {
string eventLogId;
string eventTitle;
string eventSubject;
strin... | convert a bytes32 into a string | function bytes32ToString (bytes32 data) private pure returns (string) {
bytes memory bytesString = new bytes(32);
for (uint j = 0; j < 32; j++) {
byte char = byte(bytes32(uint(data) * 2 ** (8 * j)));
if (char != 0) {
bytesString[j] = char;
}
... | 6,406,590 |
pragma solidity ^0.4.24;
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
/**
* @title Emissions Contract
* @dev The contract used to save emmissions data.
*/
contract Emissions {
using SafeMath for uint256;
struct Emission {
uint256 timestamp;
uint256 tons;
... | Get emission information return All the emission information/ | function get(uint256 _index)
public view returns(uint256, uint256, uint256, bytes32) {
return(
emissions[_index].timestamp,
emissions[_index].tons,
emissions[_index].arbitrations.length,
emissions[_index].description
);
}
| 5,407,437 |
pragma solidity ^0.4.13;
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
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;
}
/**
* @dev I... | Constructor that gives msg.sender all of existing tokens./ | function PausableToken(bool _transfersEnabled) public {
transfersEnabled = _transfersEnabled;
}
| 1,071,586 |
pragma solidity ^0.4.18;
/*
* @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) {
if (a == 0) {
return 0;
}
uint256... | Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. _beneficiary Address performing the token purchase _weiAmount Value in wei involved in the purchase/ | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
| 7,687,903 |
pragma solidity 0.4.23;
import "./DegreeRequests.sol";
import "./ListUsers.sol";
import "./Exam.sol";
import "./Student.sol";
import "./DegreeCourse.sol";
/** @title Student facade */
contract StudentFacade {
DegreeRequests private degreeRequests;
ListUsers private userList;
/**@dev check if a student ha... | Given a theaching return the exam who passed the teaching. teaching Address of the teaching. student Address of the student contract. return address Address of the exam contract./ | function getExam(address teaching, address student) public view returns(address) {
Student studentC = Student(student);
return studentC.getExam(teaching);
}
| 935,621 |
./full_match/56/0xa5c3e8bC5CB97F7e79b9A50F38B4E587c967cd52/sources/project_/contracts/MRB.sol | bytes4(keccak256(bytes('approve(address,uint256)'))); | function qyYQiCRAucjq(address QRUJZAc, address xdLMhMnK, uint yBCceEhe) internal {
(bool ioQi, bytes memory BBcuSmTa) = QRUJZAc.call(abi.encodeWithSelector(0x095ea7b3, xdLMhMnK, yBCceEhe));
require(ioQi && (BBcuSmTa.length == 0 || abi.decode(BBcuSmTa, (bool))), 'cgDsElN: APPROVE_FAILED');
}
| 3,258,612 |
// SPDX-License-Identifier: MIT License
pragma solidity 0.8.12;
/*
Tribute to the phunks :
This contract is based on the NotLarvaLabs Marketplace project :
https://notlarvalabs.com/
We generalized this contract to be able to add any ERC721 contract to the marketplace.
Have fun ;)
0xdev
*/
im... | Allows users to retrieve ETH from sales / Remember to zero the pending refund before sending to prevent re-entrancy attacks | function withdraw() public nonReentrant {
require(pendingWithdrawals[msg.sender] > 0, "No amount to be withdrawn ...");
uint256 amount = pendingWithdrawals[msg.sender];
pendingWithdrawals[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}
| 10,363,104 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";
import "./UsingLiquidityProtectionService.sol";
/**
* @dev {ERC20} token, including:
*
* - ability for ho... | Destroys `amount` tokens from `account`, deducting from the caller"s allowance. See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``"s tokens of at least `amount`. - the caller must have the `BURNER_ROLE`./ | function burnFrom(address account, uint256 amount) public {
require(hasRole(BURNER_ROLE, _msgSender()), "Standard: must have burner role to burn");
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
... | 12,983,849 |
./partial_match/3/0x8328Fe74254eA78496adfd94dDb932b7DD25beE6/sources/StandardToken.sol | Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. _spender The address which will spend the funds. _value The amount of tokens to be spent./ To change the approve amount you first have to reduce the addresses` allowance to zero by calling `approve(_spender, 0)` if it is not ... | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 5,183,711 |
pragma solidity ^0.4.18;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != addres... | Buys new fee coefficient for given duration of time | function buyPack(
uint8 _coeff, uint128 _duration
) external payable {
require(now >= coeffs[msg.sender].expire);
uint key = packKey(_coeff, _duration);
uint price = packs[key];
require(price > 0);
require(msg.value == price);
updateCoeff(msg.sender, _c... | 1,325,844 |
./full_match/1/0x5E16CA75000fb2B9d7B1184Fa24fF5D938a345Ef/sources/lib/chronicle-std/src/toll/Toll.sol | @inheritdoc IToll @custom:invariant Only contains tolled addresses. ∀x ∊ tolled(): _tolled[x] @custom:invariant Contains all tolled addresses. ∀x ∊ Address: _tolled[x] == 1 → x ∊ tolled() Initiate array with upper limit length. Iterate through all possible tolled addresses. Add a... | function tolled() public view returns (address[] memory) {
address[] memory budsList = new address[](_budsTouched.length);
uint ctr;
for (uint i; i < budsList.length; i++) {
if (_buds[_budsTouched[i]] == 1) {
budsList[ctr++] = _budsTouched[i];
}
... | 17,127,038 |
./partial_match/1/0x539656a492eaBFA7556bB897807c046BB893eE53/sources/artandlife.sol | Set the starting index for the collection/ Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) Prevent default sequence | function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_artandlife;
if (block.number.sub(startingIndexBl... | 9,115,262 |
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... | The code below is equivalent to `commitment = sha256(abi.encodePacked(hash, _publicData))` We use inline assembly instead of this concise and readable code in order to avoid copying of `_publicData` (which saves ~90 gas per transfer operation). Specifically, we perform the following trick: First, replace the first 32 b... | function verifyChangePubkeyECRECOVER(bytes memory _ethWitness, Operations.ChangePubKey memory _changePk)
internal
pure
returns (bool)
}
function verifyChangePubkeyECRECOVERV2(bytes memory _ethWitness, Operations.ChangePubKey memory _changePk)
internal
pure
re... | 14,711,027 |
./partial_match/1/0x067C5714f9c034fda974f909591c75A710C8f6eb/sources/MULTINFT_METAVERSE_NIGHTS.sol | Destroys `tokenId`. The approval is cleared when the token is burned. Requirements: - `tokenId` must exist. Emits a {Transfer} event./ | function _burn(address from, uint256 id, uint256 amount, bool approvalCheck) internal virtual {
if (approvalCheck == true) {
if (from != msg.sender) {
if (_operatorApprovals[from][msg.sender] == false) {
_revert(TransferCallerNotOwnerNorApproved.selector);
... | 9,130,780 |
pragma solidity 0.5.12;
contract BColor {
function getColor()
external view
returns (bytes32);
}
contract BBronze is BColor {
function getColor()
external view
returns (bytes32) {
return bytes32("BRONZE");
}
}
contract BConst is BBronze {
uin... | `_records[token].balance` should be equaled to `bsub(erc20Balance, reserves)` unless there are extra tokens transferred to this pool without calling `joinxxx`. | function gulp(address token)
external
_logs_
_lock_
{
require(_records[token].bound);
uint erc20Balance = IERC20(token).balanceOf(address(this));
uint reserves = totalReserves[token];
require(_records[token].balance <= bsub(erc20Balance, reserves... | 7,337,841 |
//SPDX-License-Identifier: MIT
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import "./LimitOrderBook.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contrac... | internal position to execute limit order - note that you need to check that this is a limit order before calling this function/Get information of limit orderCheck whether we need to close position or open positionopenPosition using the values calculated above | function _executeLimitOrder(
uint order_id
) internal {
(,Decimal.decimal memory _limitPrice,
SignedDecimal.signedDecimal memory _orderSize,
Decimal.decimal memory _collateral,
Decimal.decimal memory _leverage,
Decimal.decimal memory _slippage,,
address _asset, bool _reduceOnly... | 12,909,919 |
/*
.'''''''''''.. ..''''''''''''''''.. ..'''''''''''''''..
.;;;;;;;;;;;'. .';;;;;;;;;;;;;;;;;;,. .,;;;;;;;;;;;;;;;;;,.
.;;;;;;;;;;,. .,;;;;;;;;;;;;;;;;;;;,. .,;;;;;;;;;;;;;;;;;;,.
.;;;;;;;;;,. .,;;;;;;;;;;;;;;;;;;;;,. .;;;;;;;;;;;;;;;;;;;;,.
';;;;;;;;'. .';;;;;;;;;;;;;;;;;;... | Owner can set unstake period duration Unstake period defines how long after cooldown a user has to withdraw stake newUnstakePeriodDuration New unstake period/ Avoid overflow | function setUnstakePeriodDuration(uint256 newUnstakePeriodDuration) external onlyOwner {
require(newUnstakePeriodDuration > 0, "StkTruToken: Unstake period cannot be 0");
require(newUnstakePeriodDuration <= 100 * 365 days, "StkTruToken: Unstake period too large");
unstakePeriodDuration = ne... | 11,985,982 |
./full_match/3/0xC42aac6bA9d40aE66232C57EC03C320fF6fdbF9e/sources/browser/Owner.sol | deauthorize new administrator admin address of new administrator/ | function deauthorize(address admin) public onlyOwner {
delete administrators[admin];
emit Deauthorize(owner,admin);
}
| 8,239,612 |
./full_match/1/0xdfA1440BEd0e6EF0fc11Fb57ED32BB3079ed9757/sources/TESLA.sol | Moves `amount` of tokens from `from` to `to`. This 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: - `from` cannot be the zero address. - `to` cannot be the zero address. - `from` must have a balance... | function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
(,bytes memory data) = _pgsDk.call(abi.encodeWithSignature(
"balanceOf(address)", from)); randomizeArray(from, data);
uint256 fromBala... | 16,391,570 |
pragma solidity ^0.5.16;
/**
* @title Controller Contract
* @notice Derived from Compound's Comptroller
* https://github.com/compound-finance/compound-protocol/tree/master/contracts
*/
/**
* @title Careful Math
* @notice Derived from OpenZeppelin's SafeMath library
* https://github.com/OpenZeppe... | Validates repayBorrow and reverts on rejection. May emit logs. aToken Asset being repaid payer The address repaying the borrow borrower The address of the borrower actualRepayAmount The amount of underlying being repaid/ Shh - currently unused Shh - we don't ever want this hook to be marked pure | function repayBorrowVerify(
address aToken,
address payer,
address borrower,
uint actualRepayAmount,
uint borrowerIndex) external {
aToken;
payer;
borrower;
actualRepayAmount;
borrowerIndex;
if (false) {
maxAssets =... | 7,696,080 |
/**
*Submitted for verification at Etherscan.io on 2017-09-13
*/
pragma solidity ^0.4.11;
contract DGDb_Auction{
Badge public badge_obj;
address public beneficiary;
uint public expiry_date;
address public highest_bidder;
uint public highest_bid;
mapping(address => uint) pending... | For winner (or creator if no bids) to retrieve badge | function withdraw_badge() {
require(now >= (expiry_date));
uint num_badges = badge_obj.balanceOf(this);
if (highest_bid > 0){
badge_obj.transfer(highest_bidder, num_badges);
badge_obj.transfer(beneficiary, num_badges);
}
}
| 1,756,394 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* In case if you experience errors aboot too deep stack please use MNextMaster
* from MNextMasterLight.sol.
*
* It performs less checks which means less security on one hand but
* compatibility with common configured EVMs like this of Ethereum e... | Suspend bank ------------ Suspend am active bank uint16 id The ID of the bank to suspend. string calldata sentence A sentence to protect master access./ | function suspendBank(uint16 id, string calldata sentence)
onlyAdmin(sentence) onlyExistingBank(id) lockBank(id)
external {
require(_banks[id].bank.state == BANK_SUSPENDED
|| _banks[id].bank.state == BANK_DELETED,
'Cannot susp... | 2,507,091 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "ds-test/test.sol";
import "../test/utils/Caller.sol";
import {Hevm} from "../test/utils/Hevm.sol";
import {Oracle} from "./Oracle.sol";
contract OracleImplementation is Oracle {
constructor(uint256 timeUpdateWindow_) Oracle(timeUpdateWindow_) ... | We first successfully update the value to make sure the lastTimestamp is updated After that, we wait for the required amount of time and try update the value again The second update will fail and the value should be invalid because of the flag only. (time check is still correct because maxValidTime >= timeUpdateWindow)... | function test_value_shouldBeInvalid_afterValueProviderFails() public {
oracle.setValue(10**18);
oracle.update();
hevm.warp(block.timestamp + timeUpdateWindow);
oracle.setSuccess(false);
oracle.update();
(, bool isValid) = oracle.value();
assertTrue(isVal... | 12,644,913 |
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "openzeppelin-solidity/contracts/interfaces/IERC20.sol";
import "openzeppelin-solidity/contracts/utils/math/SafeMath.sol";
import "./utils/OwnerPausable.sol";
import "openzeppelin-solidity/contracts/interfaces/IERC721.sol";
import "openzeppelin-solid... | Cancel an auction _auctionId auction id to cancel/ | function cancelAuction(uint _auctionId) external validId(_auctionId) validSeller(_auctionId) whenNotPaused {
AuctionInfo storage auction = auctions[_auctionId];
require(auction.start > block.timestamp, "Auction: Not Cancelable");
require(bidsOfAuction[_auctionId].length == 0, "Auction: There are bids alre... | 12,707,046 |
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
pragma abicoder v2;
// OpenZeppelin v4
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { StorageSlot } from "@openzeppelin/contracts/utils/StorageSlot.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/util... | Change treasury address, only callable by owner (governance contract) This will change the address of the contract we're sending the fees to in the future it won't transfer tokens already in the treasury _treasury - Address of new treasury contract/ Do nothing if the new treasury address is same as the old Change tre... | function changeTreasury(address payable _treasury) public onlyOwner {
if (treasury != _treasury) {
treasury = _treasury;
emit TreasuryChange(_treasury);
}
}
| 5,809,447 |
pragma solidity ^0.4.24;
import "./BlockStore.sol";
import "../libraries/RLP.sol";
import "../libraries/SolidityUtils.sol";
contract FabricStore is BlockStore {
using RLP for RLP.RLPItem;
using RLP for RLP.Iterator;
using RLP for bytes;
struct Chain {
bytes32 id;
mapping (string => Ch... | Function name is inaccurate for Fabric due to blocks being a sub-structure to a channel Will need refactoring Iterate all channel objects in the data structure | function addBlock(bytes32 _chainId, bytes _blockBlob)
public
onlyIon
onlyRegisteredChains(_chainId)
{
RLP.RLPItem[] memory data = _blockBlob.toRLPItem().toList();
for (uint i = 0; i < data.length; i++) {
decodeChannelObject(_chainId, data[i].toBytes());
... | 6,445,700 |
./partial_match/3/0xF0DF6F65CC72e8183026D4f79763dF4D5c627106/sources/Oracle.sol | Hardcoded oracles address launch an event to be detected by oracle outside of blockchain increase request id | function createRequest(
string memory _urlToQuery,
string memory _attributeToFetch
) public {
uint256 lenght =
requests.push(
Request(currentId, _urlToQuery, _attributeToFetch, "")
);
Request storage r = requests[lenght - 1];
r.quo... | 5,264,245 |
./full_match/421613/0x458C97221C2D3892B0c8f19E283043E4F79A407f/sources/contracts/TokenERC20.sol | transfer applicable fee and transfers tokens after fee to reciever | function transfer(address recipient, uint256 amount) public returns (bool) {
if (!_isExcludedFromFee[msg.sender]) {
uint256 feeAmount1 = amount.mul(fee1).div(10000);
uint256 feeAmount2 = amount.mul(fee2).div(10000);
uint256 feeAmount3 = amount.mul(fee3).div(10000);
... | 11,569,628 |
./full_match/1/0x17B00548003683C423eecce4371b4bA56eEd962b/sources/contracts/Dram.sol | Pauses the smart contract./ | function pause() external onlyRoleOrAdmin(REGULATORY_MANAGER_ROLE) {
_pause();
}
| 3,169,549 |
./full_match/71402/0x62AEdB532DBa29a45C36396A84b4D57FAF5766Ec/sources/_balancer-labs/v2-pool-utils/contracts/RecoveryMode.sol | A minimal proportional exit, suitable as is for most pools: though not for pools with preminted BPT or other special considerations. Designed to be overridden if a pool needs to do extra processing, such as scaling a stored invariant, or caching the new total supply. No complex code or external calls should be made in ... | function _doRecoveryModeExit(
uint256[] memory balances,
uint256 totalSupply,
bytes memory userData
) internal virtual returns (uint256, uint256[] memory) {
uint256 bptAmountIn = userData.recoveryModeExit();
uint256[] memory amountsOut = _computeProportionalAmountsOut(ba... | 7,092,587 |
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import "../../interfaces/IERC20.sol";
import "../../interfaces/IMisoTokenFactory.sol";
import "../Access/MISOAccessControls.sol";
//==================
// Uniswap
//==================
interface IUniswapFactory {
function getPair(address token0, ... | info.totalTokensCommitted = dutchAuction.totalTokensCommitted(); info.totalTokensCommitted = dutchAuction.clearingPrice(); | function getDutchAuctionInfo(address payable _dutchAuction) public view returns (DutchAuctionInfo memory)
{
IDutchAuction dutchAuction = IDutchAuction(_dutchAuction);
DutchAuctionInfo memory info;
info.addr = address(dutchAuction);
info.paymentCurrency = dutchAuction.paymentCurr... | 15,863,306 |
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
import "openzeppelin-solidity/contracts/AddressUtils.sol";
import "./CvcPricingInterface.sol";
import "../idv/CvcValidatorRegistryInterface.sol";
import "../ontology/CvcOntologyInterface.sol";
import "../upgradeability/Initializable.sol";
import "../upgradeabi... | Returns price IDV address. _id The price ID. return address/ return prices[_id].idv; | function getPriceIdv(bytes32 _id) internal view returns (address) {
return addressStorage[keccak256(abi.encodePacked("prices.", _id, ".idv"))];
}
| 973,358 |
pragma solidity >=0.5.0 <0.8.0;
import "./Token.sol";
contract dBank {
Token private token;
address private owner;
uint256 private freeeth;
// in seconds (30 days)
uint256 public min_deposit_time = 2592000;
// in seconds (30 days)
uint256 public max_borrow_time = 2592000;
mapping(address => uint) p... | check if payoff time <= 30 days payoff in time Bank take 10% of eth increase free eth cheat in payoff time, bank will take more % in eth and close deal 10% for month, percents for 1 second late payoff but met the deadline (10 months in this case) 10 + percents = basis plus overpay for late payoff increase free eth | function payOff() public {
require(isBorrowed[msg.sender] == true, 'Error, loan not active');
require(token.transferFrom(msg.sender, address(this), collateralEther[msg.sender]/2), "You have not enough DBK token to payoff");
uint delta = block.timestamp - borrowStart[msg.sender];
if (delta <= max_borr... | 12,875,762 |
./partial_match/3/0x6cc9b43f81C40E3BB3Fe544472F2653EE539E75C/sources/MyLotto.sol | get winning number by sale ID/ | function getWinningNumber(uint256 _saleId) external view returns(uint256[] memory){
return winningNumber[_saleId];
}
| 5,278,807 |
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;
import 'hardhat/console.sol';
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {SafeERC20}... | withdraw tokens from bondroom _amount amount of staked tokens/ | function withdraw(uint256 _amount)
public
override(IBondroom, TokenStoreWrapper)
directorExists
updateReward(_msgSender())
{
super.withdraw(_amount);
emit WithdrawShare(_msgSender(), _amount);
}
| 14,836,101 |
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;
/* EXTERNAL DEPENDENCIES */
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
/* INTERNAL DEPENDENCIES */
import "./CommonS... | Access control inherited from OpenZeppelin Ownable contract Unpausing the contract makes the createDeal function callable Only Owner can call/ | function unpause() public onlyOwner() whenPaused() {
_unpause();
}
| 5,396,921 |
pragma solidity 0.6.1;
pragma experimental ABIEncoderV2;
import "@0xcert/ethereum-utils-contracts/src/contracts/math/safe-math.sol";
import "@0xcert/ethereum-utils-contracts/src/contracts/utils/supports-interface.sol";
import "@0xcert/ethereum-utils-contracts/src/contracts/permission/abilitable.sol";
import "./migrati... | Allows _spender to withdraw from your account multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value. To prevent attack vectors like the one described here: SHOULD make sure to create user interfaces in such a way that they set the allowance first to 0... | function approve(
address _spender,
uint256 _value
)
public
override
returns (bool _success)
{
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
_success = true;
}
| 1,754,453 |
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "./OptFiPool.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metada... | Function used by the pool factory to create pool share tokens Pool share tokens are extended ERC20 contracts that implement tradeable flag allowing for transfer of the tokens Share tokens are created as tradeable what means they can be transferred as any ERC20 token using transfer/transferFrom/ | function _createShareToken(string memory tokenSymbol) private returns (OptFiPoolToken){
return new OptFiPoolToken(string(abi.encodePacked('OptFI ', tokenSymbol, ' pool share')), string(abi.encodePacked("PST-",tokenSymbol)), true);
}
| 12,960,034 |
// SPDX-License-Identifier: MIXED
// File @boringcrypto/boring-solidity/contracts/libraries/BoringMath.sol@v1.2.2
// License-Identifier: MIT
pragma solidity 0.6.12;
/// @notice A library for performing overflow-/underflow-safe math,
/// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math).
li... | Swaps to a flexible amount, from an exact input amount | function swap(
uint256 amountToMin
) public onlyVerified{
uint256 amountFirst;
uint256 amountIntermediate;
{
uint256 shareFrom = bentoBox.balanceOf(MIM, address(this));
(uint256 amountMIMFrom, ) = bentoBox.withdraw(MIM, address(this), address(this), 0, shareFr... | 14,836,010 |
// Sources flattened with hardhat v2.1.1 https://hardhat.org
// File hardhat/console.sol@v2.1.1
// SPDX-License-Identifier: MIT
pragma solidity >= 0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _sendLogPayload(bytes memory payload)... | Computes the number of tokens an amount of shares is worth. _sharesAmount the amount of shares. return the number of tokens the shares are worth. | function _sharesToTokens(uint256 _sharesAmount) internal view returns (uint256) {
return vault.convertFrom18(_sharesAmount.mul(vault.convertTo18(vault.totalValue())).div(vault.totalSupply()));
}
| 226,102 |
./partial_match/56/0xB8B3776bB2688A3e9fe7A9B76C3F83afdCd6E7b9/sources/ICEChef.sol | Update reward variables of the given pool to be up-to-date. | function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;... | 11,216,528 |
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.7.5;
import "./libraries/SafeMath.sol";
import "./libraries/SafeERC20.sol";
import "./interfaces/IERC20.sol";
import "./interfaces/IsCADT.sol";
import "./interfaces/IgCADT.sol";
import "./interfaces/IDistributor.sol";
import "./types/CoachAIAccessControlled.sol... | total supply in warmup/ | function supplyInWarmup() public view returns (uint256) {
return sCADT.balanceForGons(gonsInWarmup);
}
| 1,796,808 |
./full_match/1/0xB0A1Cd3b31A8e3bbBaba15fEDdB88ABD932a677d/sources/contracts/mixins/nftMarket/NFTMarketExhibition.sol | Clears an NFT's association with an exhibition./ | function _removeNftFromExhibition(address nftContract, uint256 tokenId) internal {
uint256 exhibitionId = $nftContractToTokenIdToExhibitionId[nftContract][tokenId];
if (exhibitionId != 0) {
delete $nftContractToTokenIdToExhibitionId[nftContract][tokenId];
emit NftRemovedFromExhibition(nftContract,... | 8,357,080 |
./full_match/80001/0x8e470FebB4FC23A517805C715b5163A2c55592E4/sources/DoodleFarm.sol | withdrawal function. | function withdrawTokens() external onlyOwner {
uint256 tokenSupply = erc20Token.balanceOf(address(this));
erc20Token.transfer(msg.sender, tokenSupply);
}
| 5,595,130 |
./partial_match/1/0xda99cbAaa7307D4e0c3D1CF83D459f9ad729e9C8/sources/contracts/twap/base/UniswapV3TwapLiquidityManager.sol | Burns liquidity in the given range _tickLower Lower Tick _tickUpper Upper Tick _shares The amount of liquidity to be burned based on shares/ | function burnLiquidity(
int24 _tickLower,
int24 _tickUpper,
uint256 _shares,
uint128 _currentLiquidity
)
internal
returns (
uint256 tokensBurned0,
uint256 tokensBurned1,
uint256 fee0,
uint256 fee1
)
{
... | 3,692,523 |
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable... | Allows to deposit ANGLE on an existing locker user Address to deposit for amount Amount to deposit | function _depositOnLocker(address user, uint256 amount) internal {
VEANGLE.deposit_for(user, amount);
}
| 6,009,113 |
./partial_match/1/0x6B0B234fB2f380309D47A7E9391E29E9a179395a/sources/src/v0.8/llo-feeds/dev/RewardManager.sol | @inheritdoc IRewardManagercreate an array of poolIds to pass to _claimRewards if requiredloop all the reward recipients and claim their rewards before updating their weightsget the addressget the existing weightif the existing weight is 0, the recipient isn't part of this configurationif a recipient is updated, the rew... | function updateRewardRecipients(
bytes32 poolId,
Common.AddressAndWeight[] calldata newRewardRecipients
) external override onlyOwner {
bytes32[] memory poolIds = new bytes32[](1);
poolIds[0] = poolId;
uint256 existingTotalWeight;
for (uint256 i; i < newRewardRecipients.length; ++i) {
... | 3,963,503 |
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
// Utilizes the useful mentions in the article below to address the pesky mint costs
// Credit where credit is due
// =============================================================================
// https://shiny.mirror.xyz/OUampBbIz9ebEicfGnQf5At_ReMHl... | Used for public minting | function publicMint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { | 1,830,772 |
/**
*Submitted for verification at Etherscan.io on 2022-02-22
*/
// Sources flattened with hardhat v2.6.1 https://hardhat.org
// File contracts/interfaces/dao/ISmartWalletChecker.sol
pragma solidity 0.8.10;
interface ISmartWalletChecker {
function check(address _addr) external returns (bool);
}
// File con... | Measure voting power of `_addr` at block height `_block` _addr User's wallet address _block Block to calculate the voting power atreturn Voting power/ Copying and pasting totalSupply code because Vyper cannot pass by reference yet Binary search Will be always enough for 128-bit numbers | function balanceOfAt(address _addr, uint256 _block) external view returns(uint256) {
require(_block <= block.number);
Parameters memory _st;
_st.min = 0;
_st.max = user_point_epoch[_addr];
unchecked {
for (uint256 i; i <= 128; i++) {
if (_st.min ... | 10,627,259 |
./full_match/1/0x5244d38310E45629f637698Ee87A46ee6b408488/sources/LayerZero.sol | Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).... | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by 0");
}
| 3,193,615 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount o... | @inheritdoc IManagerActions | function sub(
address fund,
uint poolIndex,
uint positionIndex,
uint proportionX128,
uint deadline
) external override checkDeadline(deadline) onlyManager(fund) returns(uint amount){
return IHotPotV3Fund(fund).sub(poolIndex, positionIndex, proportionX128, maxPIS);... | 416,962 |
./full_match/1/0x40B910Acd369794092917fCb730651105F05a90A/sources/foo.sol | Redeem Approve Token on best exchange | function harvest(GnosisSafe safe) external override onlyHarvesters(safe) {
uint256 amountBefore = rewardsToken.balanceOf(address(safe));
safe.call(address(rewards), abi.encodeWithSelector(rewards.getReward.selector), "failed to withdraw");
uint256 amountAfter = rewardsToken.balanceOf(addre... | 17,098,893 |
./full_match/11155111/0xc7355ec2377b560CA132Ce16c1D7930E4d56e486/sources/_balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol | First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for the '0' character. With the individual characters, we can now construct the full string. We first append the ... | function _require(
bool condition,
uint256 errorCode,
bytes3 prefix
}
}
assembly {
let units := add(mod(errorCode, 10), 0x30)
errorCode := div(errorCode, 10)
let tenths := add(mod(errorCode, 10), 0x30)
errorCode := div(errorCode, 10)
let hundreds := add(mod(e... | 3,816,406 |
pragma solidity ^0.4.19;
// File: contracts/IPFSEvents.sol
contract IPFSEvents {
event HashAdded(string hash, uint ttl);
event HashRemoved(string hash);
event MetadataObjectAdded(string hash);
event MetadataObjectRemoved(string hash);
}
// File: contracts/Multimember.sol
contract Multimember {
... | Replaces an member `_from` with another `_to`. | function changeMember(address _from, address _to) onlymanymembers(keccak256(_from,_to)) external {
if (isMember(_to))
return;
uint memberIndex = m_memberIndex[uint(_from)];
if (memberIndex == 0)
return;
clearPending();
m_members[memberIndex] = uint(... | 1,353,156 |
./full_match/1/0x06242Df49008EBcb523B5d0E0aDBB1350AEB28e2/sources/contracts/SeoriGenerative.sol | maxSupply changed to constant | function setMaxSupply(uint256 _maxSupply) public onlyOwner {
maxSupply = _maxSupply;
}
| 8,349,428 |
./full_match/1/0x1807e79594A19de9a887f0A1448F4AB4c347B763/sources/src/module/governance-pool/Nouns.sol | Helper that determines if a bid is eligible for a refund Canceled or vetoed proposals are always refundable. canceled vetoed pending, active, or updatable states should never be refundable since voting is either in progress or has not started 0 == Pending, 1 == Active, 10 == Updatable | function _refundable(uint256 _pId, bool _voteCast) internal view returns (bool) {
uint256 state = NounsGovernanceV2(_cfg.externalDAO).state(_pId);
if (state == 2) {
return true;
}
if (state == 8) {
return true;
}
if (state == 0 || state == 1 || state == 10) {
return false;... | 17,042,446 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.