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
84
// Deposit ether to get wrapped ether
function deposit() external payable;
function deposit() external payable;
58,084
8
// leftover tokens after claiming period have been swept
event Swept(uint256 amount);
event Swept(uint256 amount);
21,937
20
// Get the storage contract for an ID _id The ID to get the storage contract ofreturn The address of the storage contract /
function getStorageContract(uint64 _id) external view returns (address) { return storageContracts[_id]; }
function getStorageContract(uint64 _id) external view returns (address) { return storageContracts[_id]; }
9,159
1
// Admin functionTransfer any kind of ERC20 tokens which are assigned/locked to this smart contract to an address._contract The ERC20 contract address._to The address to transfer all locked tokens to./
function reapErc20Tokens(address _contract, address _to) public returns (bool) { require(msg.sender == owner); ERC20Basic erc20 = ERC20Basic(_contract); uint256 totalTokens = erc20.balanceOf(address(this)); return erc20.transfer(_to, totalTokens); }
function reapErc20Tokens(address _contract, address _to) public returns (bool) { require(msg.sender == owner); ERC20Basic erc20 = ERC20Basic(_contract); uint256 totalTokens = erc20.balanceOf(address(this)); return erc20.transfer(_to, totalTokens); }
40,930
5
// Add link to the middle
uint prev = findSlot(list, pos); uint next = list.links[prev].next; list.links[linkID].prev = prev; list.links[linkID].next = next; list.links[linkID].time = block.timestamp; list.links[linkID].value = data; list.links[linkID].editor = msg.sender; list.links[linkID].status = 1;
uint prev = findSlot(list, pos); uint next = list.links[prev].next; list.links[linkID].prev = prev; list.links[linkID].next = next; list.links[linkID].time = block.timestamp; list.links[linkID].value = data; list.links[linkID].editor = msg.sender; list.links[linkID].status = 1;
14,697
194
// The total count validators in the pool /
function getTotalValidatorsCount() external view returns (uint256);
function getTotalValidatorsCount() external view returns (uint256);
9,374
46
// Returns to normal state. Requirements: - The contract must be paused. /
function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); }
function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); }
76,067
5
// Submit a claim regarding a DApp./ There are several requirements for this function to be called successfully.//`_claimData` MUST be well-encoded. In Solidity, it can be constructed/ as `abi.encode(dapp, claim)`, where `dapp` is the DApp address (type `address`)/ and `claim` is the claim structure (type `Claim`).//`firstIndex` MUST be less than or equal to `lastIndex`./ As a result, every claim MUST encompass AT LEAST one input.//If this is the DApp's first claim, then `firstIndex` MUST be `0`./ Otherwise, `firstIndex` MUST be the `lastClaim.lastIndex + 1`./ In other words, claims MUST NOT skip inputs.// @inheritdoc IHistory/Emits a `NewClaimToHistory` event. Should have access control.
function submitClaim( bytes calldata _claimData
function submitClaim( bytes calldata _claimData
23,684
121
// if Wallet owns other Faction Token, merge with old Faction token
if (noID.factionBalance > 0) { _burn( newOwner, noID.factionLastTokenId ); emit Merge(newOwner, noID.factionLastTokenId); }
if (noID.factionBalance > 0) { _burn( newOwner, noID.factionLastTokenId ); emit Merge(newOwner, noID.factionLastTokenId); }
37,203
11
// Amount will be per FNFT. So total ERC20s needed is amountquantity.We don't charge an ETH fee on depositAdditional, but do take the erc20 percentage.Users can deposit additional into their ownOtherwise, if not an owner, they must distribute to all FNFTs equally /
function depositAdditionalToFNFT( uint fnftId, uint amount, uint quantity
function depositAdditionalToFNFT( uint fnftId, uint amount, uint quantity
6,826
48
// admin & moderators
function setContract(address _dataContract, address _worldContract, address _transformDataContract, address _transformSettingContract,
function setContract(address _dataContract, address _worldContract, address _transformDataContract, address _transformSettingContract,
56,114
2
// tokenId => token owner
mapping(uint256 => address) internal tokenIdToTokenOwner;
mapping(uint256 => address) internal tokenIdToTokenOwner;
21,346
17
// durch Versender angelegt - der Versender, der eine neue Lieferung anlegt, kann folgende Variablen beschreiben
uint256 batchNumber; uint256[] prevOrderIds; uint256 shipmentDate; string workPerformed; string article; address receiverId;
uint256 batchNumber; uint256[] prevOrderIds; uint256 shipmentDate; string workPerformed; string article; address receiverId;
24,037
177
// Reflection Fee
_addFee(FeeType.Rfi, 40, address(this));
_addFee(FeeType.Rfi, 40, address(this));
26,733
26
// Validate number of block on which proposition becomes active. startBlock block number /
modifier validStartBlock(uint256 startBlock) { require(startBlock >= block.number, 'Invalid start block number'); _; }
modifier validStartBlock(uint256 startBlock) { require(startBlock >= block.number, 'Invalid start block number'); _; }
13,815
150
// require() is more informative than the default assert() // Get stake copy /return (stakeReturn, payout, dividends, penalty, cappedPenalty);
if (g._currentDay >= st._lockedDay) { if (prevUnlocked) {
if (g._currentDay >= st._lockedDay) { if (prevUnlocked) {
49,975
278
// Calculate how much G$ to mint based on expansion change (new reserveratio), in order to keep G$ price the same at the bonding curve. theformula to calculate the gd to mint: gd to mint =(reservebalance / (newreserveratiocurrentprice)) - gdsupply _token The reserve tokenreturn How much to mint in order to keep price in bonding curve the same /
function calculateMintExpansion(ERC20 _token) public view returns (uint256) { ReserveToken memory reserveToken = reserveTokens[address(_token)]; uint32 newReserveRatio = calculateNewReserveRatio(_token); // new reserve ratio uint256 reserveDecimalsDiff = uint256(27) - _token.decimals(); // //result is in RAY precision uint256 denom = (uint256(newReserveRatio) * 1e21 * currentPrice(_token) * (10**reserveDecimalsDiff)) / 1e27; // (newreserveratio * currentprice) in RAY precision uint256 gdDecimalsDiff = uint256(27) - decimals; uint256 toMint = ((reserveToken.reserveSupply * (10**reserveDecimalsDiff) * 1e27) / denom) / (10**gdDecimalsDiff); // reservebalance in RAY precision // return to gd precision return toMint - reserveToken.gdSupply; }
function calculateMintExpansion(ERC20 _token) public view returns (uint256) { ReserveToken memory reserveToken = reserveTokens[address(_token)]; uint32 newReserveRatio = calculateNewReserveRatio(_token); // new reserve ratio uint256 reserveDecimalsDiff = uint256(27) - _token.decimals(); // //result is in RAY precision uint256 denom = (uint256(newReserveRatio) * 1e21 * currentPrice(_token) * (10**reserveDecimalsDiff)) / 1e27; // (newreserveratio * currentprice) in RAY precision uint256 gdDecimalsDiff = uint256(27) - decimals; uint256 toMint = ((reserveToken.reserveSupply * (10**reserveDecimalsDiff) * 1e27) / denom) / (10**gdDecimalsDiff); // reservebalance in RAY precision // return to gd precision return toMint - reserveToken.gdSupply; }
51,593
49
// not sure what was returned: dont mark as success
default { }
default { }
69,690
25
// Throw on default handler to prevent direct transactions of Ether
function() { revert(); }
function() { revert(); }
2,182
10
// increase the contestant vote
contestants[_contestantId].voteCount ++;
contestants[_contestantId].voteCount ++;
38,775
34
// Creates a new promo collectible with the given name, with given _price and assignes it to an address.
function createPromoCollectible(uint256 tokenId, address _owner, uint256 _price) public onlyCOO { require(collectibleIndexToOwner[tokenId]==address(0)); require(promoCreatedCount < PROMO_CREATION_LIMIT); address collectibleOwner = _owner; if (collectibleOwner == address(0)) { collectibleOwner = cooAddress; } if (_price <= 0) { _price = getInitialPriceOfToken(tokenId); } promoCreatedCount++; _createCollectible(tokenId, _price); subTokenCreator[tokenId] = collectibleOwner; unlocked[tokenId] = true; // This will assign ownership, and also emit the Transfer event as // per ERC721 draft _transfer(address(0), collectibleOwner, tokenId); }
function createPromoCollectible(uint256 tokenId, address _owner, uint256 _price) public onlyCOO { require(collectibleIndexToOwner[tokenId]==address(0)); require(promoCreatedCount < PROMO_CREATION_LIMIT); address collectibleOwner = _owner; if (collectibleOwner == address(0)) { collectibleOwner = cooAddress; } if (_price <= 0) { _price = getInitialPriceOfToken(tokenId); } promoCreatedCount++; _createCollectible(tokenId, _price); subTokenCreator[tokenId] = collectibleOwner; unlocked[tokenId] = true; // This will assign ownership, and also emit the Transfer event as // per ERC721 draft _transfer(address(0), collectibleOwner, tokenId); }
30,373
29
// Returns the valid balance of a user that was taken into consideration in the total pool size for the epochA deposit will only change the next epoch balance.A withdraw will decrease the current epoch (and subsequent) balance. /
function getEpochUserBalance(address user, address token, uint128 epochId) public view returns (uint256) { Checkpoint[] storage checkpoints = balanceCheckpoints[user][token]; // if there are no checkpoints, it means the user never deposited any tokens, so the balance is 0 if (checkpoints.length == 0 || epochId < checkpoints[0].epochId) { return 0; } uint min = 0; uint max = checkpoints.length - 1; // shortcut for blocks newer than the latest checkpoint == current balance if (epochId >= checkpoints[max].epochId) { return getCheckpointEffectiveBalance(checkpoints[max]); } // binary search of the value in the array while (max > min) { uint mid = (max + min + 1) / 2; if (checkpoints[mid].epochId <= epochId) { min = mid; } else { max = mid - 1; } } return getCheckpointEffectiveBalance(checkpoints[min]); }
function getEpochUserBalance(address user, address token, uint128 epochId) public view returns (uint256) { Checkpoint[] storage checkpoints = balanceCheckpoints[user][token]; // if there are no checkpoints, it means the user never deposited any tokens, so the balance is 0 if (checkpoints.length == 0 || epochId < checkpoints[0].epochId) { return 0; } uint min = 0; uint max = checkpoints.length - 1; // shortcut for blocks newer than the latest checkpoint == current balance if (epochId >= checkpoints[max].epochId) { return getCheckpointEffectiveBalance(checkpoints[max]); } // binary search of the value in the array while (max > min) { uint mid = (max + min + 1) / 2; if (checkpoints[mid].epochId <= epochId) { min = mid; } else { max = mid - 1; } } return getCheckpointEffectiveBalance(checkpoints[min]); }
38,400
8
// Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called./
function allowance(address owner, address spender) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
851
67
// Enable a named action in a service contract/service The address of the service contract/action The name of the action to be disabled
function disableServiceAction(address service, string action) public onlyDeployer notNullOrThisAddress(service)
function disableServiceAction(address service, string action) public onlyDeployer notNullOrThisAddress(service)
4,114
11
// If no period is desired, instead set startBonus = 100% and bonusPeriod to a small value like 1sec.
require(bonusPeriodSec_ != 0, 'Cascade: bonus period is zero'); require(initialSharesPerToken > 0, 'Cascade: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new TokenPool(distributionToken); _lockedPool = new TokenPool(distributionToken); startBonus = startBonus_; bonusPeriodSec = bonusPeriodSec_; _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken;
require(bonusPeriodSec_ != 0, 'Cascade: bonus period is zero'); require(initialSharesPerToken > 0, 'Cascade: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new TokenPool(distributionToken); _lockedPool = new TokenPool(distributionToken); startBonus = startBonus_; bonusPeriodSec = bonusPeriodSec_; _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken;
22,589
0
// Launch dung roi
uint public rate = 999; uint256 public minCap = 0; uint256 public maxCap = 1*10**decimals(); address public minter; address[] public whitelist;
uint public rate = 999; uint256 public minCap = 0; uint256 public maxCap = 1*10**decimals(); address public minter; address[] public whitelist;
17,785
77
// DTHPool(address _daoAddress, address _delegate, uint _maxTimeBlocked, string _delegateName, string _delegateUrl, string _tokenSymbol);
function DTHPool( address _daoAddress, address _delegate, uint _maxTimeBlocked, string _delegateName, string _delegateUrl, string _tokenSymbol ) { daoAddress = _daoAddress;
function DTHPool( address _daoAddress, address _delegate, uint _maxTimeBlocked, string _delegateName, string _delegateUrl, string _tokenSymbol ) { daoAddress = _daoAddress;
52,146
35
// Lock the specified number of tokens until the specified unix time.The locked value and expiration time are both absolute (if the account already had some locked tokens the count will be increased to this value.)If the user already has locked tokens the locked token count and expiration time may not be smaller than the previous values.
function increaseLock(uint256 _value, uint256 _time) public returns (bool success) { User storage user = users[msg.sender]; // Is there a lock in effect? if (block.timestamp < user.lock_endTime) { // Lock in effect, ensure nothing gets smaller. require(_value >= user.lock_value); require(_time >= user.lock_endTime); // Ensure something has increased. require(_value > user.lock_value || _time > user.lock_endTime); } // Things we always require. require(_value <= user.balance); require(_time > block.timestamp); user.lock_value = _value; user.lock_endTime = _time; LockIncrease(msg.sender, _value, _time); return true; }
function increaseLock(uint256 _value, uint256 _time) public returns (bool success) { User storage user = users[msg.sender]; // Is there a lock in effect? if (block.timestamp < user.lock_endTime) { // Lock in effect, ensure nothing gets smaller. require(_value >= user.lock_value); require(_time >= user.lock_endTime); // Ensure something has increased. require(_value > user.lock_value || _time > user.lock_endTime); } // Things we always require. require(_value <= user.balance); require(_time > block.timestamp); user.lock_value = _value; user.lock_endTime = _time; LockIncrease(msg.sender, _value, _time); return true; }
32,880
203
// during the crowdsale, it shall not be allowed but if it is needed by the project owner it can by calling the crowdsale objectown by &39;this&39;
currentIco.modifyTransferableHash(_spender, value);
currentIco.modifyTransferableHash(_spender, value);
39,527
4
// ERC20Detailed token The decimals are only for visualization purposes.All the operations are done using the smallest and indivisible token unit,just as on Ethereum all the operations are done in wei. /
abstract contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; function initialize( string memory name, string memory symbol, uint8 decimals ) public virtual initializer { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; }
abstract contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; function initialize( string memory name, string memory symbol, uint8 decimals ) public virtual initializer { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; }
7,342
61
// implement minting constraints through the GlobalConstraintInterface interface. prevent any minting not through reserve
function pre( address _scheme, bytes32 _hash, bytes32 _method
function pre( address _scheme, bytes32 _hash, bytes32 _method
66,188
105
// Allows merchant or Monetha to initiate exchange of funds by withdrawing funds to deposit address of the exchange /
function withdrawToExchange(address depositAccount, uint amount) external onlyMerchantOrMonetha whenNotPaused { doWithdrawal(depositAccount, amount); }
function withdrawToExchange(address depositAccount, uint amount) external onlyMerchantOrMonetha whenNotPaused { doWithdrawal(depositAccount, amount); }
50,842
54
// {setWithFallback}. WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms ofactual characters as the UTF-8 encoding of a single character can span over multiple bytes. /
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else {
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else {
44,806
6
// only by previous nominee
function changeNominee(address newNominee) public;
function changeNominee(address newNominee) public;
42,193
45
// This percent of a transaction will be burnt.
uint8 private _taxBurn;
uint8 private _taxBurn;
27,206
143
// Remove an address from the whitelist_addressAddress to remove from the whitelist /
function removeAddress( address _address ) external onlyOwner
function removeAddress( address _address ) external onlyOwner
39,259
8
// module:core Version of the governor instance (used in building the ERC712 domain separator). Default: "1" /
function version() public view virtual returns (string memory);
function version() public view virtual returns (string memory);
12,022
890
// Contract Variables: Internal Accounting//Constructor// _libAddressManager Address of the Address Manager. /
constructor( address _libAddressManager ) Lib_AddressResolver(_libAddressManager)
constructor( address _libAddressManager ) Lib_AddressResolver(_libAddressManager)
57,029
175
// v0.3.0 - liquidatePosition is emergency exit. Supplants exitPosition
function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss)
function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss)
4,558
1
// This hook every time a key is extended. tokenId tje id of the key from the msg.sender making the purchase newTimestamp the new expiration timestamp after the key extension prevTimestamp the expiration timestamp of the key before being extended /
function onKeyExtend( uint tokenId, address from, uint newTimestamp, uint prevTimestamp ) external;
function onKeyExtend( uint tokenId, address from, uint newTimestamp, uint prevTimestamp ) external;
2,352
2
// Players can pay to re-roll their loot drop on a Furball
function upgradeLoot( FurLib.RewardModifiers memory modifiers, address owner, uint128 lootId, uint8 chances ) external returns(uint128);
function upgradeLoot( FurLib.RewardModifiers memory modifiers, address owner, uint128 lootId, uint8 chances ) external returns(uint128);
33,993
5
// Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner.Revoke all roles to the previous ownerGrant all roles to the new owner /
function transferOwnership(address newOwner) public override { //addStakeholder(newOwner); super.transferOwnership(newOwner); //need to have almost DEFAULT_ADMIN_ROLE role _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); grantRole(DEFAULT_ADMIN_ROLE, newOwner); grantRole(MINTER_ROLE, newOwner); grantRole(PAUSER_ROLE, newOwner); grantRole(BURNER_ROLE, newOwner); revokeRole(MINTER_ROLE, _msgSender()); revokeRole(PAUSER_ROLE, _msgSender()); revokeRole(BURNER_ROLE, _msgSender()); revokeRole(DEFAULT_ADMIN_ROLE, _msgSender()); }
function transferOwnership(address newOwner) public override { //addStakeholder(newOwner); super.transferOwnership(newOwner); //need to have almost DEFAULT_ADMIN_ROLE role _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); grantRole(DEFAULT_ADMIN_ROLE, newOwner); grantRole(MINTER_ROLE, newOwner); grantRole(PAUSER_ROLE, newOwner); grantRole(BURNER_ROLE, newOwner); revokeRole(MINTER_ROLE, _msgSender()); revokeRole(PAUSER_ROLE, _msgSender()); revokeRole(BURNER_ROLE, _msgSender()); revokeRole(DEFAULT_ADMIN_ROLE, _msgSender()); }
5,561
138
// decodeVecBytesArray accepts a Scale Codec of type Vec<Bytes> and returns an array of Bytes
function decodeVecBytesArray(Input.Data memory data) internal pure returns (bytes[] memory v)
function decodeVecBytesArray(Input.Data memory data) internal pure returns (bytes[] memory v)
11,133
63
// Get the aggregated publickey at the moment when pre-commit happened Aggregated pubkey given as part of calldata instead of being retrieved from voteWeigher reduces number of SLOADs (input[2], input[3]) is the apk /
mstore(add(input, 64), calldataload(pointer)) mstore(add(input, 96), calldataload(add(pointer, 32)))
mstore(add(input, 64), calldataload(pointer)) mstore(add(input, 96), calldataload(add(pointer, 32)))
38,597
182
// Enable referral
bool public enableReferral = true;
bool public enableReferral = true;
14,170
13
// Transfer from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= balanceOf[_from]); require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; }
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= balanceOf[_from]); require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; }
27,654
58
// Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
* optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); }
* optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); }
45,038
190
// If there is a baseURI but no tokenIdentifier, concatenate the tokenId to the baseURI
return string(abi.encodePacked(base, Strings.toString(_tokenId)));
return string(abi.encodePacked(base, Strings.toString(_tokenId)));
32,575
212
// amount of tokens which are still available for selling on the contract
function getRemainingTokenAmount() public view returns(uint256) { return _token.balanceOf(address(this)); }
function getRemainingTokenAmount() public view returns(uint256) { return _token.balanceOf(address(this)); }
41,154
156
// Add an account to whitelist /
function addWhitelisted(address account) external onlyOwner { require(!isWhitelisted(account), "Already whitelisted"); whitelist[account] = true; emit WhitelistedAdded(account); }
function addWhitelisted(address account) external onlyOwner { require(!isWhitelisted(account), "Already whitelisted"); whitelist[account] = true; emit WhitelistedAdded(account); }
57,954
145
// _trustedForwarder Forwarder address
constructor(address _trustedForwarder) ERC2771Context(_trustedForwarder) { _disableInitializers(); }
constructor(address _trustedForwarder) ERC2771Context(_trustedForwarder) { _disableInitializers(); }
3,399
0
// CONSTANTS//VARIABLES//MODIFIERS/
modifier accept { tvm.accept(); _; }
modifier accept { tvm.accept(); _; }
15,373
5
// The token and amount details for a transfer signed in the permit transfer signature
struct TokenPermissions { // ERC20 token address address token; // the maximum amount that can be spent uint256 amount; }
struct TokenPermissions { // ERC20 token address address token; // the maximum amount that can be spent uint256 amount; }
33,471
25
// here we precise amount param as certain bep20 tokens uses strange tax system preventing to send back whole balance
function emmergencyWithdrawTkn(address _token, uint _amount) external onlyOwner returns(bool success){ require(IERC20(_token).balanceOf(address(this)) >= _amount, "not enough tokens in contract"); IERC20(_token).transfer(administrator, _amount); return true; }
function emmergencyWithdrawTkn(address _token, uint _amount) external onlyOwner returns(bool success){ require(IERC20(_token).balanceOf(address(this)) >= _amount, "not enough tokens in contract"); IERC20(_token).transfer(administrator, _amount); return true; }
4,628
17
// get user Apas map from wallet
for(uint16 i=0; i < voterBalance; i++){ currentAPA = apaContract.tokenOfOwnerByIndex(msg.sender, i);
for(uint16 i=0; i < voterBalance; i++){ currentAPA = apaContract.tokenOfOwnerByIndex(msg.sender, i);
30,161
2
// as a participant, commit to one of the available choices.
function transcriptEntryCommit( uint256 gid, TranscriptCommitment calldata commitment ) external returns (uint256);
function transcriptEntryCommit( uint256 gid, TranscriptCommitment calldata commitment ) external returns (uint256);
11,797
62
// Performs signature verification. Throws or reverts if unable to verify the record.name The name of the RRSIG record, in DNS label-sequence format. data The original data to verify. proof A DS or DNSKEY record that's already verified by the oracle. /
function verifySignature(bytes memory name, RRUtils.SignedSet memory rrset, RRSetWithSignature memory data, bytes memory proof) internal view { // o The RRSIG RR's Signer's Name field MUST be the name of the zone // that contains the RRset. require(rrset.signerName.length <= name.length); require(rrset.signerName.equals(0, name, name.length - rrset.signerName.length)); RRUtils.RRIterator memory proofRR = proof.iterateRRs(0); // Check the proof if (proofRR.dnstype == DNSTYPE_DS) { require(verifyWithDS(rrset, data, proofRR)); } else if (proofRR.dnstype == DNSTYPE_DNSKEY) { require(verifyWithKnownKey(rrset, data, proofRR)); } else { revert("No valid proof found"); } }
function verifySignature(bytes memory name, RRUtils.SignedSet memory rrset, RRSetWithSignature memory data, bytes memory proof) internal view { // o The RRSIG RR's Signer's Name field MUST be the name of the zone // that contains the RRset. require(rrset.signerName.length <= name.length); require(rrset.signerName.equals(0, name, name.length - rrset.signerName.length)); RRUtils.RRIterator memory proofRR = proof.iterateRRs(0); // Check the proof if (proofRR.dnstype == DNSTYPE_DS) { require(verifyWithDS(rrset, data, proofRR)); } else if (proofRR.dnstype == DNSTYPE_DNSKEY) { require(verifyWithKnownKey(rrset, data, proofRR)); } else { revert("No valid proof found"); } }
7,209
0
// the targeted reward token to convert everything to
address public targetToken; address public profitSharingPool; address public uniswapRouterV2; event TokenPoolSet(address token, address pool); constructor(address _storage, address _uniswapRouterV2) public Governable(_storage)
address public targetToken; address public profitSharingPool; address public uniswapRouterV2; event TokenPoolSet(address token, address pool); constructor(address _storage, address _uniswapRouterV2) public Governable(_storage)
5,773
1
// NFT
struct NFT { address creator; uint256 supportersRoyalty; bool exists; }
struct NFT { address creator; uint256 supportersRoyalty; bool exists; }
22,902
191
// Pack unpacked data and write to storage
_packed.packedData = DubiexLib.packOrderBookItem(_unpacked); _ordersByAddress[maker].push(_packed);
_packed.packedData = DubiexLib.packOrderBookItem(_unpacked); _ordersByAddress[maker].push(_packed);
13,936
2
// Checks if the msg.sender is a contract or a proxy. requires the method _isContract(address sender). /
modifier notContract() { if (_isContract(_msgSender())) revert ContractsNotAllowed(); if (_msgSender() == tx.origin) revert ProxyNotAllowed(); _; }
modifier notContract() { if (_isContract(_msgSender())) revert ContractsNotAllowed(); if (_msgSender() == tx.origin) revert ProxyNotAllowed(); _; }
6,797
48
// maps relay managers to the number of their workers
mapping(address => uint256) public override workerCount; mapping(address => uint256) private balances; uint256 public override deprecationBlock = type(uint).max; constructor ( IStakeManager _stakeManager, address _penalizer, uint256 _maxWorkerCount,
mapping(address => uint256) public override workerCount; mapping(address => uint256) private balances; uint256 public override deprecationBlock = type(uint).max; constructor ( IStakeManager _stakeManager, address _penalizer, uint256 _maxWorkerCount,
64
276
// Attach a module/module a module to attach/enabled if the module is enabled by default/canModuleMint if the module has to be given the minter role
function attachModule( address module, bool enabled, bool canModuleMint ) external;
function attachModule( address module, bool enabled, bool canModuleMint ) external;
31,157
18
// Emits a {Transfer} event with `from` set to the zero address.Requirements: - `to` cannot be the zero address. /
function _mint(address account, uint256 amount) internal virtual { require( account != address(0), "ERC20: mint to the zero address" ); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount);
function _mint(address account, uint256 amount) internal virtual { require( account != address(0), "ERC20: mint to the zero address" ); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount);
12,875
50
// return any LINK tokens in here back to the DAPP wallet
link = LinkTokenInterface(chainlinkTokenAddress()); require(link.transfer(dappWallet, link.balanceOf(address(this))), "Unable to transfer");
link = LinkTokenInterface(chainlinkTokenAddress()); require(link.transfer(dappWallet, link.balanceOf(address(this))), "Unable to transfer");
7,909
8
// The minimum number of blocks before a liquidation event can be triggered
uint64 minimumBlocksBeforeLiquidation;
uint64 minimumBlocksBeforeLiquidation;
5,762
13
// calculate the collateral and debt values in ref. denomination for the current exchange rate and balance amounts including given adjustments to both values as requested.
uint256 cDebtValue = debtValueOf(_account).add(addDebt); uint256 cCollateralValue = collateralValueOf(_account).sub(subCollateral);
uint256 cDebtValue = debtValueOf(_account).add(addDebt); uint256 cCollateralValue = collateralValueOf(_account).sub(subCollateral);
22,634
111
// Underlying amount pending to be deposited from other strategies at reallocation /resets after the strategy reallocation DHW is finished
uint128 pendingReallocateDeposit;
uint128 pendingReallocateDeposit;
1,201
3
// Deauthorizes A Contract /
function ____DeauthorizeContract(address Contract) external onlyOwner { Role[Contract] = 0x0; }
function ____DeauthorizeContract(address Contract) external onlyOwner { Role[Contract] = 0x0; }
36,120
63
// Provides information about the current execution context, including thesender of the transaction and its data. While these are generally availablevia msg.sender and msg.data, they should not be accessed in such a directmanner, since when dealing with GSN meta-transactions the account sending andpaying for execution may not be the actual sender (as far as an applicationis concerned). This contract is only required for intermediate, library-like contracts. /
abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
146
15
// Store array keywords and encrypted data in a mapping
function storeMultiple(string[] memory keywords, string memory encryptedData) public { for (uint i = 0; i < keywords.length; i++) { keywordToData[keywords[i]].push(encryptedData); } }
function storeMultiple(string[] memory keywords, string memory encryptedData) public { for (uint i = 0; i < keywords.length; i++) { keywordToData[keywords[i]].push(encryptedData); } }
14,613
38
// Declare a variable indicating if the order is not a contract order. Cache in scratch space to avoid stack depth errors.
let isNonContract := lt(orderType, 4) mstore(0, isNonContract)
let isNonContract := lt(orderType, 4) mstore(0, isNonContract)
16,840
105
// if (_mintId > 100 && _mintId < 301) {
if (_mintId < 555) { require(tokenQuantity <= FEMVERSE_PER_FREE_MINT, "EXCEED_FEMVERSE_PER_FREE_MINT"); _safeMint(msg.sender, _mintId); publicAmountMinted++; } else {
if (_mintId < 555) { require(tokenQuantity <= FEMVERSE_PER_FREE_MINT, "EXCEED_FEMVERSE_PER_FREE_MINT"); _safeMint(msg.sender, _mintId); publicAmountMinted++; } else {
9,455
49
// Skip the copy if element to be removed is already the last element // Copy last element to the requested element's "hole" ///
stakeListRef.pop();
stakeListRef.pop();
9,701
41
// sign up for validator committee /
function signup() public { require(!signupValidatorsCheck[msg.sender], "already signed up"); uint plannedBlocks; uint actualBlocks; uint efficiency; (plannedBlocks, actualBlocks, efficiency) = consensus.getValidatorBlockInfo(msg.sender); require(actualBlocks >= MINIMAL_SIGNUP_BLOCKS, "not enough blocks produced"); Validator storage validator = validators[msg.sender]; validator.plannedBlocks = plannedBlocks; validator.actualBlocks = actualBlocks; validator.efficiency = efficiency; validator.existed = true; signupValidatorsCheck[msg.sender] = true; signupValidators.push(msg.sender); emit SignupCommitteeEvent(round, msg.sender); }
function signup() public { require(!signupValidatorsCheck[msg.sender], "already signed up"); uint plannedBlocks; uint actualBlocks; uint efficiency; (plannedBlocks, actualBlocks, efficiency) = consensus.getValidatorBlockInfo(msg.sender); require(actualBlocks >= MINIMAL_SIGNUP_BLOCKS, "not enough blocks produced"); Validator storage validator = validators[msg.sender]; validator.plannedBlocks = plannedBlocks; validator.actualBlocks = actualBlocks; validator.efficiency = efficiency; validator.existed = true; signupValidatorsCheck[msg.sender] = true; signupValidators.push(msg.sender); emit SignupCommitteeEvent(round, msg.sender); }
45,848
1
// Initializes the msg.sender as 1000.
constructor() Ownable() { _weighted[msg.sender] = DENOMINATOR; }
constructor() Ownable() { _weighted[msg.sender] = DENOMINATOR; }
24,547
156
// See {ERC20-_mint}. Requirements: - the caller must have the {MinterRole}. /
function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; }
function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; }
6,998
7
// Integer division of two signed integers truncating the quotient, reverts on division by zero./
function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0); // Solidity only automatically asserts when dividing by 0 require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow int256 c = a / b; return c; }
function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0); // Solidity only automatically asserts when dividing by 0 require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow int256 c = a / b; return c; }
14,128
753
// Burn the full balance
uint poolAmount = S.balanceOf[msg.sender]; if (poolAmount > 0) { S.transfer(address(this), poolAmount); }
uint poolAmount = S.balanceOf[msg.sender]; if (poolAmount > 0) { S.transfer(address(this), poolAmount); }
24,676
3
// Returns last time specific token reward was applicable
function lastTimeRewardApplicable(uint i) public view returns (uint256) { return Math.min(block.timestamp, tokenRewards[i].periodFinish); }
function lastTimeRewardApplicable(uint i) public view returns (uint256) { return Math.min(block.timestamp, tokenRewards[i].periodFinish); }
38,405
0
// totalSupply is updated on its own whether tokens are minted/burned
function totalSupply() public view returns (uint256) { return _totalSupply; }
function totalSupply() public view returns (uint256) { return _totalSupply; }
9,622
149
// Role manager and transfer control
ITransferProvider private transferProvider; IRBAC private rbacManager; address private feeRecipient;
ITransferProvider private transferProvider; IRBAC private rbacManager; address private feeRecipient;
8,876
132
// Pack print properties into a token ID /
function packPrintId(
function packPrintId(
20,972
311
// Resolves an offset stored at `cdPtr + headOffset` to a calldata./pointer `cdPtr` must point to some parent object with a dynamic/type's head stored at `cdPtr + headOffset`.
function pptr( CalldataPointer cdPtr, uint256 headOffset
function pptr( CalldataPointer cdPtr, uint256 headOffset
40,216
46
// patent fee ratio Values 0-10,000 map to 0%-100%
uint256 public feeRatio = 9705; uint256 public patentValidTime = 2 days; uint256 public patentSaleTimeDelay = 2 hours;
uint256 public feeRatio = 9705; uint256 public patentValidTime = 2 days; uint256 public patentSaleTimeDelay = 2 hours;
20,955
20
// Storage update.
idToBox[_boxId] = secondHandClothesBox; customerToBoxesIds[msg.sender].push(_boxId);
idToBox[_boxId] = secondHandClothesBox; customerToBoxesIds[msg.sender].push(_boxId);
19,412
44
// No active position to exit, just send all want to controller as per wrapper withdrawAll() function
function _withdrawAll() internal override { // This strategy doesn't do anything when tokens are withdrawn, wBTC stays in strategy until governance decides // what to do with it }
function _withdrawAll() internal override { // This strategy doesn't do anything when tokens are withdrawn, wBTC stays in strategy until governance decides // what to do with it }
47,731
7
// setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice
setupOwners(_owners, _threshold); if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
setupOwners(_owners, _threshold); if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
30,234
25
// positionposition in a memory blocksizedata sizebasebase dataunbox() extracts the data out of a 256bit word with the given position and returns itbase is checked by validRange() to make sure it is not over size /
) internal pure returns (uint256 unboxed) { require(validRange(256, base), "Value out of range UNBOX"); assembly { // (((1 << size) - 1) & base >> position) unboxed := and(sub(shl(size, 1), 1), shr(position, base)) } }
) internal pure returns (uint256 unboxed) { require(validRange(256, base), "Value out of range UNBOX"); assembly { // (((1 << size) - 1) & base >> position) unboxed := and(sub(shl(size, 1), 1), shr(position, base)) } }
36,544
47
// linked smart contract
address public worldContract; address public dataContract; address public tradeContract; address public castleContract; address public paymentContract;
address public worldContract; address public dataContract; address public tradeContract; address public castleContract; address public paymentContract;
3,076
187
// Only allow the project contract as caller.
modifier onlyProject () { require(_msgSender() == projectAddress, "Only the parent Project contract can call this method"); _; }
modifier onlyProject () { require(_msgSender() == projectAddress, "Only the parent Project contract can call this method"); _; }
40,809
0
// History interface
interface IHistory { // Permissioned functions /// @notice Submit a claim. /// The encoding of `_claimData` might vary /// depending on the history implementation. /// @param _claimData Data for submitting a claim /// @dev Should have access control. function submitClaim(bytes calldata _claimData) external; /// @notice Transfer ownership to another consensus. /// @param _consensus The new consensus /// @dev Should have access control. function migrateToConsensus(address _consensus) external; // Permissionless functions /// @notice Get a specific claim regarding a specific DApp. /// The encoding of `_proofContext` might vary /// depending on the history implementation. /// @param _dapp The DApp address /// @param _proofContext Data for retrieving the desired claim /// @return epochHash_ The claimed epoch hash /// @return firstInputIndex_ The index of the first input of the epoch in the input box /// @return lastInputIndex_ The index of the last input of the epoch in the input box function getClaim( address _dapp, bytes calldata _proofContext ) external view returns ( bytes32 epochHash_, uint256 firstInputIndex_, uint256 lastInputIndex_ ); }
interface IHistory { // Permissioned functions /// @notice Submit a claim. /// The encoding of `_claimData` might vary /// depending on the history implementation. /// @param _claimData Data for submitting a claim /// @dev Should have access control. function submitClaim(bytes calldata _claimData) external; /// @notice Transfer ownership to another consensus. /// @param _consensus The new consensus /// @dev Should have access control. function migrateToConsensus(address _consensus) external; // Permissionless functions /// @notice Get a specific claim regarding a specific DApp. /// The encoding of `_proofContext` might vary /// depending on the history implementation. /// @param _dapp The DApp address /// @param _proofContext Data for retrieving the desired claim /// @return epochHash_ The claimed epoch hash /// @return firstInputIndex_ The index of the first input of the epoch in the input box /// @return lastInputIndex_ The index of the last input of the epoch in the input box function getClaim( address _dapp, bytes calldata _proofContext ) external view returns ( bytes32 epochHash_, uint256 firstInputIndex_, uint256 lastInputIndex_ ); }
8,921
6
// Status stage
WorkflowStatus status;
WorkflowStatus status;
12,862
12
// get a human-readable version for the distributor that describes basic functionality The version should update whenever functionality significantly changes On-chain consumers should rely on registered ERC165 interface IDs or similar for more specificity/
function VERSION() external view returns (uint256);
function VERSION() external view returns (uint256);
15,037
9
// RewardsPool Events
event DepositAdded(address indexed _to, uint256 _deposit); event RewardAdded(address indexed _to, uint256 _reward); event ParticipantAdded(address indexed _participating); event ParticipantRemoved(address indexed _removed);
event DepositAdded(address indexed _to, uint256 _deposit); event RewardAdded(address indexed _to, uint256 _reward); event ParticipantAdded(address indexed _participating); event ParticipantRemoved(address indexed _removed);
19,203
35
// Leading zero bytes are converted to '1';
bytes memory b58_encoding = new bytes(leading_zeros + digitlength); for (uint8 i = 0; i < leading_zeros; i++) { b58_encoding[i] = '1'; }
bytes memory b58_encoding = new bytes(leading_zeros + digitlength); for (uint8 i = 0; i < leading_zeros; i++) { b58_encoding[i] = '1'; }
26,129
124
// owed = amount1e18 / (totalSupply1e18 / home) = amounthome / totalSupply
uint token_ratio = ampl_token.totalSupply().mul(1e18).div(home); uint owed = amount.mul(1e18).div(token_ratio); _mint(msg.sender,owed);
uint token_ratio = ampl_token.totalSupply().mul(1e18).div(home); uint owed = amount.mul(1e18).div(token_ratio); _mint(msg.sender,owed);
33,153
161
// Constructs the BlackfarmingToken contract. /
constructor() public ERC20("Farming Token", "FARMING") { _operator = _msgSender(); emit OperatorTransferred(address(0), _operator); _excludedFromAntiWhale[msg.sender] = true; _excludedFromAntiWhale[address(0)] = true; _excludedFromAntiWhale[address(this)] = true; _excludedFromAntiWhale[BURN_ADDRESS] = true; }
constructor() public ERC20("Farming Token", "FARMING") { _operator = _msgSender(); emit OperatorTransferred(address(0), _operator); _excludedFromAntiWhale[msg.sender] = true; _excludedFromAntiWhale[address(0)] = true; _excludedFromAntiWhale[address(this)] = true; _excludedFromAntiWhale[BURN_ADDRESS] = true; }
24,563
80
// Owner operated switch to accept/decline deposits to the contract
function acceptDeposits(bool _accept) public noReentry onlyOwner returns (bool)
function acceptDeposits(bool _accept) public noReentry onlyOwner returns (bool)
46,443
21
// public for testing only declare within function after testing
swapOut = orderTokenSwap(_orderID, orderAttributes.fromTokenAmount, swapOutMin);
swapOut = orderTokenSwap(_orderID, orderAttributes.fromTokenAmount, swapOutMin);
36,251