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 |
|---|---|---|---|---|
39 | // Emit the transfer event. | Transfer(_from, _to, _tokenId);
| Transfer(_from, _to, _tokenId);
| 20,873 |
62 | // Gets the list of guaridans for a wallet. _wallet The target wallet.return the list of guardians. / | function getGuardians(BaseWallet _wallet) external view returns (address[] memory) {
GuardianStorageConfig storage config = configs[address(_wallet)]; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC
address[] memory guardians = new address[](config.guardians.length);
for (uint256 i = 0; i < config.guardians.length; i++) {
guardians[i] = config.guardians[i];
}
return guardians;
}
| function getGuardians(BaseWallet _wallet) external view returns (address[] memory) {
GuardianStorageConfig storage config = configs[address(_wallet)]; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC
address[] memory guardians = new address[](config.guardians.length);
for (uint256 i = 0; i < config.guardians.length; i++) {
guardians[i] = config.guardians[i];
}
return guardians;
}
| 29,151 |
49 | // array for list of holders accounts (including even inactive holders) | address[] public holders;
| address[] public holders;
| 46,079 |
16 | // set highest index (latest) yes vote - must be processed for member to ragequit | if (proposalIndex > member.highestIndexYesVote) {
member.highestIndexYesVote = proposalIndex;
}
| if (proposalIndex > member.highestIndexYesVote) {
member.highestIndexYesVote = proposalIndex;
}
| 20,339 |
7 | // @inheritdoc IVaultRegistry | function isAuthorized(uint256 tokenId, address user) external view returns (bool) {
return _isApprovedOrOwner(user, tokenId);
}
| function isAuthorized(uint256 tokenId, address user) external view returns (bool) {
return _isApprovedOrOwner(user, tokenId);
}
| 21,883 |
8 | // Configure time to enable redeem functionality _windowOpen UNIX timestamp for redeem start/ | function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
| function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
| 80,699 |
35 | // Read functions |
function getTileHp(uint16 battleboardId, uint8 tileId) constant external returns (uint32) ;
function getMedalsBurned(uint16 battleboardId) constant external returns (uint8) ;
function getTeam(uint16 battleboardId, uint8 tileId) constant external returns (uint8) ;
function getMaxFreeTeams() constant public returns (uint8);
function getBarrierNum(uint16 battleboardId) public constant returns (uint8) ;
function getTileFromBattleboard(uint16 battleboardId, uint8 tileId) public constant returns (uint8 tileType, uint8 value, uint8 id, uint8 position, uint32 hp, uint16 petPower, uint64 angelId, uint64 petId, bool isLive, address owner) ;
function getTileIDByOwner(uint16 battleboardId, address _owner) constant public returns (uint8) ;
function getPetbyTileId( uint16 battleboardId, uint8 tileId) constant public returns (uint64) ;
function getOwner (uint16 battleboardId, uint8 team, uint8 ownerNumber) constant external returns (address);
|
function getTileHp(uint16 battleboardId, uint8 tileId) constant external returns (uint32) ;
function getMedalsBurned(uint16 battleboardId) constant external returns (uint8) ;
function getTeam(uint16 battleboardId, uint8 tileId) constant external returns (uint8) ;
function getMaxFreeTeams() constant public returns (uint8);
function getBarrierNum(uint16 battleboardId) public constant returns (uint8) ;
function getTileFromBattleboard(uint16 battleboardId, uint8 tileId) public constant returns (uint8 tileType, uint8 value, uint8 id, uint8 position, uint32 hp, uint16 petPower, uint64 angelId, uint64 petId, bool isLive, address owner) ;
function getTileIDByOwner(uint16 battleboardId, address _owner) constant public returns (uint8) ;
function getPetbyTileId( uint16 battleboardId, uint8 tileId) constant public returns (uint64) ;
function getOwner (uint16 battleboardId, uint8 team, uint8 ownerNumber) constant external returns (address);
| 26,442 |
291 | // ========== STRUCTS ========== / Struct for the stake | struct LockedStake {
bytes32 kek_id;
uint256 start_timestamp;
uint256 liquidity;
uint256 ending_timestamp;
uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000
}
| struct LockedStake {
bytes32 kek_id;
uint256 start_timestamp;
uint256 liquidity;
uint256 ending_timestamp;
uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000
}
| 11,706 |
16 | // State channel update function | function update(
uint[3] sig,
int r,
int[2] _credits,
uint[2] _withdrawals,
bytes32 _hash,
uint _expiry,
uint _amount) public onlyplayers
| function update(
uint[3] sig,
int r,
int[2] _credits,
uint[2] _withdrawals,
bytes32 _hash,
uint _expiry,
uint _amount) public onlyplayers
| 43,975 |
267 | // We move the last address into the affected account spot. | newExchanges[i] = newExchanges[newExchanges.length - 1];
| newExchanges[i] = newExchanges[newExchanges.length - 1];
| 26,674 |
85 | // Roles Library for managing addresses assigned to a Role. / | library Roles {
struct Role {
mapping(address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account)
internal
view
returns (bool)
{
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
| library Roles {
struct Role {
mapping(address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account)
internal
view
returns (bool)
{
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
| 34,624 |
90 | // clear proposed values | proposedArtistAddressesAndSplitsHash[_projectId] = bytes32(0);
| proposedArtistAddressesAndSplitsHash[_projectId] = bytes32(0);
| 33,330 |
142 | // See {IERC721Metadata-symbol}. / | function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| 843 |
33 | // Model for responses from oracles | struct ResponseInfo {
address requester; // Account that requested status
bool isOpen; // If open, oracle responses are accepted
mapping(uint8 => address[]) responses; // Mapping key is the status code reported
// This lets us group responses and identify
// the response that majority of the oracles
}
| struct ResponseInfo {
address requester; // Account that requested status
bool isOpen; // If open, oracle responses are accepted
mapping(uint8 => address[]) responses; // Mapping key is the status code reported
// This lets us group responses and identify
// the response that majority of the oracles
}
| 39,013 |
0 | // Deploys new Bonds.Creating a Bond involves the two steps of deploying and initialising. / | interface BondCreator {
event CreateBond(
address indexed bond,
string name,
string debtSymbol,
uint256 debtAmount,
address indexed creator,
address treasury,
uint256 expiryTimestamp,
uint256 minimumDeposit,
string data
);
/**
* @notice Deploys and initialises a new Bond.
*
* @param name Description of the purpose of the Bond.
* @param symbol Abbreviation to identify the Bond.
* @param debtTokens Number of tokens to create, which get swapped for collateral tokens by depositing.
* @param collateralTokenSymbol Abbreviation of the collateral token that are swapped for debt tokens in deposit.
* @param expiryTimestamp Unix timestamp for when the Bond is expired and anyone can move the remaining collateral
* to the Treasury, then petition for redemption.
* @param minimumDeposit Minimum debt holding allowed in the deposit phase. Once the minimum is met,
* any sized deposit from that account is allowed, as the minimum has already been met.
* @param data Metadata not required for the operation of the Bond, but needed by external actors.
*/
function createBond(
string calldata name,
string calldata symbol,
uint256 debtTokens,
string calldata collateralTokenSymbol,
uint256 expiryTimestamp,
uint256 minimumDeposit,
string calldata data
) external returns (address);
}
| interface BondCreator {
event CreateBond(
address indexed bond,
string name,
string debtSymbol,
uint256 debtAmount,
address indexed creator,
address treasury,
uint256 expiryTimestamp,
uint256 minimumDeposit,
string data
);
/**
* @notice Deploys and initialises a new Bond.
*
* @param name Description of the purpose of the Bond.
* @param symbol Abbreviation to identify the Bond.
* @param debtTokens Number of tokens to create, which get swapped for collateral tokens by depositing.
* @param collateralTokenSymbol Abbreviation of the collateral token that are swapped for debt tokens in deposit.
* @param expiryTimestamp Unix timestamp for when the Bond is expired and anyone can move the remaining collateral
* to the Treasury, then petition for redemption.
* @param minimumDeposit Minimum debt holding allowed in the deposit phase. Once the minimum is met,
* any sized deposit from that account is allowed, as the minimum has already been met.
* @param data Metadata not required for the operation of the Bond, but needed by external actors.
*/
function createBond(
string calldata name,
string calldata symbol,
uint256 debtTokens,
string calldata collateralTokenSymbol,
uint256 expiryTimestamp,
uint256 minimumDeposit,
string calldata data
) external returns (address);
}
| 26,218 |
9 | // Change the MNLTH address contract | function setMnlthAddress(address newAddress) public onlyOwner {
mnlthAddress = newAddress;
}
| function setMnlthAddress(address newAddress) public onlyOwner {
mnlthAddress = newAddress;
}
| 11,873 |
12 | // Fills in FullTokenBalance struct with final underlying components. tokenBalance TokenBalance struct consisting oftoken address and its absolute amount.return Final full absolute token amount by token address and absolute amount. / | function getFinalFullTokenBalance(TokenBalance memory tokenBalance)
internal
returns (FullTokenBalance memory)
| function getFinalFullTokenBalance(TokenBalance memory tokenBalance)
internal
returns (FullTokenBalance memory)
| 12,794 |
31 | // Calculate the fee amount based on the target amount and the platform fee. | uint256 currentFeeAmount = getFeeAmount(order);
| uint256 currentFeeAmount = getFeeAmount(order);
| 48,411 |
37 | // 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 limit imposed 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");
}
| 3,346 |
67 | // If `account` had not been already granted `role`, emits a {RoleGranted}event. Note that unlike {grantRole}, this function doesn't perform anychecks on the calling account. [WARNING]====This function should only be called from the constructor when settingup the initial roles for the system. Using this function in any other way is effectively circumventing the adminsystem imposed by {AccessControl}.==== / | function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
| function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
| 28,140 |
7 | // Live timestamp | uint256 public liveAt;
| uint256 public liveAt;
| 11,857 |
3 | // Sets rent prices. _rentPrices The price array. Each element corresponds to a specific name length; names longer than the length of the array default to the price of the last element. Values are in base price units per second, equal to one wei (1e-18 ETH) each. / | function setPrices(uint[] memory _rentPrices) public onlyOwner {
rentPrices = _rentPrices;
emit RentPriceChanged(_rentPrices);
}
| function setPrices(uint[] memory _rentPrices) public onlyOwner {
rentPrices = _rentPrices;
emit RentPriceChanged(_rentPrices);
}
| 42,046 |
19 | // exclude owner and this contract from max hold limit | isExcludedFromMaxHolding[owner()] = true;
isExcludedFromMaxHolding[address(this)] = true;
isExcludedFromMaxHolding[marketingWallet] = true;
emit Transfer(address(0), owner(), _totalSupply);
| isExcludedFromMaxHolding[owner()] = true;
isExcludedFromMaxHolding[address(this)] = true;
isExcludedFromMaxHolding[marketingWallet] = true;
emit Transfer(address(0), owner(), _totalSupply);
| 18,036 |
6 | // add to registry and posts arr | postRegistry[bzzHash] = newPost;
posts.length = posts.push(bzzHash);
LogPostPublished(id);
return (true, id);
| postRegistry[bzzHash] = newPost;
posts.length = posts.push(bzzHash);
LogPostPublished(id);
return (true, id);
| 22,023 |
9 | // _balanceOf[_from] -= _value; | _balanceOf[_from] = sub(_balanceOf[_from],_value);
| _balanceOf[_from] = sub(_balanceOf[_from],_value);
| 32,679 |
15 | // メンバーを追加する。 正しくないdaoAddressにてコールした場合に対処するために、NFTのAddressをチェックする。/ | function addMember(address eoa, string memory name, address daoERC721Address,uint256 tokenId) public onlyMember {
require(erc721Address==daoERC721Address,"NFT address isn't correct.");
memberInfoes[eoa] = MemberInfo(name,tokenId,_memberIdTracker.current());
memberIds[_memberIdTracker.current()] = eoa;
emit MemberAdded(eoa,_memberIdTracker.current());
_memberIdTracker.increment();
}
| function addMember(address eoa, string memory name, address daoERC721Address,uint256 tokenId) public onlyMember {
require(erc721Address==daoERC721Address,"NFT address isn't correct.");
memberInfoes[eoa] = MemberInfo(name,tokenId,_memberIdTracker.current());
memberIds[_memberIdTracker.current()] = eoa;
emit MemberAdded(eoa,_memberIdTracker.current());
_memberIdTracker.increment();
}
| 2,961 |
37 | // User transfer permission / | function allowance(
address owner,
address spender
)
public
constant
returns (uint remaining)
| function allowance(
address owner,
address spender
)
public
constant
returns (uint remaining)
| 22,332 |
1 | // +----oOO-{_}-OOo----+ | constructor() ERC721Creator("Ashes2ArtContract", "A2AC") {}
| constructor() ERC721Creator("Ashes2ArtContract", "A2AC") {}
| 26,766 |
127 | // Emit an event to validate that the nonce is no longer valid. | emit CANCEL692(nonceToCancel);
| emit CANCEL692(nonceToCancel);
| 27,292 |
8 | // Make `Authority` point to another history contract./_history The new history contract/Emits a `NewHistory` event./Can only be called by the `Authority` owner. | function setHistory(IHistory _history) external onlyOwner {
history = _history;
emit NewHistory(_history);
}
| function setHistory(IHistory _history) external onlyOwner {
history = _history;
emit NewHistory(_history);
}
| 8,935 |
7 | // swap on uniswapV3 using 1inch API | function swapOneInchUniV3(
address tokenIn,
address tokenOut,
uint256 amount,
uint256 minReturn,
uint256[] calldata pools
| function swapOneInchUniV3(
address tokenIn,
address tokenOut,
uint256 amount,
uint256 minReturn,
uint256[] calldata pools
| 19,386 |
63 | // If the receiver veCRV lock ends after the Pledge endTimestamp | uint256 lockRemainingDuration = receiverLockEnd - block.timestamp;
| uint256 lockRemainingDuration = receiverLockEnd - block.timestamp;
| 16,870 |
33 | // sanity checks | if (newOperatorShare > PPM_DENOMINATOR) {
| if (newOperatorShare > PPM_DENOMINATOR) {
| 15,804 |
10 | // 5. support for __ESBMC_assume | function __ESBMC_assume(bool) internal pure { }
function func_overflow() external {
_y = 240;
//_x = 100; increment_x();
//_x = get_x();
//_x = nondet();
uint8 _z = nondet(); //uint8 _m = nondet(); // This will be another statement!
//__ESBMC_assume(_z != 16);
__ESBMC_assume(_z % 16 != 0);
sum = _y + _z;
//sum = _y + _x;
//sum = _y + _z + _m;
//assert(sum > 100);
assert(sum != 0);
}
| function __ESBMC_assume(bool) internal pure { }
function func_overflow() external {
_y = 240;
//_x = 100; increment_x();
//_x = get_x();
//_x = nondet();
uint8 _z = nondet(); //uint8 _m = nondet(); // This will be another statement!
//__ESBMC_assume(_z != 16);
__ESBMC_assume(_z % 16 != 0);
sum = _y + _z;
//sum = _y + _x;
//sum = _y + _z + _m;
//assert(sum > 100);
assert(sum != 0);
}
| 17,968 |
32 | // if there are not enough contributions or not looking good brev, refund everyone their eth | function refundEveryone() external onlyOwner {
for (uint256 i = 1; i <= NUMBER_OF_CONTRIBUTOORS; i++) {
address payable refundAddress = payable(contribution[i].addr);
/// refund the contribution
refundAddress.transfer(contribution[i].amount);
}
}
| function refundEveryone() external onlyOwner {
for (uint256 i = 1; i <= NUMBER_OF_CONTRIBUTOORS; i++) {
address payable refundAddress = payable(contribution[i].addr);
/// refund the contribution
refundAddress.transfer(contribution[i].amount);
}
}
| 8,536 |
96 | // Registers tokenIds to global registry/ | function _registerId(address _project, uint256 _tokenId) private {
require(!tokenRegistry[_project][_tokenId], "Already registered");
tokenRegistry[_project][_tokenId] = true;
}
| function _registerId(address _project, uint256 _tokenId) private {
require(!tokenRegistry[_project][_tokenId], "Already registered");
tokenRegistry[_project][_tokenId] = true;
}
| 36,759 |
45 | // Converts a 'uint256' to its ASCII 'string' decimal representation. / | function toString(uint256 value) internal pure returns(string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
| function toString(uint256 value) internal pure returns(string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
| 50,655 |
22 | // avoid an SLOAD by using the swap return data | amountIn = exactOutputInternal(
params.amountOut,
params.recipient,
params.sqrtPriceLimitX96,
| amountIn = exactOutputInternal(
params.amountOut,
params.recipient,
params.sqrtPriceLimitX96,
| 17,745 |
320 | // Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. _beneficiary Address receiving the tokens _tokenAmount Number of tokens to be purchased / | function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
)
internal
| function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
)
internal
| 12,861 |
37 | // investor => balance in wei10^(-6) available for withdrawal | mapping(address => uint256) private investorBalances;
| mapping(address => uint256) private investorBalances;
| 76,059 |
478 | // Function to delete an existing group for the user / ein _groupIndex describes the associated index of the group for the user / ein / | function deleteGroup(uint _groupIndex)
| function deleteGroup(uint _groupIndex)
| 24,751 |
0 | // Interfaces for ERC20 and ERC721 | IERC20 public immutable rewardsToken;
IERC721 public immutable nftCollection;
| IERC20 public immutable rewardsToken;
IERC721 public immutable nftCollection;
| 3,017 |
72 | // Forward funding to ether wallet | wallet.transfer(amount);
bids[receiver] += amount;
totalReceived += amount;
BidSubmission(receiver, amount);
| wallet.transfer(amount);
bids[receiver] += amount;
totalReceived += amount;
BidSubmission(receiver, amount);
| 49,730 |
28 | // initializes the contract and its parents / | function __BancorArbitrage_init() internal onlyInitializing {
__ReentrancyGuard_init();
__Upgradeable_init();
__BancorArbitrage_init_unchained();
}
| function __BancorArbitrage_init() internal onlyInitializing {
__ReentrancyGuard_init();
__Upgradeable_init();
__BancorArbitrage_init_unchained();
}
| 3,586 |
53 | // logged on payout transition to mark cash payout to NEU holders | event LogPlatformFeePayout(
address paymentToken,
address disbursalPool,
uint256 amount
);
| event LogPlatformFeePayout(
address paymentToken,
address disbursalPool,
uint256 amount
);
| 33,916 |
0 | // ========== STRUCTS ========== // Timestamp for current period finish | uint32 periodFinish;
| uint32 periodFinish;
| 10,362 |
25 | // The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed | function quorumVotes() external pure returns (uint);
| function quorumVotes() external pure returns (uint);
| 83,118 |
192 | // Allow to buy remaining if there less left than requested | uint amount = in_amount; // *
if(in_amount > ticketPool.sub(ticketsBought)){ // *
amount = ticketPool.sub(ticketsBought); // *
queueAmount[queueLength] = in_amount.sub(amount); // *
queueAddress[queueLength] = msg.sender; // *
queueFunds = queueFunds.add((in_amount.sub(amount)).mul(ticketPrice)); // *
queueLength = queueLength.add(1); // *
} // *
| uint amount = in_amount; // *
if(in_amount > ticketPool.sub(ticketsBought)){ // *
amount = ticketPool.sub(ticketsBought); // *
queueAmount[queueLength] = in_amount.sub(amount); // *
queueAddress[queueLength] = msg.sender; // *
queueFunds = queueFunds.add((in_amount.sub(amount)).mul(ticketPrice)); // *
queueLength = queueLength.add(1); // *
} // *
| 7,276 |
148 | // Universal store of current contract time for testing environments. / | contract Timer {
uint256 private currentTime;
constructor() public {
currentTime = now; // solhint-disable-line not-rely-on-time
}
/**
* @notice Sets the current time.
* @dev Will revert if not running in test mode.
* @param time timestamp to set `currentTime` to.
*/
function setCurrentTime(uint256 time) external {
currentTime = time;
}
/**
* @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode.
* Otherwise, it will return the block timestamp.
* @return uint256 for the current Testable timestamp.
*/
function getCurrentTime() public view returns (uint256) {
return currentTime;
}
}
| contract Timer {
uint256 private currentTime;
constructor() public {
currentTime = now; // solhint-disable-line not-rely-on-time
}
/**
* @notice Sets the current time.
* @dev Will revert if not running in test mode.
* @param time timestamp to set `currentTime` to.
*/
function setCurrentTime(uint256 time) external {
currentTime = time;
}
/**
* @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode.
* Otherwise, it will return the block timestamp.
* @return uint256 for the current Testable timestamp.
*/
function getCurrentTime() public view returns (uint256) {
return currentTime;
}
}
| 21,276 |
18 | // 销毁合约 | function stopGame() public onlyAdmin() {
selfdestruct(owner);
}
| function stopGame() public onlyAdmin() {
selfdestruct(owner);
}
| 14,043 |
18 | // Case3: The user has never connected before: initialisation of connection | occupiedID[msg.sender] = connectionInitialisation(bandwidth, thresholdBid, burst);
| occupiedID[msg.sender] = connectionInitialisation(bandwidth, thresholdBid, burst);
| 48,015 |
3 | // Fees were unable to be transferred to the fee manager. / | error FeeTransferFailed();
| error FeeTransferFailed();
| 5,395 |
105 | // This method should be called by the owner before the contribution/period starts This initializes most of the parameters | function initialize(
address _token,
address _destTokensReserve,
address _destTokensTeam,
address _destTokensBounties,
address _destTokensAirdrop,
address _destTokensAdvisors,
address _destTokensEarlyInvestors
| function initialize(
address _token,
address _destTokensReserve,
address _destTokensTeam,
address _destTokensBounties,
address _destTokensAirdrop,
address _destTokensAdvisors,
address _destTokensEarlyInvestors
| 51,388 |
83 | // XGXCoin extends BurnableToken, PausableToken, Ownable / | contract XGXCoin is ERC20, ERC20Detailed, ERC20Burnable, ERC20Pausable, Ownable {
// 2 billion
uint256 public constant INITIAL_SUPPLY = 2000000000 * (10 ** uint256(decimals()));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor() public ERC20Detailed("XGX Coin", "XGX", 8) {
_mint(msg.sender, INITIAL_SUPPLY);
}
/**
* @dev remove an account's access to Pause
* @param account pauser
*/
function removePauser(address account) public onlyOwner {
_removePauser(account);
}
} | contract XGXCoin is ERC20, ERC20Detailed, ERC20Burnable, ERC20Pausable, Ownable {
// 2 billion
uint256 public constant INITIAL_SUPPLY = 2000000000 * (10 ** uint256(decimals()));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor() public ERC20Detailed("XGX Coin", "XGX", 8) {
_mint(msg.sender, INITIAL_SUPPLY);
}
/**
* @dev remove an account's access to Pause
* @param account pauser
*/
function removePauser(address account) public onlyOwner {
_removePauser(account);
}
} | 12,490 |
138 | // 50% of the LP tokens kept by the unstaking fee will be locked forever in the BRRR contract, the other 50% will be sent to team. | uint256 lpTokensToLock = withdrawFeeAmount.div(2);
uint256 lpTokensToTeam = lpTokensToLock;
pool.lpToken.safeTransfer(address(msg.sender), remainingUserAmount);
pool.lpToken.safeTransfer(devaddr, lpTokensToTeam);
pool.lpToken.safeTransfer(address(this), lpTokensToLock);
emit Withdraw(msg.sender, _pid, _amount);
| uint256 lpTokensToLock = withdrawFeeAmount.div(2);
uint256 lpTokensToTeam = lpTokensToLock;
pool.lpToken.safeTransfer(address(msg.sender), remainingUserAmount);
pool.lpToken.safeTransfer(devaddr, lpTokensToTeam);
pool.lpToken.safeTransfer(address(this), lpTokensToLock);
emit Withdraw(msg.sender, _pid, _amount);
| 31,227 |
386 | // Transfer ETH to sender | msg.sender.transfer(transferAmount);
| msg.sender.transfer(transferAmount);
| 37,123 |
31 | // Modifies `self` to contain everything from the first occurrence of `needle` to the end of the slice. `self` is set to the empty slice if `needle` is not found. self The slice to search and modify. needle The text to search for.return `self`. / | function toHexDigit(uint8 d) pure internal returns (byte) {
if (0 <= d && d <= 9) {
return byte(uint8(byte('0')) + d);
} else if (10 <= uint8(d) && uint8(d) <= 15) {
return byte(uint8(byte('a')) + d - 10);
}
// revert("Invalid hex digit");
revert();
}
| function toHexDigit(uint8 d) pure internal returns (byte) {
if (0 <= d && d <= 9) {
return byte(uint8(byte('0')) + d);
} else if (10 <= uint8(d) && uint8(d) <= 15) {
return byte(uint8(byte('a')) + d - 10);
}
// revert("Invalid hex digit");
revert();
}
| 13,372 |
89 | // Flash loan collaterals sitting in this contract/ Loaned amount + fee must be repaid by the end of the transaction for the transaction to not be reverted/_tokenAddress Token to flashLoan/_amount Amount to flashLoan/_receiver Receiver of the flashLoan | function flashLoan(address _tokenAddress, uint256 _amount, IFlashLoanReceiver _receiver) public nonReentrant {
IERC20 _token = IERC20(_tokenAddress);
uint256 startBalance = _token.balanceOf(address(this));
_token.safeTransfer(address(_receiver), _amount);
(uint256 fee,) = feeCalculator.getFeeAmounts(msg.sender, false, _amount, IFeeCalculator.FeeType.FlashLoan);
_receiver.execute(_tokenAddress, _amount, _amount.add(fee));
uint256 endBalance = _token.balanceOf(address(this));
uint256 endBalanceRequired = startBalance.add(fee);
require(endBalance >= endBalanceRequired, "Failed to pay back");
_token.safeTransfer(feeRecipient, endBalance.sub(startBalance));
endBalance = _token.balanceOf(address(this));
require(endBalance >= startBalance, "Failed to pay back");
}
| function flashLoan(address _tokenAddress, uint256 _amount, IFlashLoanReceiver _receiver) public nonReentrant {
IERC20 _token = IERC20(_tokenAddress);
uint256 startBalance = _token.balanceOf(address(this));
_token.safeTransfer(address(_receiver), _amount);
(uint256 fee,) = feeCalculator.getFeeAmounts(msg.sender, false, _amount, IFeeCalculator.FeeType.FlashLoan);
_receiver.execute(_tokenAddress, _amount, _amount.add(fee));
uint256 endBalance = _token.balanceOf(address(this));
uint256 endBalanceRequired = startBalance.add(fee);
require(endBalance >= endBalanceRequired, "Failed to pay back");
_token.safeTransfer(feeRecipient, endBalance.sub(startBalance));
endBalance = _token.balanceOf(address(this));
require(endBalance >= startBalance, "Failed to pay back");
}
| 37,965 |
166 | // View function to see pending PICKLEs on frontend. | function pendingPickle(uint256 _pid, address _user)
external
view
returns (uint256)
| function pendingPickle(uint256 _pid, address _user)
external
view
returns (uint256)
| 45,914 |
1 | // Returns the base URI for the metadata of this NFT collection.return The base URI for the metadata of this NFT collection. / | function baseURI() external view returns (string memory);
| function baseURI() external view returns (string memory);
| 10,482 |
119 | // Internal function to remove a token ID from the list of a given address _from address representing the previous owner of the given token ID _tokenId uint256 ID of the token to be removed from the tokens list of the given address / | function removeTokenFrom(address _from, uint256 _tokenId) internal whenNotPaused {
require(_ownerOf(_tokenId) == _from);
require(!frozenAccount[_from]);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
tokenOwner[_tokenId] = address(0);
}
| function removeTokenFrom(address _from, uint256 _tokenId) internal whenNotPaused {
require(_ownerOf(_tokenId) == _from);
require(!frozenAccount[_from]);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
tokenOwner[_tokenId] = address(0);
}
| 3,440 |
194 | // emitted on setFeeRecipient | event UpdateFeeRecipient(address sender, address receipient);
function deposit(
IERC20 asset,
address recipient,
uint128 amount,
bool claim
) external;
function withdraw(
| event UpdateFeeRecipient(address sender, address receipient);
function deposit(
IERC20 asset,
address recipient,
uint128 amount,
bool claim
) external;
function withdraw(
| 6,051 |
1 | // mapping | mapping (uint256 => Campaign) public campaigns;
| mapping (uint256 => Campaign) public campaigns;
| 5,571 |
51 | // If the condition is false, discard this run's fuzz inputs and generate new ones. | function assume(bool condition) external pure;
| function assume(bool condition) external pure;
| 47,545 |
3 | // mints a new Alchemy ContractnftAddresses_ the nft addresses array to add to the contract owner_ the owner of the contract tokenIds_ the token id array of the nft to be added totalSupply_ the total supply of the erc20 name_ the token name symbol_ the token symbol buyoutPrice_ the buyout price to buyout the dao votingPeriod_ the voting period for the DAO in blocks timelockDelay_ the timelock delay in secondsreturn alchemy - the address of the newly generated alchemy contractgovernor - the address of the new governor alphatimelock - the address of the new timelock/ | function NFTDAOMint(
IERC721[] memory nftAddresses_,
address owner_,
uint256[] memory tokenIds_,
uint256 totalSupply_,
string memory name_,
string memory symbol_,
uint256 buyoutPrice_,
uint256 votingPeriod_,
uint256 timelockDelay_
| function NFTDAOMint(
IERC721[] memory nftAddresses_,
address owner_,
uint256[] memory tokenIds_,
uint256 totalSupply_,
string memory name_,
string memory symbol_,
uint256 buyoutPrice_,
uint256 votingPeriod_,
uint256 timelockDelay_
| 65,188 |
30 | // Transfer Tokens to User | _token.safeTransfer(msg.sender, amountTokens);
_claimedAmount = _claimedAmount.add(amountTokens);
emit Claimed(msg.sender, amountTokens);
return true;
| _token.safeTransfer(msg.sender, amountTokens);
_claimedAmount = _claimedAmount.add(amountTokens);
emit Claimed(msg.sender, amountTokens);
return true;
| 18,706 |
3 | // Creator of the contract is admin during initialization | admin = msg.sender;
| admin = msg.sender;
| 11,716 |
117 | // Moves `amount` tokens from `sender` to `recipient`. The caller mustbe an operator of `sender`. If send or receive hooks are registered for `sender` and `recipient`,the corresponding functions will be called with `data` and`operatorData`. See {IERC777Sender} and {IERC777Recipient}. Emits a {Sent} event. Requirements - `sender` cannot be the zero address.- `sender` must have at least `amount` tokens.- the caller must be an operator for `sender`.- `recipient` cannot be the zero address.- if `recipient` is a contract, it must implement the {IERC777Recipient}interface. / | function operatorSend(
| function operatorSend(
| 16,261 |
187 | // Destroys `amount` tokens from `account`, deducting from the caller'sallowance. | * See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account_, uint256 amount_) public virtual {
_burnFrom(account_, amount_);
}
| * See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account_, uint256 amount_) public virtual {
_burnFrom(account_, amount_);
}
| 411 |
212 | // Performs a Solidity function call using a low level `call`. Aplain `call` is an unsafe replacement for a function call: use thisfunction instead. If `target` reverts with a revert reason, it is bubbled up by thisfunction (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, Requirements: - `target` must be a contract.- calling `target` with `data` must not revert. _Available since v3.1._ / | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| 3,239 |
169 | // public | function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
bool isOwner = msg.sender == owner();
require(!paused);
require(_mintAmount > 0);
require(isOwner || _mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
| function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
bool isOwner = msg.sender == owner();
require(!paused);
require(_mintAmount > 0);
require(isOwner || _mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
| 1,187 |
6 | // Swap tokens to ETH | _swapTokensForEth(address(this).balance);
| _swapTokensForEth(address(this).balance);
| 32,675 |
48 | // send token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE if you want to withdraw ether | function withdraw(address token) public onlyOwner returns(bool) {
//for ether withdrawal from smart contract
if (address(token) == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
uint256 amount = address(this).balance;
msg.sender.transfer(amount);
}
//for ether withdrawal from smart contract. Note on dividing by zero: likely will error.
else {
IERC20 tokenToken = IERC20(token);
uint256 newTokenBalance = tokenToken.balanceOf(address(this));
SafeERC20AH2.safeTransfer(tokenToken, msg.sender, newTokenBalance);
}
return true;
}
| function withdraw(address token) public onlyOwner returns(bool) {
//for ether withdrawal from smart contract
if (address(token) == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
uint256 amount = address(this).balance;
msg.sender.transfer(amount);
}
//for ether withdrawal from smart contract. Note on dividing by zero: likely will error.
else {
IERC20 tokenToken = IERC20(token);
uint256 newTokenBalance = tokenToken.balanceOf(address(this));
SafeERC20AH2.safeTransfer(tokenToken, msg.sender, newTokenBalance);
}
return true;
}
| 1,661 |
18 | // Returns value of collateral that must increase to reach recollateralization target (if 0 means no recollateralization) | function recollateralizeAmount(uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value) public pure returns (uint256) {
uint256 target_collat_value = total_supply.mul(global_collateral_ratio).div(1e6); // We want 18 decimals of precision so divide by 1e6; total_supply is 1e18 and global_collateral_ratio is 1e6
// Subtract the current value of collateral from the target value needed, if higher than 0 then system needs to recollateralize
return target_collat_value.sub(global_collat_value); // If recollateralization is not needed, throws a subtraction underflow
// return(recollateralization_left);
}
| function recollateralizeAmount(uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value) public pure returns (uint256) {
uint256 target_collat_value = total_supply.mul(global_collateral_ratio).div(1e6); // We want 18 decimals of precision so divide by 1e6; total_supply is 1e18 and global_collateral_ratio is 1e6
// Subtract the current value of collateral from the target value needed, if higher than 0 then system needs to recollateralize
return target_collat_value.sub(global_collat_value); // If recollateralization is not needed, throws a subtraction underflow
// return(recollateralization_left);
}
| 32,282 |
26 | // ------------------------------------------------------------------------ Mint tokens ------------------------------------------------------------------------ | function mint(address tokenOwner, uint tokens) public onlyOwner returns (bool success) {
require(mintable);
balances[tokenOwner] = balances[tokenOwner].add(tokens);
_totalSupply = _totalSupply.add(tokens);
Transfer(address(0), tokenOwner, tokens);
return true;
}
| function mint(address tokenOwner, uint tokens) public onlyOwner returns (bool success) {
require(mintable);
balances[tokenOwner] = balances[tokenOwner].add(tokens);
_totalSupply = _totalSupply.add(tokens);
Transfer(address(0), tokenOwner, tokens);
return true;
}
| 42,644 |
72 | // An array of all the erc20 token addresses the smart fund holds | address[] public tokenAddresses;
| address[] public tokenAddresses;
| 45,805 |
4 | // Address of the token B / | address private _tokenB;
| address private _tokenB;
| 21,832 |
45 | // Check that the output transaction actually created the output. | require(_transactionIncluded(_outputTx, _utxoPos, _outputTxInclusionProof));
| require(_transactionIncluded(_outputTx, _utxoPos, _outputTxInclusionProof));
| 26,698 |
213 | // Updates the reward for a given address, before executing function.Locks 80% of new rewards up for 6 months, vesting linearly from (time of last action + 6 months) to(now + 6 months). This allows rewards to be distributed close to how they were accrued, as opposedto locking up for a flat 6 months from the time of this fn call (allowing more passive accrual). / | modifier updateReward(address _account) {
_updateReward(_account);
_;
}
| modifier updateReward(address _account) {
_updateReward(_account);
_;
}
| 46,699 |
3 | // folk[i]->token->balance | mapping (address => mapping (address => uint256)) public balance;
| mapping (address => mapping (address => uint256)) public balance;
| 16,221 |
75 | // Returns how long a two-step ownership handover is valid for in seconds. | function ownershipHandoverValidFor() public view virtual returns (uint64) {
return 48 * 3600;
}
| function ownershipHandoverValidFor() public view virtual returns (uint64) {
return 48 * 3600;
}
| 41,877 |
36 | // View function which returns if an account is whitelisted account Account to check white list status ofreturn If the account is whitelisted / | function isWhitelisted(address account) public view returns (bool) {
return (whitelistAccountExpirations[account] > block.timestamp);
}
| function isWhitelisted(address account) public view returns (bool) {
return (whitelistAccountExpirations[account] > block.timestamp);
}
| 17,360 |
321 | // Called with the sale price to determine how much royaltyis owed and to whom. - the NFT asset queried for royalty information salePrice_ - the sale price of the NFT asset specified by _tokenIdreturn receiver - address of who should be sent the royalty paymentreturn royaltyAmount - the royalty payment amount for _salePrice / | function royaltyInfo(uint256, uint256 salePrice_)
external
view
virtual
override
returns (address receiver, uint256 royaltyAmount)
{
receiver = _royaltyReceiver;
| function royaltyInfo(uint256, uint256 salePrice_)
external
view
virtual
override
returns (address receiver, uint256 royaltyAmount)
{
receiver = _royaltyReceiver;
| 81,920 |
130 | // transfers the oracle's LINK to another address. Can only be calledby the oracle's admin. _oracle is the oracle whose LINK is transferred _recipient is the address to send the LINK to _amount is the amount of LINK to send / | function withdrawPayment(address _oracle, address _recipient, uint256 _amount)
external
| function withdrawPayment(address _oracle, address _recipient, uint256 _amount)
external
| 22,479 |
875 | // Minimum deposit required to create a Dispute | uint256 public minimumDeposit;
| uint256 public minimumDeposit;
| 84,733 |
11 | // See {IERC1155-setApprovalForAll}. / | function setApprovalForAll(address operator, bool approved) public virtual override {
| function setApprovalForAll(address operator, bool approved) public virtual override {
| 23,603 |
116 | // initializes bond parameters_controlVariable uint_vestingTerm uint32_minimumPrice uint_maxPayout uint_fee uint_maxDebt uint_initialDebt uint / | function initializeBondTerms(
uint _controlVariable,
uint _minimumPrice,
uint _maxPayout,
uint _fee,
uint _maxDebt,
uint _initialDebt,
uint32 _vestingTerm
| function initializeBondTerms(
uint _controlVariable,
uint _minimumPrice,
uint _maxPayout,
uint _fee,
uint _maxDebt,
uint _initialDebt,
uint32 _vestingTerm
| 2,965 |
52 | // Add liquidity tokens to staking contract _amount of LP tokens to stake / | function addLiquidityStake(uint256 _amount) external {
_addStake(msg.sender, _amount, true);
emit StakeLiquidityAdded(msg.sender, _amount);
}
| function addLiquidityStake(uint256 _amount) external {
_addStake(msg.sender, _amount, true);
emit StakeLiquidityAdded(msg.sender, _amount);
}
| 11,788 |
101 | // An abbreviated name for NFTokens. / | string internal nftSymbol;
| string internal nftSymbol;
| 2,374 |
381 | // ACR Roles/ keccak256("DEFAULT_ADMIN_ROLE"); | bytes32 internal constant ADMIN_ROLE = 0x1effbbff9c66c5e59634f24fe842750c60d18891155c32dd155fc2d661a4c86d;
| bytes32 internal constant ADMIN_ROLE = 0x1effbbff9c66c5e59634f24fe842750c60d18891155c32dd155fc2d661a4c86d;
| 8,259 |
11 | // Refund ETH if necessary. No need to refund TKN because we transferred the actual amount. | if (refundETH > 0) {
msg.sender.transfer(refundETH);
}
| if (refundETH > 0) {
msg.sender.transfer(refundETH);
}
| 30,577 |
14 | // Approve Balancer vault to spend tokens | IERC20(OHM).approve(address(balancerVault), amountOHM);
IERC20(WETH).approve(address(balancerVault), amountETH);
IERC20(DAI).approve(address(balancerVault), amountDAI);
| IERC20(OHM).approve(address(balancerVault), amountOHM);
IERC20(WETH).approve(address(balancerVault), amountETH);
IERC20(DAI).approve(address(balancerVault), amountDAI);
| 7,633 |
149 | // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it to 'token out'. This results in slightly larger price impact. |
uint256 amountOutWithFee;
if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) {
uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement());
uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount);
uint256 taxableAmountPlusFees = taxableAmount.divUp(FixedPoint.ONE.sub(swapFeePercentage));
swapFees[i] = taxableAmountPlusFees - taxableAmount;
amountOutWithFee = nonTaxableAmount.add(taxableAmountPlusFees);
} else {
|
uint256 amountOutWithFee;
if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) {
uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement());
uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount);
uint256 taxableAmountPlusFees = taxableAmount.divUp(FixedPoint.ONE.sub(swapFeePercentage));
swapFees[i] = taxableAmountPlusFees - taxableAmount;
amountOutWithFee = nonTaxableAmount.add(taxableAmountPlusFees);
} else {
| 13,366 |
5 | // External Imports / | import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title OVM_GasPriceOracle
* @dev This contract exposes the current l2 gas price, a measure of how congested the network
* currently is. This measure is used by the Sequencer to determine what fee to charge for
* transactions. When the system is more congested, the l2 gas price will increase and fees
* will also increase as a result.
*
* Compiler used: optimistic-solc
* Runtime target: OVM
*/
contract OVM_GasPriceOracle is Ownable {
/*************
* Variables *
*************/
// Current l2 gas price
uint256 public gasPrice;
/***************
* Constructor *
***************/
/**
* @param _owner Address that will initially own this contract.
*/
constructor(
address _owner,
uint256 _initialGasPrice
)
Ownable()
{
setGasPrice(_initialGasPrice);
transferOwnership(_owner);
}
/********************
* Public Functions *
********************/
/**
* Allows the owner to modify the l2 gas price.
* @param _gasPrice New l2 gas price.
*/
function setGasPrice(
uint256 _gasPrice
)
public
onlyOwner
{
gasPrice = _gasPrice;
}
}
| import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title OVM_GasPriceOracle
* @dev This contract exposes the current l2 gas price, a measure of how congested the network
* currently is. This measure is used by the Sequencer to determine what fee to charge for
* transactions. When the system is more congested, the l2 gas price will increase and fees
* will also increase as a result.
*
* Compiler used: optimistic-solc
* Runtime target: OVM
*/
contract OVM_GasPriceOracle is Ownable {
/*************
* Variables *
*************/
// Current l2 gas price
uint256 public gasPrice;
/***************
* Constructor *
***************/
/**
* @param _owner Address that will initially own this contract.
*/
constructor(
address _owner,
uint256 _initialGasPrice
)
Ownable()
{
setGasPrice(_initialGasPrice);
transferOwnership(_owner);
}
/********************
* Public Functions *
********************/
/**
* Allows the owner to modify the l2 gas price.
* @param _gasPrice New l2 gas price.
*/
function setGasPrice(
uint256 _gasPrice
)
public
onlyOwner
{
gasPrice = _gasPrice;
}
}
| 1,313 |
80 | // Gets the a value for the latest timestamp available return value for timestamp of last proof of work submited return true if the is a timestamp for the lastNewValue/ | function getLastNewValue(BerryStorage.BerryStorageStruct storage self) internal view returns (uint256, bool) {
return (
retrieveData(
self,
self.requestIdByTimestamp[self.uintVars[keccak256("timeOfLastNewValue")]],
self.uintVars[keccak256("timeOfLastNewValue")]
),
true
);
}
| function getLastNewValue(BerryStorage.BerryStorageStruct storage self) internal view returns (uint256, bool) {
return (
retrieveData(
self,
self.requestIdByTimestamp[self.uintVars[keccak256("timeOfLastNewValue")]],
self.uintVars[keccak256("timeOfLastNewValue")]
),
true
);
}
| 11,574 |
102 | // Returns the symbol of the token, usually a shorter version of thename. / | function symbol() public view returns (string memory) {
return _symbol;
}
| function symbol() public view returns (string memory) {
return _symbol;
}
| 11,297 |
73 | // transfer overrride |
function transfer(
address _to,
uint256 _value
)
public
|
function transfer(
address _to,
uint256 _value
)
public
| 58,549 |
62 | // PUBLIC-FUNCTIONS |
function getUserWallet(address _investor)
public
view
returns (uint, uint, uint, uint, int, uint)
|
function getUserWallet(address _investor)
public
view
returns (uint, uint, uint, uint, int, uint)
| 24,024 |
8 | // Override of `_baseURI()` that returns `baseTokenURI` | function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
| function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
| 70,668 |
121 | // Modified OpenZeppelin ERC721 contract, remove unnecessary stuffs to reduce gas usages. / | contract ERC721 is Context, ERC165, IERC721 {
using Address for address;
using Strings for uint256;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner)
public
view
virtual
override
returns (uint256)
{
require(owner != address(0), "Zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId)
public
view
virtual
override
returns (address)
{
address owner = _owners[tokenId];
require(owner != address(0), "Nonexistent token");
return owner;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "Can't approval to owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"Access denied"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId)
public
view
virtual
override
returns (address)
{
require(_exists(tokenId), "Nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(operator != _msgSender(), "Approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Access denied");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Access denied");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"Non ERC721Receiver implementer"
);
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
virtual
returns (bool)
{
require(_exists(tokenId), "Nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "Zero address");
require(!_exists(tokenId), "Already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "Not your token");
require(to != address(0), "Zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
_data
)
returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("Non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
| contract ERC721 is Context, ERC165, IERC721 {
using Address for address;
using Strings for uint256;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner)
public
view
virtual
override
returns (uint256)
{
require(owner != address(0), "Zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId)
public
view
virtual
override
returns (address)
{
address owner = _owners[tokenId];
require(owner != address(0), "Nonexistent token");
return owner;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "Can't approval to owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"Access denied"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId)
public
view
virtual
override
returns (address)
{
require(_exists(tokenId), "Nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(operator != _msgSender(), "Approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Access denied");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Access denied");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"Non ERC721Receiver implementer"
);
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
virtual
returns (bool)
{
require(_exists(tokenId), "Nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "Zero address");
require(!_exists(tokenId), "Already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "Not your token");
require(to != address(0), "Zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
_data
)
returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("Non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
| 39,670 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.