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 |
|---|---|---|---|---|
26 | // View function to see pending ROLLs on frontend. | function pendingRoll(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRollPerShare = pool.accRollPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
... | function pendingRoll(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRollPerShare = pool.accRollPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
... | 4,736 |
12 | // Determine if the "_from" address is a contract | function _humanSender(address _from) private view returns (bool) {
uint codeLength;
assembly {
codeLength := extcodesize(_from)
}
return (codeLength == 0); // If this is "true" sender is most likely a Wallet
}
| function _humanSender(address _from) private view returns (bool) {
uint codeLength;
assembly {
codeLength := extcodesize(_from)
}
return (codeLength == 0); // If this is "true" sender is most likely a Wallet
}
| 13,392 |
95 | // Lib_PredeployAddresses / | library Lib_PredeployAddresses {
address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002... | library Lib_PredeployAddresses {
address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002... | 34,429 |
10 | // implementation from https:github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0 original implementation: https:github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.solL687 | function sqrt(uint x) internal pure returns (uint) {
if (x == 0) return 0;
uint xx = x;
uint r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r... | function sqrt(uint x) internal pure returns (uint) {
if (x == 0) return 0;
uint xx = x;
uint r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r... | 9,124 |
26 | // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met require (_value <= _allowance); |
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
|
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
| 5,728 |
10 | // the min nif being staked in the governance required for consumers receiving UNT | uint256 public minNifConsumptionStake = 10 * 10**18; //150000 * 10**18;
| uint256 public minNifConsumptionStake = 10 * 10**18; //150000 * 10**18;
| 10,321 |
8 | // Slightly modified SafeMath library - includes a min and max function, removes useless div function | library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function add(int256 a, int256 b) internal pure returns (int256 c) {
if (b > 0) {
c = a + b;
assert(c >= a);
... | library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function add(int256 a, int256 b) internal pure returns (int256 c) {
if (b > 0) {
c = a + b;
assert(c >= a);
... | 35,980 |
84 | // initialize fixed-length memory arrays | _strategies = new address[](k);
_amounts = new uint256[](k);
address _strategy;
uint256 _balance;
| _strategies = new address[](k);
_amounts = new uint256[](k);
address _strategy;
uint256 _balance;
| 27,586 |
79 | // Protocol control center. | import { ProtocolControl } from "./ProtocolControl.sol";
// Royalties
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";
contract NFTCollection is ERC1155PresetMinterPauserSupplyHolder, ERC2771Context, IERC2981, Multicall {
/// @dev The protocol contro... | import { ProtocolControl } from "./ProtocolControl.sol";
// Royalties
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";
contract NFTCollection is ERC1155PresetMinterPauserSupplyHolder, ERC2771Context, IERC2981, Multicall {
/// @dev The protocol contro... | 2,147 |
55 | // Finding option with most votes | uint256 winningOption = 0;
uint256 maxVotedCount = 0;
for (uint256 i = 0; i < voteCounts.length; i++) {
if (voteCounts[i] > maxVotedCount) {
winningOption = i + 1;
maxVotedCount = voteCounts[i];
} else if (voteCounts[i] == maxVotedCount) {
| uint256 winningOption = 0;
uint256 maxVotedCount = 0;
for (uint256 i = 0; i < voteCounts.length; i++) {
if (voteCounts[i] > maxVotedCount) {
winningOption = i + 1;
maxVotedCount = voteCounts[i];
} else if (voteCounts[i] == maxVotedCount) {
| 33,654 |
4 | // Fallback function | function() external payable {
}
| function() external payable {
}
| 41,216 |
1 | // Decode bytes array | using Bytes for bytes;
| using Bytes for bytes;
| 17,158 |
141 | // Retrieve any shares tokens not accounted for in the cache./to Address of the recipient of the shares tokens./ return retrieved The amount of shares tokens sent. | function retrieveShares(address to) external virtual override returns (uint128 retrieved) {
retrieved = _getSharesBalance() - sharesCached; // Cache can never be above balances
sharesToken.safeTransfer(to, retrieved);
}
| function retrieveShares(address to) external virtual override returns (uint128 retrieved) {
retrieved = _getSharesBalance() - sharesCached; // Cache can never be above balances
sharesToken.safeTransfer(to, retrieved);
}
| 25,447 |
78 | // Allows the proxy owner to upgrade the current version of the proxy and call the new implementationto initialize whatever is needed through a low level call. implementation representing the address of the new implementation to be set. data represents the msg.data to bet sent in the low level call. This parameter may ... | function upgradeToAndCall(address implementation, bytes memory data) payable public onlyProxyOwner {
upgradeTo(implementation);
(bool success, ) = address(this).call{value: msg.value}(data);
require(success);
}
| function upgradeToAndCall(address implementation, bytes memory data) payable public onlyProxyOwner {
upgradeTo(implementation);
(bool success, ) = address(this).call{value: msg.value}(data);
require(success);
}
| 32,091 |
5 | // ERC-20 Transfer event | event Transfer(address indexed from, address indexed to, uint256 tokens);
| event Transfer(address indexed from, address indexed to, uint256 tokens);
| 10,168 |
230 | // MasterChef is the master of Taal. He can make Taal and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once TAL is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's... | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some f... | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some f... | 49,768 |
42 | // join the MEV reward pool once it's deposited to official one. | IRewardPool(rewardPool).joinpool(info.claimAddr, DEPOSIT_SIZE);
| IRewardPool(rewardPool).joinpool(info.claimAddr, DEPOSIT_SIZE);
| 6,866 |
9 | // Set params such that they'll pass `StakingProxy.assertValidStorageParams` | epochDurationInSeconds = 5 days;
cobbDouglasAlphaNumerator = 1;
cobbDouglasAlphaDenominator = 1;
rewardDelegatedStakeWeight = PPM_DENOMINATOR;
minimumPoolStake = 100;
| epochDurationInSeconds = 5 days;
cobbDouglasAlphaNumerator = 1;
cobbDouglasAlphaDenominator = 1;
rewardDelegatedStakeWeight = PPM_DENOMINATOR;
minimumPoolStake = 100;
| 21,660 |
29 | // This event is triggered whenever a call to claim succeeds. | event Claimed(uint256 index, address account, uint256 amount);
| event Claimed(uint256 index, address account, uint256 amount);
| 8,473 |
2 | // toggle instant reveal | bool public instantRevealActive = false;
| bool public instantRevealActive = false;
| 34,060 |
20 | // adding constructor arguments to bytecodetokenName. tokenSymbol. / | function _getERC721Data(string memory tokenName, string memory tokenSymbol, string memory baseUri)
view
internal
returns(bytes memory)
| function _getERC721Data(string memory tokenName, string memory tokenSymbol, string memory baseUri)
view
internal
returns(bytes memory)
| 1,160 |
19 | // validate input | require(bytes(_name).length > 0, "ERR_INVALID_NAME");
require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL");
name = _name;
symbol = _symbol;
decimals = _decimals;
totalSupply = _totalSupply;
balanceOf[msg.sender] = _totalSupply;
| require(bytes(_name).length > 0, "ERR_INVALID_NAME");
require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL");
name = _name;
symbol = _symbol;
decimals = _decimals;
totalSupply = _totalSupply;
balanceOf[msg.sender] = _totalSupply;
| 13,354 |
14 | // 这里不需抛出异常,只需重置未付款 | pendingReturns[msg.sender] = amount;
return false;
| pendingReturns[msg.sender] = amount;
return false;
| 18,232 |
18 | // Various setters/ | function setReservedTokens(uint256 _reservedTokens) external onlyOwner {
reservedTokens = _reservedTokens;
}
| function setReservedTokens(uint256 _reservedTokens) external onlyOwner {
reservedTokens = _reservedTokens;
}
| 79,659 |
71 | // Seed for randomness | uint256 private _seed;
| uint256 private _seed;
| 52,542 |
122 | // is the token balance of this contract address over the min number of tokens that we need to initiate a swap + send lock? also, don't get caught in a circular sending event. also, don't swap & liquify if sender is uniswap pair. | uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
| uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
| 2,107 |
244 | // ICurveStableSwapEurs interface/Enzyme Council <[email protected]> | interface ICurveStableSwapEurs {
function add_liquidity(uint256[2] calldata, uint256) external returns (uint256);
function remove_liquidity(uint256, uint256[2] calldata) external returns (uint256[2] memory);
function remove_liquidity_one_coin(
uint256,
int128,
uint256
) externa... | interface ICurveStableSwapEurs {
function add_liquidity(uint256[2] calldata, uint256) external returns (uint256);
function remove_liquidity(uint256, uint256[2] calldata) external returns (uint256[2] memory);
function remove_liquidity_one_coin(
uint256,
int128,
uint256
) externa... | 20,447 |
229 | // turn on our toggle for harvests | harvestNow = true;
if (!mintReth) {
| harvestNow = true;
if (!mintReth) {
| 3,716 |
332 | // Copy whole words back to front We use a signed comparisson here to allow dEnd to become negative (happens when source and dest < 32). Valid addresses in local memory will never be larger than 2255, so they can be safely re-interpreted as signed. Note: the first check is always true, this could have been a do-while l... | for {} slt(dest, dEnd) {} {
| for {} slt(dest, dEnd) {} {
| 16,107 |
6 | // execute an exact-in flash swap (specify an exact amount to pay) _tokenIn token address to sell _tokenOut token address to receive _fee pool fee _amountIn amount to sell _amountOutMinimum minimum amount to receive _callSource function call source _data arbitrary data assigned with the call/ | function _exactInFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountIn, uint256 _amountOutMinimum, uint8 _callSource, bytes memory _data) internal {
uint256 amountOut = _exactInputInternal(
_amountIn,
address(this),
uint160(0),
SwapCall... | function _exactInFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountIn, uint256 _amountOutMinimum, uint8 _callSource, bytes memory _data) internal {
uint256 amountOut = _exactInputInternal(
_amountIn,
address(this),
uint160(0),
SwapCall... | 43,212 |
51 | // Event to show ownership transfer is pending currentOwner representing the address of the current owner pendingOwner representing the address of the pending owner / | event NewPendingOwner(address currentOwner, address pendingOwner);
| event NewPendingOwner(address currentOwner, address pendingOwner);
| 18,798 |
11 | // buy Usage an open sale, completing the sale and transferring/Usage of the NFT if enough Ether is supplied./_tokenId - ID of token to buy./_mateId - ID of token owned | function buyMating(uint256 _tokenId,uint256 _mateId)
external
onlyOwnerOf(_mateId)
payable
whenNotPaused
returns(uint256 newFishID)
| function buyMating(uint256 _tokenId,uint256 _mateId)
external
onlyOwnerOf(_mateId)
payable
whenNotPaused
returns(uint256 newFishID)
| 23,327 |
77 | // 定義一個事件「建立租約」 在什麼時間建立了租約、租約地址、房東地址、房客數量 | event LeaseContractCreated(
uint256 timestamp,
address newLeaseContractAddress,
address landlord,
uint8 capacity
);
| event LeaseContractCreated(
uint256 timestamp,
address newLeaseContractAddress,
address landlord,
uint8 capacity
);
| 6,607 |
9 | // Set the proxy contract address which will call this contract. Can only beset once during contract initialization. target-Address of proxy contract using this contract. Should only be set once during contract init. / | function setControllerProxy(address target) internal initializer returns (bool) {
_controllerProxy = target;
return true;
}
| function setControllerProxy(address target) internal initializer returns (bool) {
_controllerProxy = target;
return true;
}
| 26,641 |
131 | // Minimum fee to create a token through the factory | uint256 public minimumFee;
uint256 public integratorFeePct;
| uint256 public minimumFee;
uint256 public integratorFeePct;
| 22,575 |
18 | // calculates the amount of credits to be created | uint256 creditBondAmount = _getCreditsAmount(ethAmount);
| uint256 creditBondAmount = _getCreditsAmount(ethAmount);
| 39,969 |
30 | // Helper function to calculate merkle tree interior nodes by sorting and concatenating and hashing a pair of children nodes, left and right.note: EVM scratch space is used to efficiently calculate hashes. _left The left hash. _right The right hash.return parent The parent hash. / | function sortConcatAndHash(bytes32 _left, bytes32 _right) internal pure returns (bytes32 parent) {
// sort sibling hashes as a convention for efficient proof validation
if (_left < _right) {
// efficient hash using EVM scratch space
assembly {
mstore(0x00, _le... | function sortConcatAndHash(bytes32 _left, bytes32 _right) internal pure returns (bytes32 parent) {
// sort sibling hashes as a convention for efficient proof validation
if (_left < _right) {
// efficient hash using EVM scratch space
assembly {
mstore(0x00, _le... | 22,743 |
31 | // Only the user who related with the token allowance can see the allowance value | require(msg.sender == _owner || msg.sender == _spender);
return allowed[_owner][_spender];
| require(msg.sender == _owner || msg.sender == _spender);
return allowed[_owner][_spender];
| 47,481 |
15 | // Coupon payment - a cash amount is paid on every Coupon Payment Date, equal to Denomination times Coupon. | Payment memory payment;
payment.payment_date = currAccrual.coupon_payment_date;
payment.payment_amount = (denomination * accrued_coupon) / (10 ** decimals) / (10 ** decimals); // this is because accrued_coupon is daysIn / totalDays
return payment;
| Payment memory payment;
payment.payment_date = currAccrual.coupon_payment_date;
payment.payment_amount = (denomination * accrued_coupon) / (10 ** decimals) / (10 ** decimals); // this is because accrued_coupon is daysIn / totalDays
return payment;
| 3,677 |
315 | // can be set only once | require(m_funds == address(0));
m_funds = FundsRegistry(_funds);
| require(m_funds == address(0));
m_funds = FundsRegistry(_funds);
| 16,238 |
54 | // Destoys `amount` tokens from `account`, reducing thetotal supply. Emits a `Transfer` event with `to` set to the zero address. Requirements - `account` cannot be the zero address.- `account` must have at least `amount` tokens. / | function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| 16,074 |
45 | // Price is per "token ETH"; tokensPerWeek is in "token wei". | require(weekShares[week].mul(1e18) <= currentPrice * tokensPerWeek, "Oversold");
| require(weekShares[week].mul(1e18) <= currentPrice * tokensPerWeek, "Oversold");
| 11,932 |
2 | // Next 5 lines from https:ethereum.stackexchange.com/a/83577 | if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
| if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
| 20,986 |
5 | // Delete function to be called by authorized issuers owners The owners of the attestations to be deleted collectionIds The collection ids of the attestations to be deleted / | function deleteAttestations(
address[] calldata owners,
uint256[] calldata collectionIds
| function deleteAttestations(
address[] calldata owners,
uint256[] calldata collectionIds
| 25,437 |
120 | // Determine the current price | updatePrices();
| updatePrices();
| 30,446 |
53 | // Burns a specific amount of tokens from the target address and decrements allowancefrom address The address which you want to send tokens fromvalue uint256 The amount of token to be burned/ | function burnFrom(address from, uint256 value) public returns (bool) {
_burnFrom(from, value);
return true;
}
| function burnFrom(address from, uint256 value) public returns (bool) {
_burnFrom(from, value);
return true;
}
| 1,798 |
27 | // sets the amount of tokens to gift threshold _value new value of the amount to gift/ | function setGiftTokenAmount(uint256 _value) {
giftTokenAmount = _value;
}
| function setGiftTokenAmount(uint256 _value) {
giftTokenAmount = _value;
}
| 47,116 |
29 | // Returns the current balance. Ignores COMP that was not liquidated and invested./ | function investedUnderlyingBalance() public view returns (uint256) {
// NOTE: The use of virtual price is okay for appreciating assets inside IDLE,
// but would be wrong and exploitable if funds were lost by IDLE, indicated by
// the virtualPrice being greater than the token price.
if (protected) {
... | function investedUnderlyingBalance() public view returns (uint256) {
// NOTE: The use of virtual price is okay for appreciating assets inside IDLE,
// but would be wrong and exploitable if funds were lost by IDLE, indicated by
// the virtualPrice being greater than the token price.
if (protected) {
... | 44,915 |
3 | // Permite al propietario actual ceder el control del contrato./ | function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
| function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
| 10,891 |
42 | // function to update the freeToUnstakeBalance and totalLockedBalance | function _updateStakeholderBalances(address _stakeholderAddress) private {
// We verify first that the address corresponds to an actual stakeholder
require(
stakeholders[_stakeholderAddress].stakings.length != 0,
"Not a stakeholder!"
);
//use temporary variabl... | function _updateStakeholderBalances(address _stakeholderAddress) private {
// We verify first that the address corresponds to an actual stakeholder
require(
stakeholders[_stakeholderAddress].stakings.length != 0,
"Not a stakeholder!"
);
//use temporary variabl... | 37,516 |
25 | // NFTfiSigningUtils NFTfi Helper contract for NFTfi. This contract manages verifying signatures from off-chain NFTfi orders.Based on the version of this same contract used on NFTfi V1 / | library NFTfiSigningUtils {
/* ********* */
/* FUNCTIONS */
/* ********* */
/**
* @dev This function gets the current chain ID.
*/
function getChainID() public view returns (uint256) {
uint256 id;
// solhint-disable-next-line no-inline-assembly
assembly {
... | library NFTfiSigningUtils {
/* ********* */
/* FUNCTIONS */
/* ********* */
/**
* @dev This function gets the current chain ID.
*/
function getChainID() public view returns (uint256) {
uint256 id;
// solhint-disable-next-line no-inline-assembly
assembly {
... | 40,359 |
48 | // Integer division of two unsigned integers truncating the quotient, reverts on division by zero. / | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, 'SafeMath#div: DIVISION_BY_ZERO');
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, 'SafeMath#div: DIVISION_BY_ZERO');
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 21,138 |
226 | // Decode a `Witnet.CBOR` structure into a native `int128[]` value./_cborValue An instance of `Witnet.CBOR`./ return The value represented by the input, as an `int128[]` value. | function decodeInt128Array(Witnet.CBOR memory _cborValue) external pure returns(int128[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `int128[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
re... | function decodeInt128Array(Witnet.CBOR memory _cborValue) external pure returns(int128[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `int128[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
re... | 19,903 |
5 | // Recovers signer address from a message by using the signaturehash bytes32 message, the hash is the signed message. What is recovered is the signer address.signature bytes signature, the signature is generated using web3.eth.sign()/ | function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
// Divide the signature in r, s and v variables with inline assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(si... | function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
// Divide the signature in r, s and v variables with inline assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(si... | 20,232 |
73 | // EToken2 Asset with manager implementation contract. Manager[s] should be a contract which will implement token movement logic.In case normal users transfers should be restricted, so that only managercan move balances, isTransferAllowed should be set to false. / | contract AssetWithManager is AssetWithAmbi {
bool public isTransferAllowed = true;
event TransferAllowedSet(bool isAllowed);
function isManager(address _caller) public view returns(bool) {
return address(ambi2) != address(0) &&
ambi2.hasRole(address(this), 'manager', _caller);
}
... | contract AssetWithManager is AssetWithAmbi {
bool public isTransferAllowed = true;
event TransferAllowedSet(bool isAllowed);
function isManager(address _caller) public view returns(bool) {
return address(ambi2) != address(0) &&
ambi2.hasRole(address(this), 'manager', _caller);
}
... | 12,892 |
43 | // Function to init balances mapping on token launch / | function initBalances(address[] calldata _accounts, uint64[] calldata _amounts) external onlyOwner {
require(!balancesInitialized);
require(_accounts.length > 0 && _accounts.length == _amounts.length);
uint256 total = 0;
for (uint256 i = 0; i < _amounts.length; i++) total = total.ad... | function initBalances(address[] calldata _accounts, uint64[] calldata _amounts) external onlyOwner {
require(!balancesInitialized);
require(_accounts.length > 0 && _accounts.length == _amounts.length);
uint256 total = 0;
for (uint256 i = 0; i < _amounts.length; i++) total = total.ad... | 61,550 |
9 | // Approves the spender to spend the caller's tokens. _spender The spender address. _value The amount of tokens to approve.return A boolean indicating whether the approval was successful or not. / | function approve(address _spender, uint256 _value) external override returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) external override returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 17,363 |
8 | // Revokes {role} from {account}. If {account} had been granted {role}, emits a {RoleRevoked} event. role - Role to revoke. account - Account to revoke role from.Note: This function can only be called by the admin. / | function revokeRole(bytes32 role, address account) public onlyAdmin {
_revokeRole(role, account);
}
| function revokeRole(bytes32 role, address account) public onlyAdmin {
_revokeRole(role, account);
}
| 35,171 |
1 | // Create a new staking pool. The sender will be the staking pal of this pool./ Note that a staking pal must be payable./rigoblockPoolAddress Adds rigoblock pool to the created staking pool for convenience if non-null./ return poolId The unique pool id generated for this pool. | function createStakingPool(address rigoblockPoolAddress)
external
override
returns (bytes32 poolId)
| function createStakingPool(address rigoblockPoolAddress)
external
override
returns (bytes32 poolId)
| 1,700 |
135 | // A unique identifier for this particular loan, sourced from the continuously increasing parameter totalNumLoans. | uint256 loanId;
| uint256 loanId;
| 10,212 |
31 | // Admin function to withdraw stuck ERC-20 tokens from this contract Withdraws to the `to` address. This contract doesn't use ERC-20 tokens,but this is a failsafe if tokens are sent to it by accident. token The address of the ERC-20 token to withdraw to The address to withdraw tokens to / | function withdrawStuckToken(address token, address to) public onlyOwnerOrAdmin {
_withdrawToken(token, to);
}
| function withdrawStuckToken(address token, address to) public onlyOwnerOrAdmin {
_withdrawToken(token, to);
}
| 26,505 |
4 | // Changes the owner of this contract./ | function changeOwner(address newOwner) public onlyOwner() {
owner = newOwner;
}
| function changeOwner(address newOwner) public onlyOwner() {
owner = newOwner;
}
| 7,037 |
24 | // User featuring the sprite owns its kitty, but hasn't listed the kitty for sale | broughtSprites[spriteId].owner = kittyOwnerNotForSale;
numberOfSpritesOwnedByUser[msg.sender]++;
| broughtSprites[spriteId].owner = kittyOwnerNotForSale;
numberOfSpritesOwnedByUser[msg.sender]++;
| 1,677 |
76 | // / | contract ProxyStorage {
address public owner;
address public pendingOwner;
bool initialized;
BalanceSheet balances_Deprecated;
AllowanceSheet allowances_Deprecated;
uint256 totalSupply_;
bool private paused_Deprecated = false;
address private globalPause_Deprecated;
uint256 publ... | contract ProxyStorage {
address public owner;
address public pendingOwner;
bool initialized;
BalanceSheet balances_Deprecated;
AllowanceSheet allowances_Deprecated;
uint256 totalSupply_;
bool private paused_Deprecated = false;
address private globalPause_Deprecated;
uint256 publ... | 32,553 |
10 | // Returns the defualt royalty recipient and BPS for this contract's NFTs. / | function getDefaultRoyaltyInfo() external view override returns (address, uint16) {
RoyaltyStorage.Data storage data = RoyaltyStorage.royaltyStorage();
return (data.royaltyRecipient, uint16(data.royaltyBps));
}
| function getDefaultRoyaltyInfo() external view override returns (address, uint16) {
RoyaltyStorage.Data storage data = RoyaltyStorage.royaltyStorage();
return (data.royaltyRecipient, uint16(data.royaltyBps));
}
| 955 |
37 | // Will reset job's syncronicity if last reward was more than epoch ago | _updateJobPeriod(_job);
_jobLiquidityCredits[_job] = _jobPeriodCredits[_job];
rewardedAt[_job] += rewardPeriodTime;
_rewarded = true;
| _updateJobPeriod(_job);
_jobLiquidityCredits[_job] = _jobPeriodCredits[_job];
rewardedAt[_job] += rewardPeriodTime;
_rewarded = true;
| 22,724 |
94 | // The prediction is tied if the price change is less than this | uint public constant TIE_PRICE_CHANGE_TOLERANCE = 0.001 * 10 ** 18;
uint public constant FEE_PERCENT_X_100 = 10e2;
| uint public constant TIE_PRICE_CHANGE_TOLERANCE = 0.001 * 10 ** 18;
uint public constant FEE_PERCENT_X_100 = 10e2;
| 8,390 |
1 | // permits of members | mapping(address => mapping(string => bool)) public permits;
| mapping(address => mapping(string => bool)) public permits;
| 25,878 |
45 | // loop assumes that the token address and amount is mapped to the same index in both arrays meaning: the user is sending _amounts[0] of _tokens[0] | for (uint256 i; i < tokensLength; i++) {
address _token = _tokens[i];
uint256 _amount = _amounts[i];
require(_amount > 0, Errors.INVALID_TOKEN_AMOUNT);
require(_token != address(0), Errors.INVALID_TOKEN_ADDRESS);
| for (uint256 i; i < tokensLength; i++) {
address _token = _tokens[i];
uint256 _amount = _amounts[i];
require(_amount > 0, Errors.INVALID_TOKEN_AMOUNT);
require(_token != address(0), Errors.INVALID_TOKEN_ADDRESS);
| 14,271 |
10 | // extract signature parts from coupon | (bytes32 r, bytes32 s, uint8 v) = splitSignature(claimCoupon);
| (bytes32 r, bytes32 s, uint8 v) = splitSignature(claimCoupon);
| 39,575 |
47 | // transfer the fee to teamaddress | require(
token.transfer(teamAddress, fee),
"transfer failed"
);
| require(
token.transfer(teamAddress, fee),
"transfer failed"
);
| 8,536 |
617 | // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); | bytes32 private constant PERMIT_SIGNATURE_HASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
| bytes32 private constant PERMIT_SIGNATURE_HASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
| 38,503 |
92 | // Leaves the contract without owner. It will not be possible to call`onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner,thereby removing any functionality that is only available to the owner. / | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| 67 |
2 | // The expected owner of adopted pet is this contract | address expectedAdopter = address(this);
| address expectedAdopter = address(this);
| 33,197 |
60 | // Set 'contract address', called from constructor whitelistedPTokenEmissionContract: whitelistedPTokenEmission contract address | * Emits a {SetWhitelistedPTokenEmissionContract} event with '_contract' set to the WhitelistedPTokenEmission contract address.
*
*/
function setWhitelistedPTokenEmissionContract(
address whitelistedPTokenEmissionContract
) public virtual override {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "ST11");... | * Emits a {SetWhitelistedPTokenEmissionContract} event with '_contract' set to the WhitelistedPTokenEmission contract address.
*
*/
function setWhitelistedPTokenEmissionContract(
address whitelistedPTokenEmissionContract
) public virtual override {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "ST11");... | 14,167 |
8 | // User is struct which holds all the details for a particular user creating a CV on Blockvitae | struct UserMain {
UserDetail personal; // personal details of the user
UserSocial social; // social details of the user
UserWorkExp[] work; // work experience of the user
UserEducation[] education; // education of the user
UserProject[] projects; // projects of the user
... | struct UserMain {
UserDetail personal; // personal details of the user
UserSocial social; // social details of the user
UserWorkExp[] work; // work experience of the user
UserEducation[] education; // education of the user
UserProject[] projects; // projects of the user
... | 6,726 |
1 | // The number of leaves per node | uint8 internal constant LEAVES_PER_NODE = 5;
| uint8 internal constant LEAVES_PER_NODE = 5;
| 6,237 |
8 | // pure不能读写变量, 即不可以涉及到合约的成员变量和成员函数 | function f4() pure public returns(uint){
//return v1;//error
//f2(); //error
//return 1; //ok
}
| function f4() pure public returns(uint){
//return v1;//error
//f2(); //error
//return 1; //ok
}
| 47,412 |
34 | // AMM's net positions are the inverse of the user's net position | pricing.postTradeAmmNetStdVega = -globalCache.netStdVega;
pricing.callDelta = pricesDeltaStdVega.callDelta;
emit ListingGreeksUpdated(
listingCache.id,
pricesDeltaStdVega.callDelta,
pricesDeltaStdVega.putDelta,
pricesDeltaStdVega.stdVega,
greekCacheGlobals.spotPrice,
boa... | pricing.postTradeAmmNetStdVega = -globalCache.netStdVega;
pricing.callDelta = pricesDeltaStdVega.callDelta;
emit ListingGreeksUpdated(
listingCache.id,
pricesDeltaStdVega.callDelta,
pricesDeltaStdVega.putDelta,
pricesDeltaStdVega.stdVega,
greekCacheGlobals.spotPrice,
boa... | 16,571 |
77 | // Returns the current implementation. | * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360... | * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360... | 5,858 |
353 | // Get component price from price oracle. If price does not exist, revert. | uint256 componentPrice = priceOracle.getPrice(_component, masterQuoteAsset);
if (masterQuoteAsset != _quoteAsset) {
uint256 quoteToMaster = priceOracle.getPrice(_quoteAsset, masterQuoteAsset);
componentPrice = componentPrice.preciseDiv(quoteToMaster);
}
| uint256 componentPrice = priceOracle.getPrice(_component, masterQuoteAsset);
if (masterQuoteAsset != _quoteAsset) {
uint256 quoteToMaster = priceOracle.getPrice(_quoteAsset, masterQuoteAsset);
componentPrice = componentPrice.preciseDiv(quoteToMaster);
}
| 18,355 |
24 | // Moves `amount` of tokens from `from` to `to`. | * This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a bal... | * This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a bal... | 1,782 |
359 | // max number of paid contributions to the pode sale | uint256 public constant maxPodeContributionTokens = 500;
constructor(
address payable _fundsMultisig,
uint256 _podeStartTimestamp,
uint256 _podeEndTimestamp,
uint256 _podeLockTimestamp,
string memory _tokenURI
| uint256 public constant maxPodeContributionTokens = 500;
constructor(
address payable _fundsMultisig,
uint256 _podeStartTimestamp,
uint256 _podeEndTimestamp,
uint256 _podeLockTimestamp,
string memory _tokenURI
| 2,841 |
202 | // A map from an account to a token to the forced withdrawal (always full balance) The `uint16' represents ERC20 token ID (if < NFT_TOKEN_ID_START) or NFT balance slot (if >= NFT_TOKEN_ID_START) | mapping (uint32 => mapping (uint16 => ForcedWithdrawal)) pendingForcedWithdrawals;
| mapping (uint32 => mapping (uint16 => ForcedWithdrawal)) pendingForcedWithdrawals;
| 54,541 |
2 | // Only MINTER_ROLE holders can sign off on `MintRequest`s and lazy mint tokens. | bytes32 private minterRole;
| bytes32 private minterRole;
| 22,598 |
24 | // has to be the creator or someone with the password | require(msg.sender == creator || hash_pwd == keccak256(_password));
require(sale == 0x0);
require(!bought_tokens);
sale = _sale;
| require(msg.sender == creator || hash_pwd == keccak256(_password));
require(sale == 0x0);
require(!bought_tokens);
sale = _sale;
| 6,718 |
478 | // the next request count to be used in generating a nonce starts at 1 in order to ensure consistent gas costreturn returns the next request count to be used in a nonce / | function getNextRequestCount() internal view returns (uint256) {
return s_requestCount;
}
| function getNextRequestCount() internal view returns (uint256) {
return s_requestCount;
}
| 72,396 |
209 | // https:docs.synthetix.io/contracts/source/contracts/eternalstorage/This contract is based on the code available from this blogImplements support for storing a keccak256 key and value pairs. It is the more flexibleand extensible option. This ensures data schema changes can be implemented withoutrequiring upgrades to t... | contract EternalStorage is Owned, State {
constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}
/* ========== DATA TYPES ========== */
mapping(bytes32 => uint) internal UIntStorage;
mapping(bytes32 => string) internal StringStorage;
mapping(byte... | contract EternalStorage is Owned, State {
constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}
/* ========== DATA TYPES ========== */
mapping(bytes32 => uint) internal UIntStorage;
mapping(bytes32 => string) internal StringStorage;
mapping(byte... | 20,643 |
18 | // External function to update the parameters of the interest rate model baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18). For DAI, this is calculated from DSR and SF. Input not used. gapPerYear The Additional margin per year separating the base borrow rate from the roof. (scaled by 1e18)... | function updateJumpRateModel(uint baseRatePerYear, uint gapPerYear, uint jumpMultiplierPerYear, uint kink_) external override {
require(msg.sender == owner, "only the owner may call this function.");
gapPerBlock = gapPerYear / blocksPerYear;
updateJumpRateModelInternal(0, 0, jumpMultiplierPe... | function updateJumpRateModel(uint baseRatePerYear, uint gapPerYear, uint jumpMultiplierPerYear, uint kink_) external override {
require(msg.sender == owner, "only the owner may call this function.");
gapPerBlock = gapPerYear / blocksPerYear;
updateJumpRateModelInternal(0, 0, jumpMultiplierPe... | 58,172 |
56 | // and check if the offer is sucessful after this sale @WARNING add logic to only set success based on something our clients want | if (!bSuccess) {
bSuccess = true;
}
| if (!bSuccess) {
bSuccess = true;
}
| 7,729 |
12 | // Returns whether the wearable can be minted._collectionAddress - collectionn address_optionId - item option id return whether a wearable can be minted/ | function canMint(address _collectionAddress, uint256 _optionId, uint256 _amount) public view returns (bool) {
CollectionData storage collection = collectionsData[_collectionAddress];
return collection.availableQtyPerOptionId[_optionId] >= _amount;
}
| function canMint(address _collectionAddress, uint256 _optionId, uint256 _amount) public view returns (bool) {
CollectionData storage collection = collectionsData[_collectionAddress];
return collection.availableQtyPerOptionId[_optionId] >= _amount;
}
| 61,925 |
69 | // Queues an update to a validator group's commission.If there was a previously scheduled update, that is overwritten. commission Fixidity representation of the commission this group receives on epochpayments made to its members. Must be in the range [0, 1.0]. / | function setNextCommissionUpdate(uint256 commission) external {
address account = getAccounts().validatorSignerToAccount(msg.sender);
require(isValidatorGroup(account), "Not a validator group");
ValidatorGroup storage group = groups[account];
require(commission <= FixidityLib.fixed1().unwrap(), "Commi... | function setNextCommissionUpdate(uint256 commission) external {
address account = getAccounts().validatorSignerToAccount(msg.sender);
require(isValidatorGroup(account), "Not a validator group");
ValidatorGroup storage group = groups[account];
require(commission <= FixidityLib.fixed1().unwrap(), "Commi... | 23,640 |
1 | // This is the interface that {BeaconProxy} expects of its beacon./ Must return an address that can be used as a delegate call target. {BeaconProxy} will check that this address is a contract. / | function implementation() external view returns (address);
| function implementation() external view returns (address);
| 23,735 |
9 | // ReimburseTFUEL > 0 if tokenRequest > tokenAllowed | uint256 reimburseTFUEL;
if (tokenQuantityRequest > tokenQuantityAllowed) {
reimburseTFUEL = (tokenQuantityRequest.sub(tokenQuantityAllowed))
.div(rate);
tokenQuantityRequest = tokenQuantityAllowed;
}
| uint256 reimburseTFUEL;
if (tokenQuantityRequest > tokenQuantityAllowed) {
reimburseTFUEL = (tokenQuantityRequest.sub(tokenQuantityAllowed))
.div(rate);
tokenQuantityRequest = tokenQuantityAllowed;
}
| 12,523 |
4 | // Mints Crypto DRMS Token Assets/ | function mintToken(string memory metadataURI) public payable {
require(totalSupply().add(1) <= MAX_TOKENS, "Purchase would exceed max supply of Tokens");
require(tokenPrice.mul(1) <= msg.value, "Ether value sent is not correct");
uint mintIndex = totalSupply();
if (totalSup... | function mintToken(string memory metadataURI) public payable {
require(totalSupply().add(1) <= MAX_TOKENS, "Purchase would exceed max supply of Tokens");
require(tokenPrice.mul(1) <= msg.value, "Ether value sent is not correct");
uint mintIndex = totalSupply();
if (totalSup... | 41,120 |
101 | // Must match BConst.MIN_BOUND_TOKENS and BConst.MAX_BOUND_TOKENS | uint256 public constant MIN_ASSET_LIMIT = 2;
uint256 public constant MAX_ASSET_LIMIT = 8;
uint256 public constant MAX_UINT = uint256(-1);
| uint256 public constant MIN_ASSET_LIMIT = 2;
uint256 public constant MAX_ASSET_LIMIT = 8;
uint256 public constant MAX_UINT = uint256(-1);
| 6,300 |
89 | // Mapping from address of a person who bought some tokens during "reserve"stage to information about how many tokens he bought to how much etherinvested. / | mapping (address => Investor) internal investors;
| mapping (address => Investor) internal investors;
| 45,120 |
73 | // Set the signer's active status to true. | _signers[signer] = true;
| _signers[signer] = true;
| 38,947 |
113 | // otherwise return Pending | return LoanStatus.Pending;
| return LoanStatus.Pending;
| 11,380 |
106 | // addresses of time-locked founder vaults | address [4] public timeLockAddresses;
| address [4] public timeLockAddresses;
| 50,431 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.