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
|
---|---|---|---|---|
143 | // Withdraw (for cold storage wallet) a bid that was overbid and platform owner share | function claimByAddress(address _address) public returns (bool) {
return claimInternal(_address);
}
| function claimByAddress(address _address) public returns (bool) {
return claimInternal(_address);
}
| 70,040 |
82 | // Grants `role` to `account`. Internal function without access restriction. / | function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
| function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
| 26,691 |
35 | // Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses: - an externally-owned account- a contract in construction- an address where a contract will be created- an address where a contract lived, but was destroyed==== / | function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
| function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
| 34,521 |
110 | // If no custom keeper requirements are set, just evaluate if sender is a registered keeper | require(_Keep3r.isKeeper(msg.sender), "keep3r::isKeeper:keeper-is-not-registered");
| require(_Keep3r.isKeeper(msg.sender), "keep3r::isKeeper:keeper-is-not-registered");
| 62,975 |
15 | // Withdraws requested amount to borrower's address from lending pool / | function withdrawRequested(uint _marketId)
external
isLoanPeriod(_marketId)
isBorrower(_marketId, msg.sender)
hasNotWithdrawn(_marketId, msg.sender)
| function withdrawRequested(uint _marketId)
external
isLoanPeriod(_marketId)
isBorrower(_marketId, msg.sender)
hasNotWithdrawn(_marketId, msg.sender)
| 9,644 |
62 | // Create a new network.token_ The token to run this network on. organization_ The network technology provider and ecosystem sponsor. / | constructor (address token_, address organization_) public {
token = XBRToken(token_);
organization = organization_;
members[msg.sender] = Member("", "", MemberLevel.VERIFIED);
}
| constructor (address token_, address organization_) public {
token = XBRToken(token_);
organization = organization_;
members[msg.sender] = Member("", "", MemberLevel.VERIFIED);
}
| 23,799 |
24 | // Cleanup stakedAssets for the current tokenId | stakedCreatures[tokenIds[i]] = address(0);
| stakedCreatures[tokenIds[i]] = address(0);
| 5,376 |
61 | // Close the channel. | function close (
uint nonce,
uint256 completed_transfers,
bytes signature
| function close (
uint nonce,
uint256 completed_transfers,
bytes signature
| 43,531 |
28 | // Mint Multiple Open Edition Tokens to the Edition Owner allows the contract owner or additional minter to mint _editionId the ID of the edition to mint a token from _quantity the number of tokens to mint / | function mintMultipleOpenEditionTokens(
uint256 _editionId,
uint256 _quantity,
address _recipient
| function mintMultipleOpenEditionTokens(
uint256 _editionId,
uint256 _quantity,
address _recipient
| 40,221 |
15 | // Minimal vol traded for regular option opens/closes (baseIvskew) | uint minVol;
| uint minVol;
| 15,796 |
13 | // transfer and remove tokens from stake | return Staking._takeStake(tokenID, Template.getCreator(), Template.getCreator(), amountToRemove);
| return Staking._takeStake(tokenID, Template.getCreator(), Template.getCreator(), amountToRemove);
| 33,111 |
24 | // This emits when ownership of any NFT changes by any mechanism. /This event emits when NFTs are created (`from` == 0) and destroyed /(`to` == 0). Exception: during contract creation, any number of NFTs /may be created and assigned without emitting Transfer. At the time of /any transfer, the approved address for that NFT (if any) is reset to none. | event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| 26,337 |
436 | // PaymentSplitter This contract allows to split Ether payments among a group of accounts. The sender does not need to be awarethat the Ether will be split in this way, since it is handled transparently by the contract. The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning eachaccount to a number of shares. Of all the Ether that this contract receives, each account will then be able to claiman amount proportional to the percentage of total shares they were assigned. The distribution of shares is set at thetime of | * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(
IERC20 indexed token,
address to,
uint256 amount
);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(
payees.length == shares_.length,
"PaymentSplitter: payees and shares length mismatch"
);
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
| * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(
IERC20 indexed token,
address to,
uint256 amount
);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(
payees.length == shares_.length,
"PaymentSplitter: payees and shares length mismatch"
);
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
| 24,571 |
653 | // SignedSafeMath Signed math operations with safety checks that revert on error. / | library SignedSafeMath {
int256 constant private _INT256_MIN = -2**255;
/**
* @dev Multiplies two signed integers, reverts on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
}
/**
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
}
/**
* @dev Subtracts two signed integers, reverts on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
}
/**
* @dev Adds two signed integers, reverts on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
}
}
| library SignedSafeMath {
int256 constant private _INT256_MIN = -2**255;
/**
* @dev Multiplies two signed integers, reverts on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
}
/**
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
}
/**
* @dev Subtracts two signed integers, reverts on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
}
/**
* @dev Adds two signed integers, reverts on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
}
}
| 3,954 |
21 | // function to claim multiple channels at a time. Needs to send limited channels per call channelIds list of channel Ids actualAmounts list of actual amounts should be aligned with channel ids index plannedAmounts list of planned amounts should be aligned with channel ids index isSendbacks list of sendbacks flags v channel senders signatures in V R S for each channel r channel senders signatures in V R S for each channel s channel senders signatures in V R S for each channel / | function multiChannelClaim(uint256[] memory channelIds, uint256[] memory actualAmounts, uint256[] memory plannedAmounts, bool[] memory isSendbacks, uint8[] memory v, bytes32[] memory r, bytes32[] memory s)
public
| function multiChannelClaim(uint256[] memory channelIds, uint256[] memory actualAmounts, uint256[] memory plannedAmounts, bool[] memory isSendbacks, uint8[] memory v, bytes32[] memory r, bytes32[] memory s)
public
| 45,685 |
92 | // The parameters representing a shortfall event. indexFraction of inactive funds converted into debt, scaled by SHORTFALL_INDEX_BASE.epochThe epoch in which the shortfall occurred. / | struct Shortfall {
uint16 epoch; // Note: Supports at least 1000 years given min epoch length of 6 days.
uint224 index; // Note: Save on contract bytecode size by reusing uint224 instead of uint240.
}
| struct Shortfall {
uint16 epoch; // Note: Supports at least 1000 years given min epoch length of 6 days.
uint224 index; // Note: Save on contract bytecode size by reusing uint224 instead of uint240.
}
| 29,957 |
1 | // address of Via contracts | address ViaBond;
address ViaCash;
| address ViaBond;
address ViaCash;
| 28,109 |
1 | // Return the latest price for ETH-USD | function getLatestPrice() external view returns (int);
| function getLatestPrice() external view returns (int);
| 55,738 |
15 | // Revert with `Error("TRANSFER_FAILED")` | mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
mstore(96, 0)
revert(0, 100)
| mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
mstore(96, 0)
revert(0, 100)
| 7,926 |
49 | // [{"constant":true,"inputs":[],"name":"ended","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"Vault","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"authIndex","type":"uint256"}],"name":"getAuthorizer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"weiRaised","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"},{"name":"tokens","type":"uint256"}],"name":"authorizedCreateTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_startStop","type":"bool"}],"name":"startTrading","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"keys","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_Vault","type":"address"}],"name":"setVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_rate","type":"uint256"}],"name":"changeRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"minPay","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestruct","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"retrieveTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_minPay","type":"uint256"}],"name":"changeMinPay","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"}],"name":"createTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_addr","type":"address"}],"name":"addAuthorized","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"collect","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closeSale","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_ended","type":"bool"}],"name":"setEnd","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"key","type":"string"}],"name":"register","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"isAuthorized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"recipient","type":"address"},{"indexed":false,"name":"wei_amount","type":"uint256"},{"indexed":false,"name":"token_amount","type":"uint256"},{"indexed":false,"name":"rate","type":"uint256"}],"name":"LogBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"recipient","type":"address"},{"indexed":false,"name":"pay_amount","type":"uint256"}],"name":"LogAuthCreate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"issuedSupply","type":"uint256"},{"indexed":false,"name":"restrictedTokens","type":"uint256"}],"name":"LogSaleClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"key","type":"string"}],"name":"LogRegister","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"LogCollect","type":"event"}] how many token units a buyer gets per ether | uint256 public rate = 10000000000000000000000; // 10k tokens per ether
bool public ended = false;
| uint256 public rate = 10000000000000000000000; // 10k tokens per ether
bool public ended = false;
| 17,514 |
6 | // Changes the address that receives the remaining rip at the end of theclaiming period. Can only be set by the contract owner.remainderDestination_ address to transfer remaining rip to whenclaiming ends. / | function setRemainderDestination(address remainderDestination_) external {
require(msg.sender == owner, 'Airdrop::setRemainderDestination: unauthorized');
remainderDestination = remainderDestination_;
}
| function setRemainderDestination(address remainderDestination_) external {
require(msg.sender == owner, 'Airdrop::setRemainderDestination: unauthorized');
remainderDestination = remainderDestination_;
}
| 13,778 |
182 | // Get burn token amount from fee percentage | burnToken = _amount.multdiv(_fee, BASE);
if (burnToken == 0)
return 0;
| burnToken = _amount.multdiv(_fee, BASE);
if (burnToken == 0)
return 0;
| 6,900 |
195 | // Address of Opium.OracleAggregator contract | address private oracleAggregator;
| address private oracleAggregator;
| 32,160 |
172 | // Claims distributions and allows to specify how many distributions to process.This allows limit gas usage.One can do this for others / | function claimDistributions(address account, uint256 toDistribution) external returns(uint256) {
require(toDistribution <= distributions.length, "DistributionToken: lastDistribution too hight");
require(nextDistributions[account] < toDistribution, "DistributionToken: no distributions to claim");
uint256 amount = _updateUserBalance(account, toDistribution);
if (amount > 0) userBalanceChanged(account);
return amount;
}
| function claimDistributions(address account, uint256 toDistribution) external returns(uint256) {
require(toDistribution <= distributions.length, "DistributionToken: lastDistribution too hight");
require(nextDistributions[account] < toDistribution, "DistributionToken: no distributions to claim");
uint256 amount = _updateUserBalance(account, toDistribution);
if (amount > 0) userBalanceChanged(account);
return amount;
}
| 7,001 |
300 | // Defines the functions used to interact with a yield source.The Prize Pool inherits this contract./Prize Pools subclasses need to implement this interface so that yield can be generated. | abstract contract YieldSource {
/// @notice Determines whether the passed token can be transferred out as an external award.
/// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The
/// prize strategy should not be allowed to move those tokens.
/// @param _externalToken The address of the token to check
/// @return True if the token may be awarded, false otherwise
function _canAwardExternal(address _externalToken) internal virtual view returns (bool);
/// @notice Returns the ERC20 asset token used for deposits.
/// @return The ERC20 asset token
function _token() internal virtual view returns (IERC20Upgradeable);
/// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.
/// @return The underlying balance of asset tokens
function _balance() internal virtual returns (uint256);
/// @notice Supplies asset tokens to the yield source.
/// @param mintAmount The amount of asset tokens to be supplied
function _supply(uint256 mintAmount) internal virtual;
/// @notice Redeems asset tokens from the yield source.
/// @param redeemAmount The amount of yield-bearing tokens to be redeemed
/// @return The actual amount of tokens that were redeemed.
function _redeem(uint256 redeemAmount) internal virtual returns (uint256);
}
| abstract contract YieldSource {
/// @notice Determines whether the passed token can be transferred out as an external award.
/// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The
/// prize strategy should not be allowed to move those tokens.
/// @param _externalToken The address of the token to check
/// @return True if the token may be awarded, false otherwise
function _canAwardExternal(address _externalToken) internal virtual view returns (bool);
/// @notice Returns the ERC20 asset token used for deposits.
/// @return The ERC20 asset token
function _token() internal virtual view returns (IERC20Upgradeable);
/// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.
/// @return The underlying balance of asset tokens
function _balance() internal virtual returns (uint256);
/// @notice Supplies asset tokens to the yield source.
/// @param mintAmount The amount of asset tokens to be supplied
function _supply(uint256 mintAmount) internal virtual;
/// @notice Redeems asset tokens from the yield source.
/// @param redeemAmount The amount of yield-bearing tokens to be redeemed
/// @return The actual amount of tokens that were redeemed.
function _redeem(uint256 redeemAmount) internal virtual returns (uint256);
}
| 16,443 |
9 | // Emitted when a published contract is removed from the public list. | event RemovedContractToPublicList(address indexed publisher, string indexed contractId);
| event RemovedContractToPublicList(address indexed publisher, string indexed contractId);
| 27,716 |
4 | // initialize byte path | path = abi.encodePacked(address(tokenIn));
| path = abi.encodePacked(address(tokenIn));
| 9,226 |
46 | // Replacement for Solidity's `transfer`: sends `amount` wei to`recipient`, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limitimposed by `transfer`, making them unable to receive funds via | * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| 257 |
76 | // Attempt to transfer Ether to the recipient and emit an appropriate event. | ok = _transferETH(recipient, amount);
| ok = _transferETH(recipient, amount);
| 27,883 |
3 | // @inheritdoc IGovernanceLockedRevenueDistributionToken Equivalent to the OpenZeppelin implementation but written in style of ERC20.permit. / | function delegateBySig(address delegatee_, uint256 nonce_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_)
public
virtual
override
| function delegateBySig(address delegatee_, uint256 nonce_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_)
public
virtual
override
| 10,827 |
30 | // verify the inputs | require(_nextId > 0, "zero nextId");
| require(_nextId > 0, "zero nextId");
| 1,699 |
51 | // Emit event to inform a new oracle was registered. | emit OracleRegistered(msg.sender, indexes);
| emit OracleRegistered(msg.sender, indexes);
| 34,962 |
1,464 | // Set in %, defines the MAX deviation per block from the mean rate | uint256 private blockNumberDeviation;
constructor(
address[] memory _listOfToken0,
address[] memory _listOfToken1,
address[] memory _listOfPair,
address _centralizedRateProvider,
uint256 _blockNumberDeviation
) public {
addPair(_listOfToken0, _listOfToken1, _listOfPair);
| uint256 private blockNumberDeviation;
constructor(
address[] memory _listOfToken0,
address[] memory _listOfToken1,
address[] memory _listOfPair,
address _centralizedRateProvider,
uint256 _blockNumberDeviation
) public {
addPair(_listOfToken0, _listOfToken1, _listOfPair);
| 83,285 |
64 | // We write the previously calculated values into storage //We invoke doTransferOut for the borrower and the borrowAmount. Note: The cToken must handle variations between ERC-20 and ETH underlying. On success, the cToken borrowAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. / | doTransferOut(borrower, borrowAmount);
| doTransferOut(borrower, borrowAmount);
| 27,741 |
228 | // Get message hash digest and any additional context from data argument. | bytes32 digest;
bytes memory context;
if (data.length == 32) {
digest = abi.decode(data, (bytes32));
} else {
| bytes32 digest;
bytes memory context;
if (data.length == 32) {
digest = abi.decode(data, (bytes32));
} else {
| 82,634 |
61 | // Just in rare case, owner wants to transfer TRX from contract to owner address | function manualRemove()onlyOwner public{
address(address(uint160(owner))).transfer(address(this).balance);
}
| function manualRemove()onlyOwner public{
address(address(uint160(owner))).transfer(address(this).balance);
}
| 23,023 |
556 | // res += valcoefficients[132]. | res := addmod(res,
mulmod(val, /*coefficients[132]*/ mload(0x1480), PRIME),
PRIME)
| res := addmod(res,
mulmod(val, /*coefficients[132]*/ mload(0x1480), PRIME),
PRIME)
| 19,702 |
18 | // Subtract 256 bit number from 512 bit number. | prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
| prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
| 33,650 |
9 | // The number of reported failures / | function nrFailures() constant returns (uint32) {
return failures;
}
| function nrFailures() constant returns (uint32) {
return failures;
}
| 4,498 |
2 | // using SafeMath for uint256;using SafeERC20 for IERC20; | using Strings for uint256;
using Strings for uint16;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
| using Strings for uint256;
using Strings for uint16;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
| 20,628 |
143 | // remove any tracking | roundFrozen[currencyKey] = 0;
| roundFrozen[currencyKey] = 0;
| 75,834 |
3 | // Check if _asset already exists, add to trackedAssets[] if not | bool isExistsIntrackedAssets = false;
uint256 trackedAssetsLength = trackedAssets.length;
for (uint256 i; i < trackedAssetsLength; i++) {
if (trackedAssets[i] == _asset) {
isExistsIntrackedAssets = true;
break;
}
| bool isExistsIntrackedAssets = false;
uint256 trackedAssetsLength = trackedAssets.length;
for (uint256 i; i < trackedAssetsLength; i++) {
if (trackedAssets[i] == _asset) {
isExistsIntrackedAssets = true;
break;
}
| 15,280 |
15 | // Get the decimals of an assetreturn number of decimals of the asset / | function _getDecimals(address asset) internal view returns (uint256) {
return IERC20Detailed(asset).decimals();
}
| function _getDecimals(address asset) internal view returns (uint256) {
return IERC20Detailed(asset).decimals();
}
| 20,011 |
182 | // Airdrop for Early Pass and Dessert Shop | function airdropEarlyPass(address to, uint256 airdropBalance) public onlyOwner {
require(totalSupply() + airdropBalance <= MAX_SUPPLY, "Airdrop would exceed max supply");
require(earlyPassBalance - airdropBalance >= 0, "No more airdrop quota");
earlyPassBalance -= airdropBalance;
_mintFTB(to, airdropBalance);
}
| function airdropEarlyPass(address to, uint256 airdropBalance) public onlyOwner {
require(totalSupply() + airdropBalance <= MAX_SUPPLY, "Airdrop would exceed max supply");
require(earlyPassBalance - airdropBalance >= 0, "No more airdrop quota");
earlyPassBalance -= airdropBalance;
_mintFTB(to, airdropBalance);
}
| 79,137 |
5 | // Main - Proxy | MainP1 main = MainP1(
address(new ERC1967Proxy(address(implementations.main), new bytes(0)))
);
| MainP1 main = MainP1(
address(new ERC1967Proxy(address(implementations.main), new bytes(0)))
);
| 40,166 |
170 | // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding an 'if' statement (like in _removeTokenFromOwnerEnumeration) | uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
| uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
| 2,243 |
28 | // Transaction tx = transactions[transactionId]; | transactions[transactionId].executed = true;
| transactions[transactionId].executed = true;
| 12,426 |
43 | // transfer assets to user's balance account | Transfer.transferIn(state, asset, BalancePath.getMarketPath(user, marketID), amount);
Requires.requireCashLessThanOrEqualContractBalance(state, asset);
| Transfer.transferIn(state, asset, BalancePath.getMarketPath(user, marketID), amount);
Requires.requireCashLessThanOrEqualContractBalance(state, asset);
| 12,554 |
19 | // encode function that will be called in target chain | bytes memory claimUnlockMethod = _encodeClaimUnlock(_orderId, _beneficiary);
| bytes memory claimUnlockMethod = _encodeClaimUnlock(_orderId, _beneficiary);
| 13,454 |
27 | // Builds base station / | function buildBaseStation(uint256 tokenId) external onlyTokenOwner(tokenId) whenNotPaused {
require(tokenData[tokenId].baseStation == 0, 'There is already a base station');
_deduct(BASE_STATION);
fixEarnings(tokenId);
tokenData[tokenId].baseStation = 1;
emit BuildBaseStation(tokenId, msg.sender);
}
| function buildBaseStation(uint256 tokenId) external onlyTokenOwner(tokenId) whenNotPaused {
require(tokenData[tokenId].baseStation == 0, 'There is already a base station');
_deduct(BASE_STATION);
fixEarnings(tokenId);
tokenData[tokenId].baseStation = 1;
emit BuildBaseStation(tokenId, msg.sender);
}
| 20,348 |
8 | // require(IERC20(usdt).balanceOf(_msgSender()) >=nftPrice[nftType], "Insufficient USDT balance"); require(usdt.approve(address(this), nftPrice[nftType]) == true, "USDT approval failed"); require(getUsdtAllowance(_msgSender()) >=nftPrice[nftType], "USDT allowance is not enough"); |
require(IERC20(usdt).transferFrom(msg.sender, address(this), nftPrice[nftType]), "USDT transfer failed");
return _mintAnElement(msg.sender, nftType, nftTypes[nftType].price);
|
require(IERC20(usdt).transferFrom(msg.sender, address(this), nftPrice[nftType]), "USDT transfer failed");
return _mintAnElement(msg.sender, nftType, nftTypes[nftType].price);
| 1,555 |
133 | // get AccountClassification of an account | function getAccountClassification(
address account
)
internal view returns(AccountClassification)
| function getAccountClassification(
address account
)
internal view returns(AccountClassification)
| 6,973 |
75 | // Gets the token ID at a given index of the tokens list of the requested owner owner address owning the tokens list to be accessed index uint256 representing the index to be accessed of the requested tokens listreturn uint256 token ID at the given index of the tokens list owned by the requested address / | function tokenOfOwnerByIndex(
address owner,
uint256 index
)
public
view
returns (uint256)
| function tokenOfOwnerByIndex(
address owner,
uint256 index
)
public
view
returns (uint256)
| 6,838 |
354 | // Confirm owner has an endpoint | require(
spDetails[msg.sender].numberOfEndpoints > 0,
"ServiceProviderFactory: Registered endpoint required to increase stake"
);
require(
!_claimPending(msg.sender),
"ServiceProviderFactory: No claim expected to be pending prior to stake transfer"
);
Staking stakingContract = Staking(
| require(
spDetails[msg.sender].numberOfEndpoints > 0,
"ServiceProviderFactory: Registered endpoint required to increase stake"
);
require(
!_claimPending(msg.sender),
"ServiceProviderFactory: No claim expected to be pending prior to stake transfer"
);
Staking stakingContract = Staking(
| 7,513 |
49 | // Returns the address of the {IRelayHub} instance this recipient interacts with. / | function getHubAddr() external view returns (address);
| function getHubAddr() external view returns (address);
| 3,606 |
17 | // Constructor of new minter contract newToken Address of the token to mint startBlock Initial lastMint block newAdmin Initial admin address / | constructor(address newToken, uint256 startBlock, address newAdmin){
require(startBlock >= block.number, "SPSMinter: Start block must be above current block");
require(newToken != address(0), 'SPSMinter: Token cannot be address 0');
require(newAdmin != address(0), 'SPSMinter: Admin cannot be address 0');
token = IMintable(newToken);
lastMintBlock = startBlock;
admin = newAdmin;
require(token.decimals() == 18, "SPSMinter: Token doesn't have 18 decimals");
emit UpdateAdmin(address(0), newAdmin);
}
| constructor(address newToken, uint256 startBlock, address newAdmin){
require(startBlock >= block.number, "SPSMinter: Start block must be above current block");
require(newToken != address(0), 'SPSMinter: Token cannot be address 0');
require(newAdmin != address(0), 'SPSMinter: Admin cannot be address 0');
token = IMintable(newToken);
lastMintBlock = startBlock;
admin = newAdmin;
require(token.decimals() == 18, "SPSMinter: Token doesn't have 18 decimals");
emit UpdateAdmin(address(0), newAdmin);
}
| 8,257 |
78 | // transfer to upstream receiverAddress | require(receiverAddress.call.value(weiAmount)
.gas(gasleft().sub(5000))(),
"Error submitting pool to receivingAddress");
| require(receiverAddress.call.value(weiAmount)
.gas(gasleft().sub(5000))(),
"Error submitting pool to receivingAddress");
| 26,053 |
28 | // Initialize the account's collateral tokens. This function should be called in the beginning of every function that accesses accountCollateralTokens or accountTokens. account The account of accountCollateralTokens that needs to be updated / | function initializeAccountCollateralTokens(address account) internal {
/**
* If isCollateralTokenInit is false, it means accountCollateralTokens was not initialized yet.
* This case will only happen once and must be the very beginning. accountCollateralTokens is a new structure and its
* initial value should be equal to accountTokens if user has entered the market. However, it's almost impossible to
* check every user's value when the implementation becomes active. Therefore, it must rely on every action which will
* access accountTokens to call this function to check if accountCollateralTokens needed to be initialized.
*/
if (!isCollateralTokenInit[account]) {
if (ComptrollerInterfaceExtension(address(comptroller)).checkMembership(account, CToken(this))) {
accountCollateralTokens[account] = accountTokens[account];
totalCollateralTokens = add_(totalCollateralTokens, accountTokens[account]);
emit UserCollateralChanged(account, accountCollateralTokens[account]);
}
isCollateralTokenInit[account] = true;
}
}
| function initializeAccountCollateralTokens(address account) internal {
/**
* If isCollateralTokenInit is false, it means accountCollateralTokens was not initialized yet.
* This case will only happen once and must be the very beginning. accountCollateralTokens is a new structure and its
* initial value should be equal to accountTokens if user has entered the market. However, it's almost impossible to
* check every user's value when the implementation becomes active. Therefore, it must rely on every action which will
* access accountTokens to call this function to check if accountCollateralTokens needed to be initialized.
*/
if (!isCollateralTokenInit[account]) {
if (ComptrollerInterfaceExtension(address(comptroller)).checkMembership(account, CToken(this))) {
accountCollateralTokens[account] = accountTokens[account];
totalCollateralTokens = add_(totalCollateralTokens, accountTokens[account]);
emit UserCollateralChanged(account, accountCollateralTokens[account]);
}
isCollateralTokenInit[account] = true;
}
}
| 7,236 |
4 | // get a bounty by index/i the index of bounty/ return the details of bounty | function getBounty(uint i) public view returns(uint ,
string memory,
string memory,
| function getBounty(uint i) public view returns(uint ,
string memory,
string memory,
| 38,920 |
172 | // OWNER ONLY OPERATIONS //Allows owner to change gas cost for boost operation, but only up to 3 millions/_gasCost New gas cost for boost method | function changeBoostGasCost(uint _gasCost) public onlyOwner {
require(_gasCost < 3000000);
BOOST_GAS_COST = _gasCost;
}
| function changeBoostGasCost(uint _gasCost) public onlyOwner {
require(_gasCost < 3000000);
BOOST_GAS_COST = _gasCost;
}
| 16,685 |
558 | // If the search fails and no sample has a timestamp of `lookUpDate` (as is the most common scenario), `sample` will be either the sample with the largest timestamp smaller than `lookUpDate`, or the one with the smallest timestamp larger than `lookUpDate`. | bytes32 sample;
uint256 sampleTimestamp;
while (low <= high) {
| bytes32 sample;
uint256 sampleTimestamp;
while (low <= high) {
| 3,246 |
32 | // return the result of computing the pairing check/ e(p1[0], p2[0]) ....e(p1[n], p2[n]) == 1/ For example pairing([P1(), P1().negate()], [P2(), P2()]) should/ return true. | function pairing(G1Point[] memory p1, G2Point[] memory p2) internal returns (bool) {
require(p1.length == p2.length);
uint elements = p1.length;
uint inputSize = elements * 6;
uint[] memory input = new uint[](inputSize);
for (uint i = 0; i < elements; i++)
{
input[i * 6 + 0] = p1[i].X;
input[i * 6 + 1] = p1[i].Y;
input[i * 6 + 2] = p2[i].X[0];
input[i * 6 + 3] = p2[i].X[1];
input[i * 6 + 4] = p2[i].Y[0];
input[i * 6 + 5] = p2[i].Y[1];
}
uint[1] memory out;
bool success;
assembly {
success := call(sub(gas(), 2000), 8, 0, add(input, 0x20), mul(inputSize, 0x20), out, 0x20)
// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
require(success);
return out[0] != 0;
}
| function pairing(G1Point[] memory p1, G2Point[] memory p2) internal returns (bool) {
require(p1.length == p2.length);
uint elements = p1.length;
uint inputSize = elements * 6;
uint[] memory input = new uint[](inputSize);
for (uint i = 0; i < elements; i++)
{
input[i * 6 + 0] = p1[i].X;
input[i * 6 + 1] = p1[i].Y;
input[i * 6 + 2] = p2[i].X[0];
input[i * 6 + 3] = p2[i].X[1];
input[i * 6 + 4] = p2[i].Y[0];
input[i * 6 + 5] = p2[i].Y[1];
}
uint[1] memory out;
bool success;
assembly {
success := call(sub(gas(), 2000), 8, 0, add(input, 0x20), mul(inputSize, 0x20), out, 0x20)
// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
require(success);
return out[0] != 0;
}
| 6,589 |
0 | // Define events | event ArticleAdded(uint aticleNum);
event ArticleRemoved(uint aticleNum);
event ArticleChallenged(uint aticleNum);
| event ArticleAdded(uint aticleNum);
event ArticleRemoved(uint aticleNum);
event ArticleChallenged(uint aticleNum);
| 31,971 |
48 | // Fallback / | function () public {
revert();
}
| function () public {
revert();
}
| 19,743 |
17 | // owner should be able to close the contract is nobody has been using it for at least 30 days / | contract Mortal is Owned {
/** contract can be closed by the owner anytime after this timestamp if non-zero */
uint public closeAt;
/** the edgeless token contract */
Token edg;
function Mortal(address tokenContract) internal{
edg = Token(tokenContract);
}
/**
* lets the owner close the contract if there are no player funds on it or if nobody has been using it for at least 30 days
*/
function closeContract(uint playerBalance) internal{
if(closeAt == 0) closeAt = now + 30 days;
if(closeAt < now || playerBalance == 0){
edg.transfer(owner, edg.balanceOf(address(this)));
selfdestruct(owner);
}
}
/**
* in case close has been called accidentally.
**/
function open() onlyOwner public{
closeAt = 0;
}
/**
* make sure the contract is not in process of being closed.
**/
modifier isAlive {
require(closeAt == 0);
_;
}
/**
* delays the time of closing.
**/
modifier keepAlive {
if(closeAt > 0) closeAt = now + 30 days;
_;
}
}
| contract Mortal is Owned {
/** contract can be closed by the owner anytime after this timestamp if non-zero */
uint public closeAt;
/** the edgeless token contract */
Token edg;
function Mortal(address tokenContract) internal{
edg = Token(tokenContract);
}
/**
* lets the owner close the contract if there are no player funds on it or if nobody has been using it for at least 30 days
*/
function closeContract(uint playerBalance) internal{
if(closeAt == 0) closeAt = now + 30 days;
if(closeAt < now || playerBalance == 0){
edg.transfer(owner, edg.balanceOf(address(this)));
selfdestruct(owner);
}
}
/**
* in case close has been called accidentally.
**/
function open() onlyOwner public{
closeAt = 0;
}
/**
* make sure the contract is not in process of being closed.
**/
modifier isAlive {
require(closeAt == 0);
_;
}
/**
* delays the time of closing.
**/
modifier keepAlive {
if(closeAt > 0) closeAt = now + 30 days;
_;
}
}
| 23,015 |
151 | // Check whether the amount of token are available to transfer | require(totalSupplyMintTransfer.Add(exhToCredit) <= maxCapMintTransfer);
| require(totalSupplyMintTransfer.Add(exhToCredit) <= maxCapMintTransfer);
| 3,638 |
5 | // How much ether in wei card holds | uint value;
| uint value;
| 34,492 |
186 | // Chain | uint256 private constant CHAIN_ID = 1; // Mainnet
| uint256 private constant CHAIN_ID = 1; // Mainnet
| 9,221 |
118 | // fixed swimming poolmake sure the swimming pool is connected/ | mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address private dev;
address private marketing;
address private adviser;
| mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address private dev;
address private marketing;
address private adviser;
| 46,647 |
102 | // the proof verification has failed, the roll goes to refund | roll.state = State.REFUND;
emit RollRefunded(roll_id);
| roll.state = State.REFUND;
emit RollRefunded(roll_id);
| 19,064 |
32 | // Remove _tokenId from _user's account | function _removeTokenIdFromUser(address _user, uint256 _tokenId) private {
uint256[] storage tokenIds = users[_user].stakedNFTsId;
uint256 length = tokenIds.length;
for (uint256 i = 0; i < length; i++) {
if (_tokenId == tokenIds[i]) {
tokenIds[i] = tokenIds[tokenIds.length - 1];
tokenIds.pop();
return;
}
}
}
| function _removeTokenIdFromUser(address _user, uint256 _tokenId) private {
uint256[] storage tokenIds = users[_user].stakedNFTsId;
uint256 length = tokenIds.length;
for (uint256 i = 0; i < length; i++) {
if (_tokenId == tokenIds[i]) {
tokenIds[i] = tokenIds[tokenIds.length - 1];
tokenIds.pop();
return;
}
}
}
| 2,636 |
104 | // Overrides parent method taking into account variable rate and add bonus for large contributor. _weiAmount The value in wei to be converted into tokensreturn The number of tokens _weiAmount wei will buy at present time / | function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
uint256 currentRate = getCurrentRate();
uint256 tokenAmount = currentRate.mul(_weiAmount);
uint256 largeContribThresholdWeiAmount = largeContribThreshold.mul(1 ether);
if ( _weiAmount >= largeContribThresholdWeiAmount ) {
tokenAmount = tokenAmount.mul(largeContribPercentage).div(100);
}
return tokenAmount;
}
| function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
uint256 currentRate = getCurrentRate();
uint256 tokenAmount = currentRate.mul(_weiAmount);
uint256 largeContribThresholdWeiAmount = largeContribThreshold.mul(1 ether);
if ( _weiAmount >= largeContribThresholdWeiAmount ) {
tokenAmount = tokenAmount.mul(largeContribPercentage).div(100);
}
return tokenAmount;
}
| 32,590 |
10 | // Liquidity generation logic/ Steps - All tokens tat will ever exist go to this contract/ This contract accepts ETH as payable/ ETH is mapped to people/ When liquidity generationevent is over veryone can call/ the LP create function which will put all the ETH and tokens inside the uniswap contract/ without any involvement/ This LP will go into this contract/ And will be able to proportionally be withdrawn baed on ETH put in. |
string public liquidityGenerationParticipationAgreement = "I'm not a resident of the United States \n I understand that this contract is provided with no warranty of any kind. \n I agree to not hold the contract creators, team members or anyone associated with this event liable for any damage monetary and otherwise I might onccur. \n I understand that any smart contract interaction carries an inherent risk.";
|
string public liquidityGenerationParticipationAgreement = "I'm not a resident of the United States \n I understand that this contract is provided with no warranty of any kind. \n I agree to not hold the contract creators, team members or anyone associated with this event liable for any damage monetary and otherwise I might onccur. \n I understand that any smart contract interaction carries an inherent risk.";
| 19,974 |
13 | // if user is a winner, remove his pledge from the losers_pool wtv remains is the pool of losers pledges | if (!curr_user.is_loser) {
winners[num_winners] = working_user_addr;
loser_pool -= curr_user.pledge_amt;
num_winners++;
}
| if (!curr_user.is_loser) {
winners[num_winners] = working_user_addr;
loser_pool -= curr_user.pledge_amt;
num_winners++;
}
| 1,265 |
2 | // | /// type CanonicalBlockID struct {
/// Hash []byte `protobuf:"bytes,1,opt,name=hash`
/// PartSetHeader CanonicalPartSetHeader `protobuf:"bytes,2,opt,name=part_set_header`
/// }
| /// type CanonicalBlockID struct {
/// Hash []byte `protobuf:"bytes,1,opt,name=hash`
/// PartSetHeader CanonicalPartSetHeader `protobuf:"bytes,2,opt,name=part_set_header`
/// }
| 31,312 |
2 | // method auth whitelist management: mapping[methodId][accAddress][bool] | mapping(bytes4 => mapping(address => bool)) private _methodAuthWhiteMap;
| mapping(bytes4 => mapping(address => bool)) private _methodAuthWhiteMap;
| 52,394 |
69 | // any non-zero byte is considered true | function toBoolean(RLPItem memory item) internal pure returns (bool) {
require(item.len == 1);
uint256 result;
uint256 memPtr = item.memPtr;
assembly {
result := byte(0, mload(memPtr))
}
return result == 0 ? false : true;
}
| function toBoolean(RLPItem memory item) internal pure returns (bool) {
require(item.len == 1);
uint256 result;
uint256 memPtr = item.memPtr;
assembly {
result := byte(0, mload(memPtr))
}
return result == 0 ? false : true;
}
| 7,689 |
18 | // grant approval to or revoke approval from given account to spend all tokens held by sender operator address to be approved status approval status / | function setApprovalForAll(address operator, bool status) external;
| function setApprovalForAll(address operator, bool status) external;
| 17,174 |
119 | // supplyDelta = totalSupply(rate - targetRate) / targetRate | int256 targetRateSigned = targetRate.toInt256Safe();
return oms.totalSupply().toInt256Safe()
.mul(rate.toInt256Safe().sub(targetRateSigned))
.div(targetRateSigned);
| int256 targetRateSigned = targetRate.toInt256Safe();
return oms.totalSupply().toInt256Safe()
.mul(rate.toInt256Safe().sub(targetRateSigned))
.div(targetRateSigned);
| 39,828 |
21 | // Perform the EIP-20 transfer in | EIP20Interface token = EIP20Interface(underlying);
require(token.transferFrom(from, address(this), amount), "unexpected EIP-20 transfer in return");
DaiJoinLike daiJoin = DaiJoinLike(daiJoinAddress);
GemLike dai = GemLike(underlying);
PotLike pot = PotLike(potAddress);
VatLike vat = VatLike(vatAddress);
| EIP20Interface token = EIP20Interface(underlying);
require(token.transferFrom(from, address(this), amount), "unexpected EIP-20 transfer in return");
DaiJoinLike daiJoin = DaiJoinLike(daiJoinAddress);
GemLike dai = GemLike(underlying);
PotLike pot = PotLike(potAddress);
VatLike vat = VatLike(vatAddress);
| 51,225 |
76 | // Gets the token symbolreturn string representing the token symbol / | function symbol() public view returns (string) {
return symbol_;
}
| function symbol() public view returns (string) {
return symbol_;
}
| 4,539 |
49 | // ======== INTERNAL/PRIVATE FUNCTIONS ======== // Assigns ownership of a specific token to an address. / | function _transfer(address _from, address _to, uint _tokenId) internal {
// Step 1: Remove token from _form address.
// When creating new token, _from is 0x0.
if (_from != address(0)) {
uint[] storage fromTokens = ownerTokens[_from];
uint tokenIndex = tokenIdToOwnerTokensIndex[_tokenId];
// Put the last token to the transferred token index and update its index in ownerTokensIndexes.
uint lastTokenId = fromTokens[fromTokens.length - 1];
// Do nothing if the transferring token is the last item.
if (_tokenId != lastTokenId) {
fromTokens[tokenIndex] = lastTokenId;
tokenIdToOwnerTokensIndex[lastTokenId] = tokenIndex;
}
fromTokens.length--;
}
// Step 2: Add token to _to address.
// Transfer ownership.
tokenIdToOwner[_tokenId] = _to;
// Add the _tokenId to ownerTokens[_to] and remember the index in ownerTokensIndexes.
tokenIdToOwnerTokensIndex[_tokenId] = ownerTokens[_to].length;
ownerTokens[_to].push(_tokenId);
// Emit the Transfer event.
Transfer(_from, _to, _tokenId);
}
| function _transfer(address _from, address _to, uint _tokenId) internal {
// Step 1: Remove token from _form address.
// When creating new token, _from is 0x0.
if (_from != address(0)) {
uint[] storage fromTokens = ownerTokens[_from];
uint tokenIndex = tokenIdToOwnerTokensIndex[_tokenId];
// Put the last token to the transferred token index and update its index in ownerTokensIndexes.
uint lastTokenId = fromTokens[fromTokens.length - 1];
// Do nothing if the transferring token is the last item.
if (_tokenId != lastTokenId) {
fromTokens[tokenIndex] = lastTokenId;
tokenIdToOwnerTokensIndex[lastTokenId] = tokenIndex;
}
fromTokens.length--;
}
// Step 2: Add token to _to address.
// Transfer ownership.
tokenIdToOwner[_tokenId] = _to;
// Add the _tokenId to ownerTokens[_to] and remember the index in ownerTokensIndexes.
tokenIdToOwnerTokensIndex[_tokenId] = ownerTokens[_to].length;
ownerTokens[_to].push(_tokenId);
// Emit the Transfer event.
Transfer(_from, _to, _tokenId);
}
| 24,014 |
83 | // exclude from fees, wallet limit and transaction limit | excludeFromAllLimits(owner(), true);
excludeFromAllLimits(address(this), true);
excludeFromWalletLimit(uniswapV2Pair, true);
dev = _dev;
deployer = _msgSender();
| excludeFromAllLimits(owner(), true);
excludeFromAllLimits(address(this), true);
excludeFromWalletLimit(uniswapV2Pair, true);
dev = _dev;
deployer = _msgSender();
| 24,829 |
23 | // Confirm that you (the gigCreator) received the item./ This will release the locked ether. | function acceptGig() external onlyGigCreator inState(State.Locked) {
emit ItemReceived();
// It is important to change the state first because
// otherwise, the contracts called using `send` below
// can call in again here.
state = State.Release;
uint256 fee = value / 10;
gigCreator.transfer(value - fee);
// Transfer the fee to the platform's address
payable(platformAddress).transfer(fee);
}
| function acceptGig() external onlyGigCreator inState(State.Locked) {
emit ItemReceived();
// It is important to change the state first because
// otherwise, the contracts called using `send` below
// can call in again here.
state = State.Release;
uint256 fee = value / 10;
gigCreator.transfer(value - fee);
// Transfer the fee to the platform's address
payable(platformAddress).transfer(fee);
}
| 6,734 |
24 | // Add tokens to the transfer address | balanceOf[_to] = safeAdd(balanceOf[_to], _value);
| balanceOf[_to] = safeAdd(balanceOf[_to], _value);
| 20,385 |
10 | // / | bool Withdraw;
| bool Withdraw;
| 8,813 |
18 | // Cut owner takes on each auction, measured in basis points (1/100 of a percent). Values 0-10,000 map to 0%-100% | uint256 public ownerCut;
| uint256 public ownerCut;
| 18,695 |
0 | // Scale for calculations to avoid rounding errors | uint256 private constant SCALE = 1_000_000;
| uint256 private constant SCALE = 1_000_000;
| 8,663 |
3 | // the timestamp of when the vote ends | uint256 public end;
| uint256 public end;
| 17,803 |
10 | // require(msg.value == 0.2 ether, "Participate cost 0.2"); | require(isUserExists(userAddress), "user not exists");
require(isUserExists(referrerAddress), "referrer not exists");
require(lastUserId >=1014, "Less than the minimum amount");
address freeX2Referrer = findFreeX2Referrer(userAddress);
if(users[referrerAddress].activeX2){
users[referrerAddress].partnerActive++;
users[referrerAddress].wallet = SafeMath.add(users[referrerAddress].wallet, 4 * 10 ** 16);
| require(isUserExists(userAddress), "user not exists");
require(isUserExists(referrerAddress), "referrer not exists");
require(lastUserId >=1014, "Less than the minimum amount");
address freeX2Referrer = findFreeX2Referrer(userAddress);
if(users[referrerAddress].activeX2){
users[referrerAddress].partnerActive++;
users[referrerAddress].wallet = SafeMath.add(users[referrerAddress].wallet, 4 * 10 ** 16);
| 15,301 |
2 | // 转账:从自己账户向_to地址转入_value个Token | function transfer(address _to, uint256 _value)public returns (bool success);
| function transfer(address _to, uint256 _value)public returns (bool success);
| 33,923 |
153 | // update the consumed days after we calcuate | totalDaysConsumed += totalDaysHeld;
return returnVal;
| totalDaysConsumed += totalDaysHeld;
return returnVal;
| 28,475 |
0 | // Constructor / Make the admin the owner of the bridge... | transferOwnership(admin);
| transferOwnership(admin);
| 71,438 |
257 | // issuer => holder => bond record | mapping(address => mapping(address => HourlyBond))
public hourlyBondAccounts;
uint256 public borrowingFactorPercent = 200;
function _makeHourlyBond(
address issuer,
address holder,
uint256 amount
| mapping(address => mapping(address => HourlyBond))
public hourlyBondAccounts;
uint256 public borrowingFactorPercent = 200;
function _makeHourlyBond(
address issuer,
address holder,
uint256 amount
| 79,273 |
56 | // Transfers the ownership of a given token ID to another addressUsage of this method is discouraged, use `safeTransferFrom` whenever possibleRequires the msg sender to be the owner, approved, or operator _from current owner of the token _to address to receive the ownership of the given token ID _tokenId uint256 ID of the token to be transferred/ | function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
canTransfer(_tokenId)
| function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
canTransfer(_tokenId)
| 49,484 |
64 | // Set maximum transaction | function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 100000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
| function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 100000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
| 1,893 |
34 | // Claim slot slot Slot index bid Bid amount delegate Delegate for slot / | function claimSlot(
uint8 slot,
uint128 bid,
address delegate
| function claimSlot(
uint8 slot,
uint128 bid,
address delegate
| 37,626 |
124 | // depositeer | mapping (address => bool) public depositeer;
| mapping (address => bool) public depositeer;
| 13,850 |
4 | // Merkle tree created from leaves ['a', 'b', 'c']. Leaf is 'a'. Proof is same as testValidProofSupplied but last byte of first element is modified. | bytes32[] memory proof = new bytes32[](2);
proof[0] = 0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5511;
proof[1] = 0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2;
bytes32 root = 0x5842148bc6ebeb52af882a317c765fccd3ae80589b21a9b8cbf21abb630e46a7;
bytes32 leaf = 0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb;
assertBoolEq(this.verify(proof, root, leaf), false);
| bytes32[] memory proof = new bytes32[](2);
proof[0] = 0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5511;
proof[1] = 0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2;
bytes32 root = 0x5842148bc6ebeb52af882a317c765fccd3ae80589b21a9b8cbf21abb630e46a7;
bytes32 leaf = 0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb;
assertBoolEq(this.verify(proof, root, leaf), false);
| 1,776 |
41 | // min return check | require(receivedYToken >= minReturn, "MIN_RETURN_FAIL");
| require(receivedYToken >= minReturn, "MIN_RETURN_FAIL");
| 17,453 |
Subsets and Splits