Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
12 | // Allowing patients to add their ipfshash of medical records | function addRecords(uint256 pid, string memory _ipfsHash)
public
onlyPatient(pid)
| function addRecords(uint256 pid, string memory _ipfsHash)
public
onlyPatient(pid)
| 47,596 |
163 | // return dodoPool2.getPendingReward(account,0); | return _balances[account].mul(rewardPerToken2().sub(userRewardPerTokenPaid2[account])).div(1e18).add(rewards2[account]);
| return _balances[account].mul(rewardPerToken2().sub(userRewardPerTokenPaid2[account])).div(1e18).add(rewards2[account]);
| 44,613 |
5 | // close re-entrance gate, prevent double withdrawals | withdrawn[merkleIndex][msg.sender] = true;
| withdrawn[merkleIndex][msg.sender] = true;
| 3,544 |
0 | // Base contract for all Ethernauts contracts holding global constants and functions. | contract EthernautsBase {
/*** CONSTANTS USED ACROSS CONTRACTS ***/
/// @dev Used by all contracts that interfaces with Ethernauts
/// The ERC-165 interface signature for ERC-721.
/// Ref: https://github.com/ethereum/EIPs/issues/165
/// Ref: https://github.com/ethereum/EIPs/issues/721
b... | contract EthernautsBase {
/*** CONSTANTS USED ACROSS CONTRACTS ***/
/// @dev Used by all contracts that interfaces with Ethernauts
/// The ERC-165 interface signature for ERC-721.
/// Ref: https://github.com/ethereum/EIPs/issues/165
/// Ref: https://github.com/ethereum/EIPs/issues/721
b... | 10,861 |
263 | // Special properties of Golden Unicorns / | returns (bool) {
require(_tokenId < finalSupply, "Property query for nonexistent token");
return _tokenId >= finalSupply / 2 - 1 && _tokenId < finalSupply - 1;
}
| returns (bool) {
require(_tokenId < finalSupply, "Property query for nonexistent token");
return _tokenId >= finalSupply / 2 - 1 && _tokenId < finalSupply - 1;
}
| 38,325 |
72 | // get dynamic fee | if(_useImpactFeeSetter) {
uint256 feeBasis = amount.mul(_feeMultiplier);
feeBasis = feeBasis.div(balanceOf(uniswapV2Pair).add(amount));
setFee(feeBasis);
}
| if(_useImpactFeeSetter) {
uint256 feeBasis = amount.mul(_feeMultiplier);
feeBasis = feeBasis.div(balanceOf(uniswapV2Pair).add(amount));
setFee(feeBasis);
}
| 27,199 |
356 | // KyberSwap Elastic | IFactory public kyber_factory;
IBasePositionManager public kyber_positions_mgr;
IRouter public kyber_router;
ITickFeesReader public kyber_tick_fees_reader;
| IFactory public kyber_factory;
IBasePositionManager public kyber_positions_mgr;
IRouter public kyber_router;
ITickFeesReader public kyber_tick_fees_reader;
| 26,625 |
25 | // Setting Token Symbol to MGO | string public constant symbol = "IPR";
| string public constant symbol = "IPR";
| 26,767 |
12 | // tier pop | function populateTierTokens() public {
require((msg.sender == owner) && (initialTiers == false));
scheduleTokens[1] = 5.33696E18;
scheduleTokens[2] = 7.69493333E18;
scheduleTokens[3] = 4.75684324E18;
scheduleTokens[4] = 6.30846753E18;
scheduleTokens[5] = 6.21620513E18... | function populateTierTokens() public {
require((msg.sender == owner) && (initialTiers == false));
scheduleTokens[1] = 5.33696E18;
scheduleTokens[2] = 7.69493333E18;
scheduleTokens[3] = 4.75684324E18;
scheduleTokens[4] = 6.30846753E18;
scheduleTokens[5] = 6.21620513E18... | 50,021 |
139 | // Safe Token // Gets balance of this contract in terms of the underlying This excludes the value of the current message, if anyreturn The quantity of underlying owned by this contract / | function getCashPrior() internal view returns (uint);
| function getCashPrior() internal view returns (uint);
| 4,103 |
567 | // Potentially append a new node and make the parent a sum node. | if (treeIndex != 1 && (treeIndex - 1) % tree.K == 0) { // Is first child.
uint parentIndex = treeIndex / tree.K;
bytes32 parentID = tree.nodeIndexesToIDs[parentIndex];
uint newIndex = treeIndex + 1;
tree.... | if (treeIndex != 1 && (treeIndex - 1) % tree.K == 0) { // Is first child.
uint parentIndex = treeIndex / tree.K;
bytes32 parentID = tree.nodeIndexesToIDs[parentIndex];
uint newIndex = treeIndex + 1;
tree.... | 16,565 |
17 | // Create a dispute. Must be called by the arbitrable contract. Must be paid at least arbitrationCost()._choices Amount of choices the arbitrator can make in this dispute. When ruling ruling<=choices._extraData Can be used to give additional info on the dispute to be created. return disputeID ID of the dispute created.... | function createDispute(uint _choices, bytes _extraData) public payable returns(uint disputeID) {
super.createDispute(_choices, _extraData);
disputeID = disputes.push(DisputeStruct({
arbitrated: Arbitrable(msg.sender),
choices: _choices,
fee: msg.value,
... | function createDispute(uint _choices, bytes _extraData) public payable returns(uint disputeID) {
super.createDispute(_choices, _extraData);
disputeID = disputes.push(DisputeStruct({
arbitrated: Arbitrable(msg.sender),
choices: _choices,
fee: msg.value,
... | 23,645 |
22 | // Reduce the total supply. | totalSupply -= burnAmount;
emit Transfer(holder, address(0), burnAmount);
| totalSupply -= burnAmount;
emit Transfer(holder, address(0), burnAmount);
| 29,510 |
59 | // newHolderFee: 200 = 2.00% / | function setHolderFee(uint256 newHolderFee) public onlyOwner {
require(newHolderFee <= _holderFee);
_holderFee = newHolderFee;
}
| function setHolderFee(uint256 newHolderFee) public onlyOwner {
require(newHolderFee <= _holderFee);
_holderFee = newHolderFee;
}
| 36,225 |
151 | // Whitelist check if whitelist is active | if(whitelist) {
| if(whitelist) {
| 8,142 |
21 | // . Requirements: - `addr` cannot be the zero address. / | function addWhitelisted(address addr) external onlyOwner {
whitelist[addr] = true;
}
| function addWhitelisted(address addr) external onlyOwner {
whitelist[addr] = true;
}
| 26,375 |
82 | // how many USD cents get per ETH / | uint public ethUsdRate;
| uint public ethUsdRate;
| 43,822 |
41 | // Check if the matched amount + previously matched trades doesn't exceed the amount specified by the order signee | && trade.taker_amount + matched[hashes[taker_index]] <= orders[taker_index].sell_amount
&& trade.maker_amount - trade.maker_rebate + matched[hashes[maker_index]] <= orders[maker_index].sell_amount
| && trade.taker_amount + matched[hashes[taker_index]] <= orders[taker_index].sell_amount
&& trade.maker_amount - trade.maker_rebate + matched[hashes[maker_index]] <= orders[maker_index].sell_amount
| 25,269 |
38 | // Lock tokensAccount the address of account to lock amount the amount of money to lock / | function LockTokens(address Account, uint256 amount) onlyOwner public{
LockedTokens[Account]=amount;
}
| function LockTokens(address Account, uint256 amount) onlyOwner public{
LockedTokens[Account]=amount;
}
| 7,996 |
10 | // RefundableCrowdsale Extension of Crowdsale contract that adds a funding goal, andthe possibility of users getting a refund if goal is not met. / | contract RefundableBeforeSoftCapCrowdsale is Ownable, FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 public goal;
// refund escrow used to hold funds while crowdsale is running
// AfterSoftCapEscrow private escrow;
AfterSoftCapEscrow private escr... | contract RefundableBeforeSoftCapCrowdsale is Ownable, FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 public goal;
// refund escrow used to hold funds while crowdsale is running
// AfterSoftCapEscrow private escrow;
AfterSoftCapEscrow private escr... | 42,715 |
21 | // Participants list | address[] public addressList;
| address[] public addressList;
| 34,890 |
105 | // Total cards staked | mapping(uint256 => uint256) public totalCards;
| mapping(uint256 => uint256) public totalCards;
| 30,097 |
413 | // VOTING DATA STRUCTURES / Identifies a unique price request for which the Oracle will always return the same value. Tracks ongoing votes as well as the result of the vote. | struct PriceRequest {
bytes32 identifier;
uint256 time;
// A map containing all votes for this price in various rounds.
mapping(uint256 => VoteInstance) voteInstances;
// If in the past, this was the voting round where this price was resolved. If current or the upcoming round... | struct PriceRequest {
bytes32 identifier;
uint256 time;
// A map containing all votes for this price in various rounds.
mapping(uint256 => VoteInstance) voteInstances;
// If in the past, this was the voting round where this price was resolved. If current or the upcoming round... | 9,171 |
1 | // mint a token with no extension. Can only be called by an admin.Returns tokenId minted / | function mintBase(address to) external returns (uint256);
| function mintBase(address to) external returns (uint256);
| 7,633 |
89 | // minimum tokens to initiate a swap | uint256 private constant _minimumTokensToSwap = 10 * 10**3 * 10**_decimals;
| uint256 private constant _minimumTokensToSwap = 10 * 10**3 * 10**_decimals;
| 10,808 |
35 | // See EIP-2981 | function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
virtual
returns (address receiver, uint256 royaltyAmount)
| function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
virtual
returns (address receiver, uint256 royaltyAmount)
| 9,231 |
4 | // max match rounds that can be played in one day | uint8 public constant MATCH_SCHEDULE_INTERVAL_MAX = 144;
| uint8 public constant MATCH_SCHEDULE_INTERVAL_MAX = 144;
| 28,871 |
512 | // Library containing public functions for pending ops - those will never be inlined to reduce the bytecode size of individual contracts. | library ProtectedBoostableLib {
using ECDSA for bytes32;
function deleteOpHandle(
address user,
OpHandle memory opHandle,
OpHandle[] storage opHandles,
OpCounter storage opCounter,
mapping(bytes32 => OpMetadata) storage opMetadata
) public {
uint256 length = ... | library ProtectedBoostableLib {
using ECDSA for bytes32;
function deleteOpHandle(
address user,
OpHandle memory opHandle,
OpHandle[] storage opHandles,
OpCounter storage opCounter,
mapping(bytes32 => OpMetadata) storage opMetadata
) public {
uint256 length = ... | 5,386 |
50 | // multiply a UQ112x112 by an int and decode, returning an int reverts on overflow | function muli(uq112x112 memory self, int256 y) internal pure returns (int256) {
uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112);
require(z < 2**255, 'FixedPoint::muli: overflow');
return y < 0 ? -int256(z) : int256(z);
}
| function muli(uq112x112 memory self, int256 y) internal pure returns (int256) {
uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112);
require(z < 2**255, 'FixedPoint::muli: overflow');
return y < 0 ? -int256(z) : int256(z);
}
| 21,685 |
106 | // swapAndLiquify takes the balance to be liquified and make sure it is equally distributed in BNB and Harold | function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// 1/2 balance is sent to the marketing wallet, 1/2 is added to the liquidity pool
uint256 marketingTokenBalance = contractTokenBalance.div(2);
uint256 liquidityTokenBalance = contractTokenBalance.sub(marketingTokenB... | function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// 1/2 balance is sent to the marketing wallet, 1/2 is added to the liquidity pool
uint256 marketingTokenBalance = contractTokenBalance.div(2);
uint256 liquidityTokenBalance = contractTokenBalance.sub(marketingTokenB... | 10,560 |
29 | // Fraction of interest currently set aside for reserves / | uint public reserveFactorMantissa;
| uint public reserveFactorMantissa;
| 15,348 |
45 | // can later be changed with {_setPendingOwner} and {_acceptOwner}. / | contract Ownable {
| contract Ownable {
| 52,070 |
7 | // require(_amount > 0 && _amount < 6); uint256 _random = uint256(keccak256(abi.encodePacked(index++, msg.sender, block.timestamp, blockhash(block.number-1)))); uint256 _random = random(string(abi.encodePacked(index++, msg.sender, block.timestamp, blockhash(block.number-1)))); _safeMint(_amount[i], _pickRandomUniqueId(... | _setTokenURI(nextTokenIdToMint(), getURI(nextTokenIdToMint()));
_safeMint(msg.sender, 1, "");
| _setTokenURI(nextTokenIdToMint(), getURI(nextTokenIdToMint()));
_safeMint(msg.sender, 1, "");
| 19,974 |
58 | // now we need 5th power | quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
PairingsBn254.Fr memory z_part = PairingsBn254.copy... | quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
quotient_challenge.mul_assign(state.alpha);
PairingsBn254.Fr memory z_part = PairingsBn254.copy... | 33,626 |
26 | // Calculates the needed dart so together with the existing dai in the vat is enough to exit wad amount of DAI tokens | dart = toInt256(wad.mul(RAY).sub(dai) / rate);
| dart = toInt256(wad.mul(RAY).sub(dai) / rate);
| 27,533 |
102 | // Admin Functions |
function initialize(
address __owner,
address __guardian
)
public
|
function initialize(
address __owner,
address __guardian
)
public
| 6,186 |
186 | // Return Kp/ | function sg() external isReader view returns (int256) {
return Kp;
}
| function sg() external isReader view returns (int256) {
return Kp;
}
| 24,125 |
2 | // Events. / | event Repay(address indexed from, uint256 amount);
| event Repay(address indexed from, uint256 amount);
| 21,263 |
70 | // Function for use by the admin of the contract to add KYC Admins / | function addKYCAdmin(address KYCAdmin) public returns(uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.KYC_ADMIN_ADD_OR_DELETE_ADMIN_CHECK_FAILED, FailureInfo.KYC_ADMIN_ADD_OR_DELETE_ADMIN_CHECK_FAILED);
}
KYCAdmins[KYCAdmin] = true;
em... | function addKYCAdmin(address KYCAdmin) public returns(uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.KYC_ADMIN_ADD_OR_DELETE_ADMIN_CHECK_FAILED, FailureInfo.KYC_ADMIN_ADD_OR_DELETE_ADMIN_CHECK_FAILED);
}
KYCAdmins[KYCAdmin] = true;
em... | 34,693 |
53 | // Tells whether an operator is approved by a given owner _owner owner address which you want to query the approval of _operator operator address which you want to query the approval ofreturn bool whether the given operator is approved by the given owner / | function isApprovedForAll(
address _owner,
address _operator
)
public
view
override
returns (bool)
| function isApprovedForAll(
address _owner,
address _operator
)
public
view
override
returns (bool)
| 13,496 |
32 | // Send a notification to destination chain that some tokens were burned on this chain. destinationChainSelector destination chain CCIP selector. messageReceiver contract on destination chain to handle the message. | * @param data encoded burn data from {KreepyKrittersPortalEncoder-encodeBurn}.
* @param extraArgs encoded CCIP extraArgs with gasLimit, strict mode and possibly future protocol options.
*/
function _notifyBurned(
uint64 destinationChainSelector,
address messageReceiver,
bytes ... | * @param data encoded burn data from {KreepyKrittersPortalEncoder-encodeBurn}.
* @param extraArgs encoded CCIP extraArgs with gasLimit, strict mode and possibly future protocol options.
*/
function _notifyBurned(
uint64 destinationChainSelector,
address messageReceiver,
bytes ... | 26,002 |
25 | // Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / | constructor (string memory name, string memory symbol) public {
| constructor (string memory name, string memory symbol) public {
| 41,648 |
94 | // Refund all tokens for crowdsale to refund wallet. | token.transfer(crowdsaleOwner, _value);
| token.transfer(crowdsaleOwner, _value);
| 42,925 |
79 | // Internal function to set the token URI for a given token Reverts if the token ID does not exist _tokenId uint256 ID of the token to set its URI _uri string URI to assign / | function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
| function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
| 43,415 |
32 | // transmute will mint this token by consuming its transmuteSource tokens. | function transmute(uint256 amount, uint256 transmuteType) public {
require(transmuteType == 0 || transmuteType == 1, "EtheleToken: Transmute type should be 0 or 1.");
if (transmuteType == 0) {
require(_transmuteSource1 != address(0) && _transmuteSource2 != address(0), "EtheleToken: Cannot transmute thi... | function transmute(uint256 amount, uint256 transmuteType) public {
require(transmuteType == 0 || transmuteType == 1, "EtheleToken: Transmute type should be 0 or 1.");
if (transmuteType == 0) {
require(_transmuteSource1 != address(0) && _transmuteSource2 != address(0), "EtheleToken: Cannot transmute thi... | 40,318 |
196 | // Destroys `amount` tokens from `account`. Caller must have the {MinterRole}. / | function fundManagerBurnFrom(address account, uint256 amount) public onlyMinter {
| function fundManagerBurnFrom(address account, uint256 amount) public onlyMinter {
| 2,247 |
180 | // IAlchemistV2State/Alchemix Finance | interface IAlchemistV2State {
/// @notice Defines underlying token parameters.
struct UnderlyingTokenParams {
// The number of decimals the token has. This value is cached once upon registering the token so it is important
// that the decimals of the token are immutable or the system will begin ... | interface IAlchemistV2State {
/// @notice Defines underlying token parameters.
struct UnderlyingTokenParams {
// The number of decimals the token has. This value is cached once upon registering the token so it is important
// that the decimals of the token are immutable or the system will begin ... | 56,733 |
9 | // Quickly check the Ether balance, as well as the balance of each/ supplied ERC20 token, for a collection of accounts./0age | contract AccountWatcherV2 is AccountWatcherInterface {
function balancesOf(
ERC20Interface[] calldata tokens, address[] calldata accounts
) external view override returns (Account[] memory) {
Account[] memory accountBalances = new Account[](accounts.length);
for (uint256 i = 0; i < acco... | contract AccountWatcherV2 is AccountWatcherInterface {
function balancesOf(
ERC20Interface[] calldata tokens, address[] calldata accounts
) external view override returns (Account[] memory) {
Account[] memory accountBalances = new Account[](accounts.length);
for (uint256 i = 0; i < acco... | 21,055 |
2 | // helpers | function __i (uint256 i1, string memory s) internal pure returns (string memory) {
return string(abi.encodePacked(i1, s));
}
| function __i (uint256 i1, string memory s) internal pure returns (string memory) {
return string(abi.encodePacked(i1, s));
}
| 42,854 |
401 | // Emitted when pause guardian is changed | event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);
| event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);
| 9,547 |
5 | // Burns user variable debt- Only callable by the LendingPool user The user whose debt is getting burned amount The amount getting burned index The variable debt index of the reserve / | ) external override onlyLendingPool {
uint256 amountScaled = amount.rayDiv(index);
require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT);
_burn(user, amountScaled);
emit Transfer(user, address(0), amount);
emit Burn(user, amount, index);
}
| ) external override onlyLendingPool {
uint256 amountScaled = amount.rayDiv(index);
require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT);
_burn(user, amountScaled);
emit Transfer(user, address(0), amount);
emit Burn(user, amount, index);
}
| 50,173 |
12 | // Super Token Factory// Get the super token factoryreturn factory The factory / | function getSuperTokenFactory() external view returns (ISuperTokenFactory factory);
| function getSuperTokenFactory() external view returns (ISuperTokenFactory factory);
| 6,098 |
162 | // DataExchange Wibson Development Team <developers@wibson.org> `DataExchange` is the core contract of the Wibson Protocol.This allows the creation, management, and tracking of DataOrders. This contract also contains some helper methods to access the data needed by the different parties involved in the Protocol. / | contract DataExchange is TokenDestructible, Pausable {
using SafeMath for uint256;
using MultiMap for MultiMap.MapStorage;
event NotaryRegistered(address indexed notary);
event NotaryUpdated(address indexed notary);
event NotaryUnregistered(address indexed notary);
event NewOrder(address indexed orderAddr... | contract DataExchange is TokenDestructible, Pausable {
using SafeMath for uint256;
using MultiMap for MultiMap.MapStorage;
event NotaryRegistered(address indexed notary);
event NotaryUpdated(address indexed notary);
event NotaryUnregistered(address indexed notary);
event NewOrder(address indexed orderAddr... | 36,381 |
44 | // This event is fired whenever the owner changes the maximumLockupDurationInBlocks. /newMaximumLockoutDurationInBlocksTo prevent users from accidentally locking up ether for an eternity, the lockout /period of all bounties is capped using this variable, which is inially set to 4 weeks. This is measured in blocks, whic... | event MaximumLockoutDurationInBlocksUpdated(uint256 newMaximumLockoutDurationInBlocks);
| event MaximumLockoutDurationInBlocksUpdated(uint256 newMaximumLockoutDurationInBlocks);
| 43,372 |
467 | // Get the timestamp of the last issue this account made | return flexibleStorage().getUIntValue(CONTRACT_NAME, keccak256(abi.encodePacked(LAST_ISSUE_EVENT, account)));
| return flexibleStorage().getUIntValue(CONTRACT_NAME, keccak256(abi.encodePacked(LAST_ISSUE_EVENT, account)));
| 24,685 |
11 | // Checks ifaccount has the role. / | function isBurner(address account) public view returns (bool) {
return _burners.has(account);
}
| function isBurner(address account) public view returns (bool) {
return _burners.has(account);
}
| 48,197 |
283 | // update the maximum time an option can be created for nMT_ the time (in seconds) of maximum possible bet / | function uMXOT(uint256 nMT_) external tierOneDelegation {
BinaryOptions protocol = BinaryOptions(pA);
protocol.setMaxT(nMT_);
}
| function uMXOT(uint256 nMT_) external tierOneDelegation {
BinaryOptions protocol = BinaryOptions(pA);
protocol.setMaxT(nMT_);
}
| 27,214 |
2 | // anyFRAX -> L1 FRAX Swapout AnySwap Bridge | IAnyswapV5ERC20(address(anyFRAX)).Swapout(token_amount, address_to_send_to);
| IAnyswapV5ERC20(address(anyFRAX)).Swapout(token_amount, address_to_send_to);
| 32,179 |
80 | // claim pending bid rewards only | _accrueRewards(msg.sender, claim);
| _accrueRewards(msg.sender, claim);
| 5,983 |
14 | // Build random card data | bytes32[] memory cards = new bytes32[](10);
for (uint256 i; i < 10; ++i) {
cards[i] = keccak256(abi.encodePacked(user, pack, i));
}
| bytes32[] memory cards = new bytes32[](10);
for (uint256 i; i < 10; ++i) {
cards[i] = keccak256(abi.encodePacked(user, pack, i));
}
| 40,193 |
10 | // if someones sends Ether directly to the contract - fail it! / | function /* fallback */ () public payable {
revert();
}
| function /* fallback */ () public payable {
revert();
}
| 36,206 |
113 | // Timestamp at which the contract was created | uint32 public startTime;
| uint32 public startTime;
| 13,658 |
2 | // if (!halted) throw; | require(halted);
_;
| require(halted);
_;
| 38,998 |
4 | // Handle negative z | if (z < 0) {
responseValue = uint256(100000).sub(responseValue);
}
| if (z < 0) {
responseValue = uint256(100000).sub(responseValue);
}
| 75,508 |
69 | // ! Not need to check state since changes at 02.2018 inState(State.Setup) | onlyOwner
public
| onlyOwner
public
| 78,934 |
144 | // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there will be at least one available slot due to how the memory scratch space works. We can safely overwrite whatever is stored in this slot as we will revert immediately after that. | let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
| let start := sub(tokenAmounts, 0x20)
mstore(start, bptAmount)
| 32,859 |
6 | // Adds an address to the blocklist account The address to addreturn true if the operation succeeded Fails if the address was already blocklisted / | function _addToBlocklist(address account) private onlyNotInBlocklist(account) returns(bool) {
_userIndex[account] = _userList.length;
_userList.push(account);
emit addedToBlocklist(account, msg.sender);
return true;
}
| function _addToBlocklist(address account) private onlyNotInBlocklist(account) returns(bool) {
_userIndex[account] = _userList.length;
_userList.push(account);
emit addedToBlocklist(account, msg.sender);
return true;
}
| 10,863 |
12 | // Calculate and deposit owedToken | uint256 maxHeldTokenFromSell = MathHelpers.maxUint256();
if (!transaction.depositInHeldToken) {
transaction.depositAmount =
getOwedTokenDeposit(transaction, collateralToAdd, orderData);
BorrowShared.doDepositOwedToken(state, transaction);
maxHeldTokenF... | uint256 maxHeldTokenFromSell = MathHelpers.maxUint256();
if (!transaction.depositInHeldToken) {
transaction.depositAmount =
getOwedTokenDeposit(transaction, collateralToAdd, orderData);
BorrowShared.doDepositOwedToken(state, transaction);
maxHeldTokenF... | 52,969 |
2 | // 余额 | mapping(address => uint) balanceOf;
| mapping(address => uint) balanceOf;
| 50,891 |
17 | // looping over the number of items created (if number has not been sold pupulte the array) | MarketToken[] memory items = new MarketToken[](unsoldItemCount);
for(uint i = 0; i < itemCount; i++) {
if(idToMarketToken[i+1].owner == address(0)) {
uint currentId = i + 1;
MarketToken storage currentItem = idToMarketToken[currentId];
... | MarketToken[] memory items = new MarketToken[](unsoldItemCount);
for(uint i = 0; i < itemCount; i++) {
if(idToMarketToken[i+1].owner == address(0)) {
uint currentId = i + 1;
MarketToken storage currentItem = idToMarketToken[currentId];
... | 9,532 |
26 | // the consumer release payment to receiver_paymentId the integer identifier of payment return valid Boolean indication of payment is released/ | function releasePayment(bytes32 _paymentId) public isLocked(_paymentId) isAuthContract() returns (bool) {
// payment must not be paused
require(mPayments[_paymentId].paused == false, 'Payment is paused');
// update state to avoid re-entry attack
mPayments[_paymentId].state = PaymentS... | function releasePayment(bytes32 _paymentId) public isLocked(_paymentId) isAuthContract() returns (bool) {
// payment must not be paused
require(mPayments[_paymentId].paused == false, 'Payment is paused');
// update state to avoid re-entry attack
mPayments[_paymentId].state = PaymentS... | 6,773 |
122 | // set the offer hash as cancelled | _cancelledOrCompletedOffers[_offer_hash]=true;
emit OfferCancelled(_offer_hash);
| _cancelledOrCompletedOffers[_offer_hash]=true;
emit OfferCancelled(_offer_hash);
| 43,563 |
30 | // Allows contract owner to mint new tokens, prevents numerical overflow | function mintToken(address target, uint256 mintedAmount) onlyOwner returns (bool success) {
require(mintedAmount > 0);
uint256 addTokens = mintedAmount;
balance[target] += addTokens;
totalSupply += addTokens;
Transfer(0, target, addTokens);
return true;
}
| function mintToken(address target, uint256 mintedAmount) onlyOwner returns (bool success) {
require(mintedAmount > 0);
uint256 addTokens = mintedAmount;
balance[target] += addTokens;
totalSupply += addTokens;
Transfer(0, target, addTokens);
return true;
}
| 15,980 |
228 | // PUBLIC STATES |
IDfWalletFactory public dfWalletFactory;
uint256 private DELETED_fee; // DELETED state
mapping(address => UserData) public wallets;
|
IDfWalletFactory public dfWalletFactory;
uint256 private DELETED_fee; // DELETED state
mapping(address => UserData) public wallets;
| 30,350 |
154 | // Reentrancy Guard // Prevents a contract from calling itself, directly or indirectly. / | modifier nonReentrant() {
require(_notEntered, "re-entered");
_notEntered = false;
_;
_notEntered = true; // get a gas-refund post-Istanbul
}
| modifier nonReentrant() {
require(_notEntered, "re-entered");
_notEntered = false;
_;
_notEntered = true; // get a gas-refund post-Istanbul
}
| 9,481 |
35 | // / | function getWinner() public onlyContractCreator returns (uint256[]) {
uint i;
//Loop to generate 5 random hero IDs from 55 heroes
for(i=0;i<=4;i++){
//Block timestamp and number used to generate the random number
winners.push(uint256(sha256(block.timestamp, block.number-i-1)) % heroMax);
... | function getWinner() public onlyContractCreator returns (uint256[]) {
uint i;
//Loop to generate 5 random hero IDs from 55 heroes
for(i=0;i<=4;i++){
//Block timestamp and number used to generate the random number
winners.push(uint256(sha256(block.timestamp, block.number-i-1)) % heroMax);
... | 44,192 |
27 | // verify that ETH was passed with the call if needed | verifyEthAmount(reserveToken.isNativeToken() ? amount : 0);
return addBaseTokenLiquidity(owner, poolAnchor, reserveToken, amount);
| verifyEthAmount(reserveToken.isNativeToken() ? amount : 0);
return addBaseTokenLiquidity(owner, poolAnchor, reserveToken, amount);
| 55,788 |
59 | // Set a new metadata renderer/newRenderer new renderer address to use/setupRenderer data to setup new renderer with | function setMetadataRenderer(
IMetadataRenderer newRenderer,
bytes memory setupRenderer
| function setMetadataRenderer(
IMetadataRenderer newRenderer,
bytes memory setupRenderer
| 19,007 |
13 | // Inits the module for a wallet by logging an event.The method can only be called by the wallet itself. _wallet The wallet. / | function init(BaseWallet _wallet) external onlyWallet(_wallet) {
emit ModuleInitialised(_wallet);
}
| function init(BaseWallet _wallet) external onlyWallet(_wallet) {
emit ModuleInitialised(_wallet);
}
| 19,008 |
17 | // Get Matrix Upline Depth/ | function getMatrix() internal view virtual returns (uint8) {
return getSettings().matrix;
}
| function getMatrix() internal view virtual returns (uint8) {
return getSettings().matrix;
}
| 29,261 |
155 | // Minimum between two uint256 numbers | function uint256Min(uint256 a, uint256 b) pure internal returns (uint256) {
return a > b ? b : a;
}
| function uint256Min(uint256 a, uint256 b) pure internal returns (uint256) {
return a > b ? b : a;
}
| 14,485 |
47 | // Upgrade agent interface inspired by Lunyr. Upgrade agent transfers tokens to a new contract.Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting. / | contract UpgradeAgent {
uint public originalSupply;
/** Interface marker */
function isUpgradeAgent() public constant returns (bool) {
return true;
}
function upgradeFrom(address _from, uint256 _value) public;
}
| contract UpgradeAgent {
uint public originalSupply;
/** Interface marker */
function isUpgradeAgent() public constant returns (bool) {
return true;
}
function upgradeFrom(address _from, uint256 _value) public;
}
| 25,630 |
66 | // calculates the amount of ETH belonging to the LP-Pair and converts them to LP | if(tokenForLiquidity>0){
uint liqETH = (newETH*LiqHalf)/swapToken;
_addLiquidity(LiqHalf, liqETH);
}
| if(tokenForLiquidity>0){
uint liqETH = (newETH*LiqHalf)/swapToken;
_addLiquidity(LiqHalf, liqETH);
}
| 43,594 |
77 | // Get asset 0 twapUses Uni V3 oracle, reading the TWAP from twap periodor the earliest oracle observation time if twap period is not set / | function getAsset0Price() public view returns (int128) {
return
UniswapLibrary.getAsset0Price(
uniContracts.pool,
twapPeriod,
token0Decimals,
token1Decimals,
tokenDiffDecimalMultiplier
);
}
| function getAsset0Price() public view returns (int128) {
return
UniswapLibrary.getAsset0Price(
uniContracts.pool,
twapPeriod,
token0Decimals,
token1Decimals,
tokenDiffDecimalMultiplier
);
}
| 81,799 |
45 | // Withdraws bought tokens, or returns commitment if the sale is unsuccessful. | function withdrawTokens() public {
withdrawTokens(msg.sender);
}
| function withdrawTokens() public {
withdrawTokens(msg.sender);
}
| 60,410 |
30 | // They may have been whitelisted to mint 10, but if only 2 remain in supply, then they will only get 2 | _mintAmount(amountMint, _msgSender());
return true;
| _mintAmount(amountMint, _msgSender());
return true;
| 9,877 |
35 | // link group ID ---> Group structure / | mapping (uint => Group) public lockup;
| mapping (uint => Group) public lockup;
| 41,767 |
0 | // Common interface for L1 and L2 Gateway Routers / | interface IGatewayRouter is ITokenGateway {
function defaultGateway() external view returns (address gateway);
event TransferRouted(
address indexed token,
address indexed _userFrom,
address indexed _userTo,
address gateway
);
event GatewaySet(address indexed l1Token, a... | interface IGatewayRouter is ITokenGateway {
function defaultGateway() external view returns (address gateway);
event TransferRouted(
address indexed token,
address indexed _userFrom,
address indexed _userTo,
address gateway
);
event GatewaySet(address indexed l1Token, a... | 22,401 |
109 | // Gets the DMM token for the provided underlying token. For example, sending DAI returns DMM: DAI. / | function getDmmTokenForUnderlying(address underlyingToken) external view returns (address);
| function getDmmTokenForUnderlying(address underlyingToken) external view returns (address);
| 24,724 |
196 | // the total borrows of the reserve at a stable rate. Expressed in the currency decimals | uint256 totalBorrowsStable;
| uint256 totalBorrowsStable;
| 24,249 |
24 | // Optional: A simple email validation function (not suitable for all cases) | function isValidEmail(string memory email) internal pure returns (bool) {
// Perform basic email format check here (e.g., check for '@' symbol and valid domain)
// This example is just for demonstration purposes and is not exhaustive.
bytes memory emailBytes = bytes(email);
bool hasA... | function isValidEmail(string memory email) internal pure returns (bool) {
// Perform basic email format check here (e.g., check for '@' symbol and valid domain)
// This example is just for demonstration purposes and is not exhaustive.
bytes memory emailBytes = bytes(email);
bool hasA... | 22,914 |
16 | // Computes the winning proposal taking all previous votes into account.return winningProposal_ index of winning proposal in the proposals array / | function winningProposal() public view
returns (uint256 winningProposal_)
| function winningProposal() public view
returns (uint256 winningProposal_)
| 37,703 |
13 | // sale in ERC20 | if (sale.tokenWant != address(0)) {
IERC20 tokenWant = IERC20(sale.tokenWant);
require (tokenTotalAmount <= tokenWant.balanceOf(msg.sender), 'Balance of token want too low');
tokenWant.safeTransferFrom(msg.sender, sale.creator, tokenTotalAmount);
} else {
| if (sale.tokenWant != address(0)) {
IERC20 tokenWant = IERC20(sale.tokenWant);
require (tokenTotalAmount <= tokenWant.balanceOf(msg.sender), 'Balance of token want too low');
tokenWant.safeTransferFrom(msg.sender, sale.creator, tokenTotalAmount);
} else {
| 34,323 |
318 | // pool信息 | address pool;
| address pool;
| 7,087 |
6 | // using `new string(len)` would work locally but is not memory safe. | string memory str = new string(32);
| string memory str = new string(32);
| 1,913 |
57 | // ================================================================== operations ================================================================== | function grantRole(bytes32 role, address account)
public
override
onlyOwner
| function grantRole(bytes32 role, address account)
public
override
onlyOwner
| 13,273 |
20 | // Returns the symbol of the token. / | function symbol() external view returns (string memory);
| function symbol() external view returns (string memory);
| 809 |
15 | // Get the denominator This is the denominator used for calculating feesreturn The denominator / | function getDenominator() external pure returns (uint256);
| function getDenominator() external pure returns (uint256);
| 10,982 |
35 | // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); | (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'Helper::transferFrom: transferFrom failed'
);
| (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'Helper::transferFrom: transferFrom failed'
);
| 15,895 |
23 | // Logged when the resolver for a node changes. | event NewResolver(bytes32 indexed node, address resolver);
| event NewResolver(bytes32 indexed node, address resolver);
| 17,243 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.