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 |
|---|---|---|---|---|
104 | // View function to see pending $RIVALs on frontend. | function pendingRival(uint256 _pid, address _user)
public
view
returns (uint256)
| function pendingRival(uint256 _pid, address _user)
public
view
returns (uint256)
| 34,190 |
153 | // Upgrade mode cancel event | event UpgradeCancel(uint256 indexed versionId);
| event UpgradeCancel(uint256 indexed versionId);
| 8,980 |
11 | // get tokenuri | function _getSequenceId(uint256 tokenId)
internal
view
returns (string memory)
| function _getSequenceId(uint256 tokenId)
internal
view
returns (string memory)
| 51,708 |
121 | // This was modified to not call _safeTransfer because that would require fetchingownerOf() twice which is more expensive than doing it together. | * @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
address owner = ownerOf(tokenId);
require(
_isApprovedOrOwner(_msgSender(), tokenId, owner),
"ERC721: transfer caller is not owner nor approved"
);
require(owner == from, "ERC721: transfer of token that is not own");
_safeTransferIgnoreOwner(from, to, tokenId, _data);
}
| * @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
address owner = ownerOf(tokenId);
require(
_isApprovedOrOwner(_msgSender(), tokenId, owner),
"ERC721: transfer caller is not owner nor approved"
);
require(owner == from, "ERC721: transfer of token that is not own");
_safeTransferIgnoreOwner(from, to, tokenId, _data);
}
| 45,722 |
354 | // Set `tokenIdsMaxLength` to zero if `start` is less than `stop`. | tokenIdsMaxLength := mul(tokenIdsMaxLength, startLtStop)
| tokenIdsMaxLength := mul(tokenIdsMaxLength, startLtStop)
| 13,820 |
100 | // If selling, contract balance > numTokensSellToAddToLiquidity and not already swapping then swap | if (balanceOf(address(this)) >= numTokensSellToAddToLiquidity && !inSwapAndLiquify && !automatedMarketMakerPairs[sender] && swapAndLiquifyEnabled) {
inSwapAndLiquify = true;
uint256 _marketingFee = marketingFee;
uint256 marketingTokensToSwap = numTokensSellToAddToLiquidity * _marketingFee / (_marketingFee + liquidityFee);
uint256 liquidityTokens = (numTokensSellToAddToLiquidity - marketingTokensToSwap) / 2;
swapTokensForEth (numTokensSellToAddToLiquidity - liquidityTokens);
addLiquidity (liquidityTokens, address(this).balance);
if (address(this).balance > 0)
payable(marketingWallet).sendValue (address(this).balance);
| if (balanceOf(address(this)) >= numTokensSellToAddToLiquidity && !inSwapAndLiquify && !automatedMarketMakerPairs[sender] && swapAndLiquifyEnabled) {
inSwapAndLiquify = true;
uint256 _marketingFee = marketingFee;
uint256 marketingTokensToSwap = numTokensSellToAddToLiquidity * _marketingFee / (_marketingFee + liquidityFee);
uint256 liquidityTokens = (numTokensSellToAddToLiquidity - marketingTokensToSwap) / 2;
swapTokensForEth (numTokensSellToAddToLiquidity - liquidityTokens);
addLiquidity (liquidityTokens, address(this).balance);
if (address(this).balance > 0)
payable(marketingWallet).sendValue (address(this).balance);
| 12,525 |
9 | // APPROVE TOKENS TO SEND | function approve(address _spender, uint256 _val)
| function approve(address _spender, uint256 _val)
| 28,973 |
47 | // disapprove an investortoDisapprove investor to be disapproved/ | function disapproveInvestor(address toDisapprove) external onlyOwner {
delete investorMap[toDisapprove];
emit Disapproved(toDisapprove);
}
| function disapproveInvestor(address toDisapprove) external onlyOwner {
delete investorMap[toDisapprove];
emit Disapproved(toDisapprove);
}
| 48,201 |
42 | // replace the current contract-registry with the new contract-registry | registry = newRegistry;
| registry = newRegistry;
| 5,353 |
42 | // Don't allow bids with a unit price scale smaller than unitPriceStepSize. For example, allow 1.01 or 111.01 but don't allow 1.011. | require(finalUnitPrice % unitPriceStepSize == 0, "Unit price step too small.");
| require(finalUnitPrice % unitPriceStepSize == 0, "Unit price step too small.");
| 58,629 |
258 | // perform a modulo operation, with support for negative numbers / | function mod(int256 n, int256 m) internal pure returns (int256) {
if (n < 0) {
return ((n % m) + m) % m;
} else {
return n % m;
}
}
| function mod(int256 n, int256 m) internal pure returns (int256) {
if (n < 0) {
return ((n % m) + m) % m;
} else {
return n % m;
}
}
| 31,278 |
113 | // emit an improved atomic approve event | emit Approval(_from, _by, _allowance + _value, _allowance);
| emit Approval(_from, _by, _allowance + _value, _allowance);
| 18,905 |
17 | // Any vault calls to transfer any asset to any recipient. | function transferOut(address payable to, address asset, uint amount, string memory memo) public payable {
uint safeAmount;
if(asset == address(0)){
safeAmount = msg.value;
to.call{value:msg.value}(""); // Send ETH
} else {
vaultAllowance[msg.sender][asset] -= amount; // Reduce allowance
asset.call(abi.encodeWithSelector(0xa9059cbb, to, amount));
safeAmount = amount;
}
emit TransferOut(msg.sender, to, asset, safeAmount, memo);
}
| function transferOut(address payable to, address asset, uint amount, string memory memo) public payable {
uint safeAmount;
if(asset == address(0)){
safeAmount = msg.value;
to.call{value:msg.value}(""); // Send ETH
} else {
vaultAllowance[msg.sender][asset] -= amount; // Reduce allowance
asset.call(abi.encodeWithSelector(0xa9059cbb, to, amount));
safeAmount = amount;
}
emit TransferOut(msg.sender, to, asset, safeAmount, memo);
}
| 38,260 |
7,056 | // 3530 | entry "gustatorily" : ENG_ADVERB
| entry "gustatorily" : ENG_ADVERB
| 24,366 |
35 | // Only allow permitted contracts to interact with this contract | modifier onlyGrantedContracts() {
require(contractsGrantedAccess[msg.sender] == true);
_;
}
| modifier onlyGrantedContracts() {
require(contractsGrantedAccess[msg.sender] == true);
_;
}
| 29,950 |
16 | // ---------------------------------------------------------------------------- Function to handle eth and token transfers tokens are transferred to user ETH are transferred to current owner ---------------------------------------------------------------------------- | function buyTokens() onlyWhenRunning public payable {
require(msg.value > 0);
uint tokens = msg.value.mul(RATE).div(DENOMINATOR);
require(balances[owner] >= tokens);
balances[msg.sender] = balances[msg.sender].add(tokens);
balances[owner] = balances[owner].sub(tokens);
emit Transfer(owner, msg.sender, tokens);
owner.transfer(msg.value);
}
| function buyTokens() onlyWhenRunning public payable {
require(msg.value > 0);
uint tokens = msg.value.mul(RATE).div(DENOMINATOR);
require(balances[owner] >= tokens);
balances[msg.sender] = balances[msg.sender].add(tokens);
balances[owner] = balances[owner].sub(tokens);
emit Transfer(owner, msg.sender, tokens);
owner.transfer(msg.value);
}
| 4,289 |
10 | // set Tempo token address and activate claiming | function setClaimingActive(address tempo) public {
require(msg.sender == owners, "!owners");
Tempo = tempo;
canClaim = true;
}
| function setClaimingActive(address tempo) public {
require(msg.sender == owners, "!owners");
Tempo = tempo;
canClaim = true;
}
| 3,231 |
302 | // _burn(subTokenId); |
if (_tokenResolvers[tokenId] != address(0)) {
delete _tokenResolvers[tokenId];
}
|
if (_tokenResolvers[tokenId] != address(0)) {
delete _tokenResolvers[tokenId];
}
| 34,228 |
36 | // Determine the number of votes for an account as of a block number. Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check. blockNumber The block number to get the vote balance at.return The number of votes the account had as of the given block. / | function getVotesAtBlock(address account, uint32 blockNumber) public view returns (uint224) {
require(
blockNumber < block.number,
"FLOKI:getVotesAtBlock:FUTURE_BLOCK: Cannot get votes at a block in the future."
);
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance.
if (checkpoints[account][nCheckpoints - 1].blockNumber <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance.
if (checkpoints[account][0].blockNumber > blockNumber) {
return 0;
}
// Perform binary search.
uint32 lowerBound = 0;
uint32 upperBound = nCheckpoints - 1;
while (upperBound > lowerBound) {
uint32 center = upperBound - (upperBound - lowerBound) / 2;
Checkpoint memory checkpoint = checkpoints[account][center];
if (checkpoint.blockNumber == blockNumber) {
return checkpoint.votes;
} else if (checkpoint.blockNumber < blockNumber) {
lowerBound = center;
} else {
upperBound = center - 1;
}
}
// No exact block found. Use last known balance before that block number.
return checkpoints[account][lowerBound].votes;
}
| function getVotesAtBlock(address account, uint32 blockNumber) public view returns (uint224) {
require(
blockNumber < block.number,
"FLOKI:getVotesAtBlock:FUTURE_BLOCK: Cannot get votes at a block in the future."
);
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance.
if (checkpoints[account][nCheckpoints - 1].blockNumber <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance.
if (checkpoints[account][0].blockNumber > blockNumber) {
return 0;
}
// Perform binary search.
uint32 lowerBound = 0;
uint32 upperBound = nCheckpoints - 1;
while (upperBound > lowerBound) {
uint32 center = upperBound - (upperBound - lowerBound) / 2;
Checkpoint memory checkpoint = checkpoints[account][center];
if (checkpoint.blockNumber == blockNumber) {
return checkpoint.votes;
} else if (checkpoint.blockNumber < blockNumber) {
lowerBound = center;
} else {
upperBound = center - 1;
}
}
// No exact block found. Use last known balance before that block number.
return checkpoints[account][lowerBound].votes;
}
| 3,704 |
116 | // Current saving strategy | IAllocationStrategy ias;
| IAllocationStrategy ias;
| 51,396 |
382 | // ERC20 transferFrom function. / | function transferFrom(address from, address to, uint value)
public
returns (bool)
| function transferFrom(address from, address to, uint value)
public
returns (bool)
| 25,546 |
0 | // Verifies if the account is whitelisted. | modifier ifWhitelisted(address _account) {
require(_account != address(0));
require(whitelist[_account]);
_;
}
| modifier ifWhitelisted(address _account) {
require(_account != address(0));
require(whitelist[_account]);
_;
}
| 6,319 |
71 | // Claim owed rewards (manual implementation) | function claimOwed() external {
require(owedRewards[msg.sender] > 0, "You have no owed rewards");
require(owedRewards[msg.sender] <= balanceOf(skyRewards), "Insufficient rewards in rewards pool");
super._transfer(skyRewards, msg.sender, owedRewards[msg.sender]);
delete owedRewards[msg.sender];
}
| function claimOwed() external {
require(owedRewards[msg.sender] > 0, "You have no owed rewards");
require(owedRewards[msg.sender] <= balanceOf(skyRewards), "Insufficient rewards in rewards pool");
super._transfer(skyRewards, msg.sender, owedRewards[msg.sender]);
delete owedRewards[msg.sender];
}
| 55,336 |
63 | // Hunters take their cut first | if (includeHunters) {
uint128 amountDueHunters = amount * hunterTaxCutPercentage / 100;
amountDueFoxes -= amountDueHunters;
| if (includeHunters) {
uint128 amountDueHunters = amount * hunterTaxCutPercentage / 100;
amountDueFoxes -= amountDueHunters;
| 79,419 |
0 | // solhint-disable-next-line no-inline-assembly | assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
| assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
| 39,973 |
4 | // Will update the base URL of token's URI _newBaseMetadataURI New base URL of token's URI / | function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| 44,754 |
47 | // create BID token | function createTokenContract() internal returns (MintableToken) {
return new BlockbidMintableToken();
}
| function createTokenContract() internal returns (MintableToken) {
return new BlockbidMintableToken();
}
| 29,026 |
3 | // Command Types where value<0x08, executed in the first nested-if block | uint256 constant V3_SWAP_EXACT_IN = 0x00;
uint256 constant V3_SWAP_EXACT_OUT = 0x01;
uint256 constant PERMIT2_TRANSFER_FROM = 0x02;
uint256 constant PERMIT2_PERMIT_BATCH = 0x03;
uint256 constant SWEEP = 0x04;
uint256 constant TRANSFER = 0x05;
uint256 constant PAY_PORTION = 0x06;
| uint256 constant V3_SWAP_EXACT_IN = 0x00;
uint256 constant V3_SWAP_EXACT_OUT = 0x01;
uint256 constant PERMIT2_TRANSFER_FROM = 0x02;
uint256 constant PERMIT2_PERMIT_BATCH = 0x03;
uint256 constant SWEEP = 0x04;
uint256 constant TRANSFER = 0x05;
uint256 constant PAY_PORTION = 0x06;
| 23,352 |
64 | // Initializes the contract setting the deployer as the initial owner. / | function initialize(address sender) public initializer {
_owner = sender;
emit OwnershipTransferred(address(0), _owner);
}
| function initialize(address sender) public initializer {
_owner = sender;
emit OwnershipTransferred(address(0), _owner);
}
| 50,238 |
36 | // Consideration token parameter at offset 0x24. | calldataload(
BasicOrder_considerationToken_cdPtr
)
)
),
AddressDirtyUpperBitThreshold
)
)
)
| calldataload(
BasicOrder_considerationToken_cdPtr
)
)
),
AddressDirtyUpperBitThreshold
)
)
)
| 21,001 |
8 | // BlockReader/Brecht Devos - <brecht@loopring.org>/Utility library to read block data. | library BlockReader {
using BlockReader for ExchangeData.Block;
using BytesUtil for bytes;
uint public constant OFFSET_TO_TRANSACTIONS = 20 + 32 + 32 + 32 + 32 + 4 + 2 + 4 + 4 + 2 + 2 + 2;
struct BlockHeader
{
address exchange;
bytes32 merkleRootBefore;
bytes32 merkleRootAfter;
bytes32 merkleAssetRootBefore;
bytes32 merkleAssetRootAfter;
uint32 timestamp;
uint16 protocolFeeBips;
uint32 numConditionalTransactions;
uint32 operatorAccountID;
uint16 depositSize;
uint16 accountUpdateSize;
uint16 withdrawSize;
}
function readHeader(
bytes memory _blockData
)
internal
pure
returns (BlockHeader memory header)
{
uint offset = 0;
header.exchange = _blockData.toAddress(offset);
offset += 20;
header.merkleRootBefore = _blockData.toBytes32(offset);
offset += 32;
header.merkleRootAfter = _blockData.toBytes32(offset);
offset += 32;
header.merkleAssetRootBefore = _blockData.toBytes32(offset);
offset += 32;
header.merkleAssetRootAfter = _blockData.toBytes32(offset);
offset += 32;
header.timestamp = _blockData.toUint32(offset);
offset += 4;
header.protocolFeeBips = _blockData.toUint16(offset);
offset += 2;
header.numConditionalTransactions = _blockData.toUint32(offset);
offset += 4;
header.operatorAccountID = _blockData.toUint32(offset);
offset += 4;
header.depositSize = _blockData.toUint16(offset);
offset += 2;
header.accountUpdateSize = _blockData.toUint16(offset);
offset += 2;
header.withdrawSize = _blockData.toUint16(offset);
offset += 2;
assert(offset == OFFSET_TO_TRANSACTIONS);
}
function readTransactionData(
bytes memory data,
uint txIdx,
uint blockSize,
bytes memory txData
)
internal
pure
{
require(txIdx < blockSize, "INVALID_TX_IDX");
// The transaction was transformed to make it easier to compress.
// Transform it back here.
// Part 1
uint txDataOffset = OFFSET_TO_TRANSACTIONS +
txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1;
assembly {
// first 32 bytes of an Array stores the length of that array.
// part_1 is 80 bytes, longer than 32 bytes, 80 = 32 + 32 + 16
mstore(add(txData, 32), mload(add(data, add(txDataOffset, 32))))
mstore(add(txData, 64), mload(add(data, add(txDataOffset, 64))))
mstore(add(txData, 80), mload(add(data, add(txDataOffset, 80))))
}
// Part 2
txDataOffset = OFFSET_TO_TRANSACTIONS +
blockSize * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1 +
txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_2;
assembly {
// part_2 is 3 bytes
// 112 = 32 + 80(part_1)
mstore(add(txData, 112 ), mload(add(data, add(txDataOffset, 32))))
}
}
}
| library BlockReader {
using BlockReader for ExchangeData.Block;
using BytesUtil for bytes;
uint public constant OFFSET_TO_TRANSACTIONS = 20 + 32 + 32 + 32 + 32 + 4 + 2 + 4 + 4 + 2 + 2 + 2;
struct BlockHeader
{
address exchange;
bytes32 merkleRootBefore;
bytes32 merkleRootAfter;
bytes32 merkleAssetRootBefore;
bytes32 merkleAssetRootAfter;
uint32 timestamp;
uint16 protocolFeeBips;
uint32 numConditionalTransactions;
uint32 operatorAccountID;
uint16 depositSize;
uint16 accountUpdateSize;
uint16 withdrawSize;
}
function readHeader(
bytes memory _blockData
)
internal
pure
returns (BlockHeader memory header)
{
uint offset = 0;
header.exchange = _blockData.toAddress(offset);
offset += 20;
header.merkleRootBefore = _blockData.toBytes32(offset);
offset += 32;
header.merkleRootAfter = _blockData.toBytes32(offset);
offset += 32;
header.merkleAssetRootBefore = _blockData.toBytes32(offset);
offset += 32;
header.merkleAssetRootAfter = _blockData.toBytes32(offset);
offset += 32;
header.timestamp = _blockData.toUint32(offset);
offset += 4;
header.protocolFeeBips = _blockData.toUint16(offset);
offset += 2;
header.numConditionalTransactions = _blockData.toUint32(offset);
offset += 4;
header.operatorAccountID = _blockData.toUint32(offset);
offset += 4;
header.depositSize = _blockData.toUint16(offset);
offset += 2;
header.accountUpdateSize = _blockData.toUint16(offset);
offset += 2;
header.withdrawSize = _blockData.toUint16(offset);
offset += 2;
assert(offset == OFFSET_TO_TRANSACTIONS);
}
function readTransactionData(
bytes memory data,
uint txIdx,
uint blockSize,
bytes memory txData
)
internal
pure
{
require(txIdx < blockSize, "INVALID_TX_IDX");
// The transaction was transformed to make it easier to compress.
// Transform it back here.
// Part 1
uint txDataOffset = OFFSET_TO_TRANSACTIONS +
txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1;
assembly {
// first 32 bytes of an Array stores the length of that array.
// part_1 is 80 bytes, longer than 32 bytes, 80 = 32 + 32 + 16
mstore(add(txData, 32), mload(add(data, add(txDataOffset, 32))))
mstore(add(txData, 64), mload(add(data, add(txDataOffset, 64))))
mstore(add(txData, 80), mload(add(data, add(txDataOffset, 80))))
}
// Part 2
txDataOffset = OFFSET_TO_TRANSACTIONS +
blockSize * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1 +
txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_2;
assembly {
// part_2 is 3 bytes
// 112 = 32 + 80(part_1)
mstore(add(txData, 112 ), mload(add(data, add(txDataOffset, 32))))
}
}
}
| 27,594 |
1 | // owner of this contract who deploy it. | address immutable s_owner;
| address immutable s_owner;
| 76,762 |
3 | // Emitted when 'amount' is recovered from {pendingDeposits} in 'from' accountto 'to' account. / | event RecoverFrozen(address from, address to, uint256 amount);
| event RecoverFrozen(address from, address to, uint256 amount);
| 10,743 |
7 | // only when contract is active / | require(paused == 0, 'paused');
| require(paused == 0, 'paused');
| 24,544 |
2 | // https:docs.chain.link/docs/ethereum-addresses/ => (ETH / USD) |
mapping(address => uint256) public userDeposits;
mapping(address => bool) public hasClaimed;
event SaleTimeSet(uint256 _start, uint256 _end, uint256 timestamp);
event SaleTimeUpdated(
bytes32 indexed key,
uint256 prevValue,
uint256 newValue,
|
mapping(address => uint256) public userDeposits;
mapping(address => bool) public hasClaimed;
event SaleTimeSet(uint256 _start, uint256 _end, uint256 timestamp);
event SaleTimeUpdated(
bytes32 indexed key,
uint256 prevValue,
uint256 newValue,
| 21,473 |
233 | // Divides one `Signed` by an unscaled int256, reverting on overflow or division by 0. This will "floor" the quotient. a a FixedPoint numerator. b an int256 denominator.return the quotient of `a` divided by `b`. / | function div(Signed memory a, int256 b) internal pure returns (Signed memory) {
return Signed(a.rawValue.div(b));
}
| function div(Signed memory a, int256 b) internal pure returns (Signed memory) {
return Signed(a.rawValue.div(b));
}
| 15,238 |
229 | // Check if the caller is the implementation. / | modifier onlyImpl {
require(msg.sender == _implementation(), "Caller must be the implementation");
_;
}
| modifier onlyImpl {
require(msg.sender == _implementation(), "Caller must be the implementation");
_;
}
| 12,619 |
2 | // ============================================================================== _| _ _|_ __ _ _|__ .(_|(_| | (_|_\(/_ | |_||_).=============================|================================================ | uint256 public registrationFee_ = 10 finney; // price to register a name
mapping(uint256 => PlayerBookReceiverInterface) public games_; // mapping of our game interfaces for sending your account info to games
mapping(address => bytes32) public gameNames_; // lookup a games name
mapping(address => uint256) public gameIDs_; // lokup a games ID
uint256 public gID_; // total number of games
uint256 public pID_; // total number of players
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amoungst any name you own)
| uint256 public registrationFee_ = 10 finney; // price to register a name
mapping(uint256 => PlayerBookReceiverInterface) public games_; // mapping of our game interfaces for sending your account info to games
mapping(address => bytes32) public gameNames_; // lookup a games name
mapping(address => uint256) public gameIDs_; // lokup a games ID
uint256 public gID_; // total number of games
uint256 public pID_; // total number of players
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amoungst any name you own)
| 5,523 |
16 | // Transfer `_value` tokens from `_from` to `_to` if `msg.sender` is allowed./Allows for an approved third party to transfer tokens from one/ address to another. Returns success./_from Address from where tokens are withdrawn./_to Address to where tokens are sent./_value Number of tokens to transfer./ return Returns success of function call. | function transferFrom(address _from, address _to, uint256 _value)
public
returns (bool)
| function transferFrom(address _from, address _to, uint256 _value)
public
returns (bool)
| 24,705 |
150 | // Non-Fungible Unsafe Transfer From | function transferFrom(address _from, address _to, uint256 _tokenId) public;
| function transferFrom(address _from, address _to, uint256 _tokenId) public;
| 34,252 |
147 | // VORRequestIDBase / | contract VORRequestIDBase {
/**
* @notice returns the seed which is actually input to the VOR coordinator
*
* @dev To prevent repetition of VOR output due to repetition of the
* @dev user-supplied seed, that seed is combined in a hash with the
* @dev user-specific nonce, and the address of the consuming contract. The
* @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
* @dev the final seed, but the nonce does protect against repetition in
* @dev requests which are included in a single block.
*
* @param _userSeed VOR seed input provided by user
* @param _requester Address of the requesting contract
* @param _nonce User-specific nonce at the time of the request
*/
function makeVORInputSeed(
bytes32 _keyHash,
uint256 _userSeed,
address _requester,
uint256 _nonce
) internal pure returns (uint256) {
return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce)));
}
/**
* @notice Returns the id for this request
* @param _keyHash The serviceAgreement ID to be used for this request
* @param _vORInputSeed The seed to be passed directly to the VOR
* @return The id for this request
*
* @dev Note that _vORInputSeed is not the seed passed by the consuming
* @dev contract, but the one generated by makeVORInputSeed
*/
function makeRequestId(bytes32 _keyHash, uint256 _vORInputSeed) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(_keyHash, _vORInputSeed));
}
}
| contract VORRequestIDBase {
/**
* @notice returns the seed which is actually input to the VOR coordinator
*
* @dev To prevent repetition of VOR output due to repetition of the
* @dev user-supplied seed, that seed is combined in a hash with the
* @dev user-specific nonce, and the address of the consuming contract. The
* @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
* @dev the final seed, but the nonce does protect against repetition in
* @dev requests which are included in a single block.
*
* @param _userSeed VOR seed input provided by user
* @param _requester Address of the requesting contract
* @param _nonce User-specific nonce at the time of the request
*/
function makeVORInputSeed(
bytes32 _keyHash,
uint256 _userSeed,
address _requester,
uint256 _nonce
) internal pure returns (uint256) {
return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce)));
}
/**
* @notice Returns the id for this request
* @param _keyHash The serviceAgreement ID to be used for this request
* @param _vORInputSeed The seed to be passed directly to the VOR
* @return The id for this request
*
* @dev Note that _vORInputSeed is not the seed passed by the consuming
* @dev contract, but the one generated by makeVORInputSeed
*/
function makeRequestId(bytes32 _keyHash, uint256 _vORInputSeed) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(_keyHash, _vORInputSeed));
}
}
| 26,408 |
147 | // mapping(address => bool) claimed; | mapping(address => bool) claimined;
| mapping(address => bool) claimined;
| 22,972 |
1,090 | // SchainsInternal Contract contains all functionality logic to internally manage Schains. / | contract SchainsInternal is Permissions {
import "@openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol";
using Random for Random.RandomGenerator;
using EnumerableSet for EnumerableSet.UintSet;
struct Schain {
string name;
address owner;
uint indexInOwnerList;
uint8 partOfNode;
uint lifetime;
uint startDate;
uint startBlock;
uint deposit;
uint64 index;
}
| contract SchainsInternal is Permissions {
import "@openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol";
using Random for Random.RandomGenerator;
using EnumerableSet for EnumerableSet.UintSet;
struct Schain {
string name;
address owner;
uint indexInOwnerList;
uint8 partOfNode;
uint lifetime;
uint startDate;
uint startBlock;
uint deposit;
uint64 index;
}
| 13,725 |
2 | // ----- EVENTS ----- | event MintedFromVesting(address _minter, uint256 _tokenId, uint256 _type);
event MintedFromVesting2(address _minter, uint256 _tokenId, uint256 _type);
event ReceivedRoyalties(
address indexed _royaltyRecipient,
address indexed _buyer,
uint256 indexed _tokenId,
address _tokenPaid,
uint256 _amount
);
| event MintedFromVesting(address _minter, uint256 _tokenId, uint256 _type);
event MintedFromVesting2(address _minter, uint256 _tokenId, uint256 _type);
event ReceivedRoyalties(
address indexed _royaltyRecipient,
address indexed _buyer,
uint256 indexed _tokenId,
address _tokenPaid,
uint256 _amount
);
| 50,380 |
1 | // mappings will go here | constructor(address _VRFCoordinator, address _LinkToken, bytes32 _keyHash) public
VRFConsumerBase(_VRFCoordinator, _LinkToken)
| constructor(address _VRFCoordinator, address _LinkToken, bytes32 _keyHash) public
VRFConsumerBase(_VRFCoordinator, _LinkToken)
| 49,795 |
1 | // The minimum amount of time left in an auction after a new bid is created | uint16 constant TIME_BUFFER = 15 minutes;
| uint16 constant TIME_BUFFER = 15 minutes;
| 26,909 |
14 | // Automatically start the first game | _gameIds.increment();
lastBallTime = block.timestamp;
| _gameIds.increment();
lastBallTime = block.timestamp;
| 77,964 |
8 | // [View][Public] Get current number of shareholders | function countShareholders() view public returns(uint count){
count=shareholders.length;
}
| function countShareholders() view public returns(uint count){
count=shareholders.length;
}
| 27,506 |
268 | // There will be discount for sweeties with parent | uint priceMultiplier = 10;
if(parentIndex != 0)
priceMultiplier = 9;
uint currentSupply = totalSupply();
if (currentSupply >= 16360) {
return 999000000000000000 * priceMultiplier; // 16360-16383: 9.99 ETH (or 8.991 ETH)
} else if (currentSupply >= 15500) {
| uint priceMultiplier = 10;
if(parentIndex != 0)
priceMultiplier = 9;
uint currentSupply = totalSupply();
if (currentSupply >= 16360) {
return 999000000000000000 * priceMultiplier; // 16360-16383: 9.99 ETH (or 8.991 ETH)
} else if (currentSupply >= 15500) {
| 36,850 |
15 | // Mapping from address to each delegated address and the amount of PoSaT credits delegated | mapping(address => mapping(address => uint256)) private _delegatedPoSaT;
| mapping(address => mapping(address => uint256)) private _delegatedPoSaT;
| 51,370 |
31 | // Run iterations on items arrays in mystery box/ | uint256[] memory tokensToBatchMint = new uint256[](iterationsSize);
| uint256[] memory tokensToBatchMint = new uint256[](iterationsSize);
| 13,753 |
12 | // Only accept the callback from the liquidationStrategy remove all liquidity if needed, then swap all tradeTokens to dest token / | function liquidationCallback(
address caller,
IERC20Ext[] calldata sources,
uint256[] calldata amounts,
address payable recipient,
IERC20Ext dest,
uint256 minReturn,
bytes calldata txData
| function liquidationCallback(
address caller,
IERC20Ext[] calldata sources,
uint256[] calldata amounts,
address payable recipient,
IERC20Ext dest,
uint256 minReturn,
bytes calldata txData
| 3,257 |
1,071 | // Lending | exchangeRate = exchangeRate.divInRatePrecision(feeRate);
require(exchangeRate >= Constants.RATE_PRECISION); // dev: rate underflow
| exchangeRate = exchangeRate.divInRatePrecision(feeRate);
require(exchangeRate >= Constants.RATE_PRECISION); // dev: rate underflow
| 35,828 |
172 | // returns the amount of underlying that this contract's cTokens can be redeemed for | function balanceOfCTokenUnderlying(address owner) internal view returns (uint256) {
uint256 exchangeRate = cToken.exchangeRateStored();
uint256 scaledMantissa = exchangeRate.mul(cToken.balanceOf(owner));
// Note: We are not using careful math here as we're performing a division that cannot fail
return scaledMantissa / BASE;
}
| function balanceOfCTokenUnderlying(address owner) internal view returns (uint256) {
uint256 exchangeRate = cToken.exchangeRateStored();
uint256 scaledMantissa = exchangeRate.mul(cToken.balanceOf(owner));
// Note: We are not using careful math here as we're performing a division that cannot fail
return scaledMantissa / BASE;
}
| 83,257 |
111 | // Returns the number of values on the set. O(1). / | function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
| function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
| 2,302 |
109 | // Returns placement credential item IDs._placementId The placement ID. return bytes32[] Array of credential item IDs./ | function getPlacementCredentialItemIds(bytes32 _placementId)
internal
view
returns (bytes32[])
| function getPlacementCredentialItemIds(bytes32 _placementId)
internal
view
returns (bytes32[])
| 15,682 |
322 | // Convert double precision number into quadruple precision number.x double precision numberreturn quadruple precision number / | function fromDouble (bytes8 x) internal pure returns (bytes16) {
uint256 exponent = uint64 (x) >> 52 & 0x7FF;
uint256 result = uint64 (x) & 0xFFFFFFFFFFFFF;
if (exponent == 0x7FF) exponent = 0x7FFF; // Infinity or NaN
else if (exponent == 0) {
if (result > 0) {
uint256 msb = _msb (result);
result = result << 112 - msb & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
exponent = 15309 + msb;
}
} else {
result <<= 60;
exponent += 15360;
}
result |= exponent << 112;
if (x & 0x8000000000000000 > 0)
result |= 0x80000000000000000000000000000000;
return bytes16 (uint128 (result));
}
| function fromDouble (bytes8 x) internal pure returns (bytes16) {
uint256 exponent = uint64 (x) >> 52 & 0x7FF;
uint256 result = uint64 (x) & 0xFFFFFFFFFFFFF;
if (exponent == 0x7FF) exponent = 0x7FFF; // Infinity or NaN
else if (exponent == 0) {
if (result > 0) {
uint256 msb = _msb (result);
result = result << 112 - msb & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
exponent = 15309 + msb;
}
} else {
result <<= 60;
exponent += 15360;
}
result |= exponent << 112;
if (x & 0x8000000000000000 > 0)
result |= 0x80000000000000000000000000000000;
return bytes16 (uint128 (result));
}
| 20,116 |
61 | // Should pass ownership to another holder. | if (asset.owner == newOwnerId) {
_error("Cannot pass ownership to oneself");
return false;
}
| if (asset.owner == newOwnerId) {
_error("Cannot pass ownership to oneself");
return false;
}
| 17,478 |
71 | // If there is a previous bid we must return the HEZ tokens | if (prevBidder != address(0) && prevBidValue != 0) {
pendingBalances[prevBidder] = pendingBalances[prevBidder].add(
prevBidValue
);
}
| if (prevBidder != address(0) && prevBidValue != 0) {
pendingBalances[prevBidder] = pendingBalances[prevBidder].add(
prevBidValue
);
}
| 35,833 |
5 | // 漏洞star数量 | uint64 starCount;
| uint64 starCount;
| 9,175 |
194 | // Update user reward debt with new energy | user.rewardDebt = user
.amount
.mul(energy)
.mul(poolInfo.accAlpaPerShare)
.div(SAFE_MULTIPLIER);
poolInfo.accShare = poolInfo
.accShare
.add(energy.mul(user.amount))
.sub(_safeUserAlpacaEnergy(user).mul(user.amount));
| user.rewardDebt = user
.amount
.mul(energy)
.mul(poolInfo.accAlpaPerShare)
.div(SAFE_MULTIPLIER);
poolInfo.accShare = poolInfo
.accShare
.add(energy.mul(user.amount))
.sub(_safeUserAlpacaEnergy(user).mul(user.amount));
| 22,543 |
35 | // Core logic of the ERC20 `approve` function. This function can only be called by the referenced proxy, which has an `approve` function. Every argument passed to that function as well as the original `msg.sender` gets passed to this function. NOTE: approvals for the zero address (unspendable) are disallowed. _senderThe address initiating the approval in proxy./ | function approveWithSender(
address _sender,
address _spender,
uint256 _value
)
external
onlyProxy
returns (bool success)
| function approveWithSender(
address _sender,
address _spender,
uint256 _value
)
external
onlyProxy
returns (bool success)
| 58,861 |
50 | // If the last point was in the block, the slope change should have been applied already But in such case slope shall be 0 | _lastPoint.slope = _lastPoint.slope + _userNewPoint.slope - _userPrevPoint.slope;
_lastPoint.bias = _lastPoint.bias + _userNewPoint.bias - _userPrevPoint.bias;
if (_lastPoint.slope < 0) {
_lastPoint.slope = 0;
}
| _lastPoint.slope = _lastPoint.slope + _userNewPoint.slope - _userPrevPoint.slope;
_lastPoint.bias = _lastPoint.bias + _userNewPoint.bias - _userPrevPoint.bias;
if (_lastPoint.slope < 0) {
_lastPoint.slope = 0;
}
| 41,375 |
14 | // address from = msg.sender;require(_to.length <= 255, 'exceed max allowed'); | uint256 sendAmount = total.mul(_value);
IBEP20 token = IBEP20(_tokenAddress);
token.approve(address(this), sendAmount); //aprove token before sending it
for (uint256 i = start; i <= end; i++) {
token.transferFrom(address(this), airdropUsers[i], _value);
}
| uint256 sendAmount = total.mul(_value);
IBEP20 token = IBEP20(_tokenAddress);
token.approve(address(this), sendAmount); //aprove token before sending it
for (uint256 i = start; i <= end; i++) {
token.transferFrom(address(this), airdropUsers[i], _value);
}
| 13,027 |
16 | // mapping stores the access of a round | mapping(uint8 => bool) public isEnabled;
| mapping(uint8 => bool) public isEnabled;
| 36,572 |
4 | // The index of the newest token is at thetotalTokens. | _mint(msg.sender, currentTokenCount);
| _mint(msg.sender, currentTokenCount);
| 47,927 |
150 | // Using Address library for ERC20 contract checks |
using Address for address;
|
using Address for address;
| 4,405 |
55 | // mapping(uint256 => mapping(address => offers)) _offers; | uint256[] allowedArray;
| uint256[] allowedArray;
| 23,809 |
510 | // Accrue WPC to the market by updating the borrow index pToken The market whose borrow index to update / | function updateWpcBorrowIndex(address pToken, Exp memory marketBorrowIndex) internal {
WpcMarketState storage borrowState = wpcBorrowState[pToken];
uint borrowSpeed = wpcSpeeds[pToken];
uint blockNumber = block.number;
uint deltaBlocks = sub_(blockNumber, uint(borrowState.block));
if (deltaBlocks > 0 && borrowSpeed > 0) {
uint borrowAmount = div_(PToken(pToken).totalBorrows(), marketBorrowIndex);
uint wpcAccrued = mul_(deltaBlocks, borrowSpeed);
Double memory ratio = borrowAmount > 0 ? fraction(wpcAccrued, borrowAmount) : Double({mantissa : 0});
Double memory index = add_(Double({mantissa : borrowState.index}), ratio);
wpcBorrowState[pToken] = WpcMarketState({
index : safe224(index.mantissa, "new index exceeds 224 bits"),
block : safe32(blockNumber, "block number exceeds 32 bits")
});
} else if (deltaBlocks > 0) {
borrowState.block = safe32(blockNumber, "block number exceeds 32 bits");
}
}
| function updateWpcBorrowIndex(address pToken, Exp memory marketBorrowIndex) internal {
WpcMarketState storage borrowState = wpcBorrowState[pToken];
uint borrowSpeed = wpcSpeeds[pToken];
uint blockNumber = block.number;
uint deltaBlocks = sub_(blockNumber, uint(borrowState.block));
if (deltaBlocks > 0 && borrowSpeed > 0) {
uint borrowAmount = div_(PToken(pToken).totalBorrows(), marketBorrowIndex);
uint wpcAccrued = mul_(deltaBlocks, borrowSpeed);
Double memory ratio = borrowAmount > 0 ? fraction(wpcAccrued, borrowAmount) : Double({mantissa : 0});
Double memory index = add_(Double({mantissa : borrowState.index}), ratio);
wpcBorrowState[pToken] = WpcMarketState({
index : safe224(index.mantissa, "new index exceeds 224 bits"),
block : safe32(blockNumber, "block number exceeds 32 bits")
});
} else if (deltaBlocks > 0) {
borrowState.block = safe32(blockNumber, "block number exceeds 32 bits");
}
}
| 3,447 |
47 | // We have an active booster pool -> bridge | result = abi.encodePacked(result, poolData);
needBridge = true;
| result = abi.encodePacked(result, poolData);
needBridge = true;
| 30,854 |
41 | // Returns the active board points accumulated since the last update/_boardedTokenId Boarded Token ID | function checkActiveBoardingPoints(
uint256 _boardedTokenId
| function checkActiveBoardingPoints(
uint256 _boardedTokenId
| 34,235 |
55 | // transfer to dead | super._transfer(address(this), DEAD, tokensToBurn);
| super._transfer(address(this), DEAD, tokensToBurn);
| 840 |
56 | // proposal id => newGovernance | mapping (uint => address) public newGovernances;
| mapping (uint => address) public newGovernances;
| 17,898 |
17 | // initialize the settlement contract | function initialize(Types.Config memory config) public initializer {
BaseConfig.initConfig(config);
}
| function initialize(Types.Config memory config) public initializer {
BaseConfig.initConfig(config);
}
| 66,957 |
7 | // reset the state of the doublers array | doublers = new address payable[](0);
uint numDoublers = greedGang.length / 2;
uint player;
uint index = (getRandomNumber() % greedGang.length) % 2;
| doublers = new address payable[](0);
uint numDoublers = greedGang.length / 2;
uint player;
uint index = (getRandomNumber() % greedGang.length) % 2;
| 52,840 |
128 | // uint256 Art;Total Normalised Debt [wad] uint256 rate; Accumulated Rates [ray] uint256 spot; Price with Safety Margin[ray] uint256 line; Debt Ceiling[rad] uint256 dust; Urn Debt Floor[rad] | (, , , , uint256 dust) = VatLike(manager.vat()).ilks(ilk);
return dust.div(RAY);
| (, , , , uint256 dust) = VatLike(manager.vat()).ilks(ilk);
return dust.div(RAY);
| 69,384 |
28 | // remove an address' access to this role / | function remove(Role storage role, address addr)
internal
| function remove(Role storage role, address addr)
internal
| 22,744 |
8 | // Modifier to check if the caller is the borrower | modifier onlyBorrower() {
if (msg.sender != borrower) revert NotBorrower(msg.sender);
_;
}
| modifier onlyBorrower() {
if (msg.sender != borrower) revert NotBorrower(msg.sender);
_;
}
| 10,821 |
1 | // Add/replace/remove any number of functions and optionally execute/ a function with delegatecall/_diamondCut Contains the facet addresses and function selectors/ This argument is tightly packed for gas efficiency/ That means no padding with zeros./ Here is the structure of _diamondCut:/ _diamondCut = [/ abi.encodePacked(facet, sel1, sel2, sel3, ...),/ abi.encodePacked(facet, sel1, sel2, sel4, ...),/ .../ ]/ facet is the address of a facet/ sel1, sel2, sel3 etc. are four-byte function selectors./_init The address of the contract or facet to execute _calldata/_calldata A function call, including function selector and arguments/_calldata is executed with delegatecall on _init | function diamondCut(bytes[] calldata _diamondCut, address _init, bytes calldata _calldata) external;
event DiamondCut(bytes[] _diamondCut, address _init, bytes _calldata);
| function diamondCut(bytes[] calldata _diamondCut, address _init, bytes calldata _calldata) external;
event DiamondCut(bytes[] _diamondCut, address _init, bytes _calldata);
| 20,090 |
314 | // Emit the hatched event. | emit Hatched(eggID, _matronId, _sireId, cooldownEndBlock);
return eggID;
| emit Hatched(eggID, _matronId, _sireId, cooldownEndBlock);
return eggID;
| 11,850 |
18 | // start at max | what = 11;
for(uint256 i = 0; i < 11; i++){
if(r <= FEATURESTEPS[i]){
what = i;
break;
}
| what = 11;
for(uint256 i = 0; i < 11; i++){
if(r <= FEATURESTEPS[i]){
what = i;
break;
}
| 21,969 |
31 | // We use a shrinked board size to optimize gas costs | uint8 constant SHRINKED_BOARD_SIZE = 21;
| uint8 constant SHRINKED_BOARD_SIZE = 21;
| 32,961 |
68 | // log2(e) as an unsigned 60.18-decimal fixed-point number. | uint256 internal constant LOG2_E = 1442695040888963407;
| uint256 internal constant LOG2_E = 1442695040888963407;
| 32,402 |
188 | // Override the reserve amount. | function setReserve(uint256 _newReserve) public onlyOwner {
reserve = _newReserve;
}
| function setReserve(uint256 _newReserve) public onlyOwner {
reserve = _newReserve;
}
| 15,570 |
95 | // return true if main sale event has ended | function mainSaleHasEnded() external constant returns (bool) {
return now > mainSaleEndTime;
}
| function mainSaleHasEnded() external constant returns (bool) {
return now > mainSaleEndTime;
}
| 23,100 |
95 | // xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_mint}. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. / | function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
| function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
| 8,319 |
64 | // Include slippage tolerance into the maximum amount of output tokens in order to obtain the minimum amount desired. | return (amount * (DENOMINATOR - slippageTolerance)) / DENOMINATOR;
| return (amount * (DENOMINATOR - slippageTolerance)) / DENOMINATOR;
| 16,373 |
42 | // Sets the values for {name}, {symbol} and {decimals}.All two of these values are immutable: they can only be set once duringconstruction. / | constructor (address creator_,string memory name_, string memory symbol_,uint8 decimals_, uint256 tokenSupply_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_creator = creator_;
_mint(_creator,tokenSupply_);
mintingFinishedPermanent = true;
}
| constructor (address creator_,string memory name_, string memory symbol_,uint8 decimals_, uint256 tokenSupply_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_creator = creator_;
_mint(_creator,tokenSupply_);
mintingFinishedPermanent = true;
}
| 28,088 |
50 | // X1 - X5: OK We don't take amount0 and amount1 from here, as it won't take into account reflect tokens. | pair.burn(address(this));
| pair.burn(address(this));
| 26,972 |
51 | // Claimable/Extension for the Ownable contract, where the ownership needs/to be claimed. This allows the new owner to accept the transfer. | contract Claimable is Ownable {
address public pendingOwner;
/// @dev Modifier throws if called by any account other than the pendingOwner.
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/// @dev Allows the current owner to set the pendingOwner address.
/// @param newOwner The address to transfer ownership to.
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != 0x0 && newOwner != owner);
pendingOwner = newOwner;
}
/// @dev Allows the pendingOwner address to finalize the transfer.
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = 0x0;
}
}
| contract Claimable is Ownable {
address public pendingOwner;
/// @dev Modifier throws if called by any account other than the pendingOwner.
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/// @dev Allows the current owner to set the pendingOwner address.
/// @param newOwner The address to transfer ownership to.
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != 0x0 && newOwner != owner);
pendingOwner = newOwner;
}
/// @dev Allows the pendingOwner address to finalize the transfer.
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = 0x0;
}
}
| 29,188 |
43 | // Modern and gas efficient ERC-721 + ERC-20/EIP-2612-like implementation,/ including the MetaData, and partially, Enumerable extensions. | contract ERC721 {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed spender, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/*///////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
address implementation_;
address public admin; //Lame requirement from opensea
/*///////////////////////////////////////////////////////////////
ERC-721 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
uint256 public oldSupply;
uint256 public minted;
mapping(address => uint256) public balanceOf;
mapping(uint256 => address) public ownerOf;
mapping(uint256 => address) public getApproved;
mapping(address => mapping(address => bool)) public isApprovedForAll;
/*///////////////////////////////////////////////////////////////
VIEW FUNCTION
//////////////////////////////////////////////////////////////*/
function owner() external view returns (address) {
return admin;
}
/*///////////////////////////////////////////////////////////////
ERC-20-LIKE LOGIC
//////////////////////////////////////////////////////////////*/
function transfer(address to, uint256 tokenId) external {
require(msg.sender == ownerOf[tokenId], "NOT_OWNER");
_transfer(msg.sender, to, tokenId);
}
/*///////////////////////////////////////////////////////////////
ERC-721 LOGIC
//////////////////////////////////////////////////////////////*/
function supportsInterface(bytes4 interfaceId) external pure returns (bool supported) {
supported = interfaceId == 0x80ac58cd || interfaceId == 0x5b5e139f;
}
function approve(address spender, uint256 tokenId) external {
address owner_ = ownerOf[tokenId];
require(msg.sender == owner_ || isApprovedForAll[owner_][msg.sender], "NOT_APPROVED");
getApproved[tokenId] = spender;
emit Approval(owner_, spender, tokenId);
}
function setApprovalForAll(address operator, bool approved) external {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(address from, address to, uint256 tokenId) public {
require(
msg.sender == from
|| msg.sender == getApproved[tokenId]
|| isApprovedForAll[from][msg.sender],
"NOT_APPROVED"
);
_transfer(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) external {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {
transferFrom(from, to, tokenId);
if (to.code.length != 0) {
// selector = `onERC721Received(address,address,uint,bytes)`
(, bytes memory returned) = to.staticcall(abi.encodeWithSelector(0x150b7a02,
msg.sender, from, tokenId, data));
bytes4 selector = abi.decode(returned, (bytes4));
require(selector == 0x150b7a02, "NOT_ERC721_RECEIVER");
}
}
/*///////////////////////////////////////////////////////////////
INTERNAL UTILS
//////////////////////////////////////////////////////////////*/
function _transfer(address from, address to, uint256 tokenId) internal {
require(ownerOf[tokenId] == from, "not owner");
balanceOf[from]--;
balanceOf[to]++;
delete getApproved[tokenId];
ownerOf[tokenId] = to;
emit Transfer(from, to, tokenId);
}
function _mint(address to, uint256 tokenId) internal {
require(ownerOf[tokenId] == address(0), "ALREADY_MINTED");
totalSupply++;
// This is safe because the sum of all user
// balances can't exceed type(uint256).max!
unchecked {
balanceOf[to]++;
}
ownerOf[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal {
address owner_ = ownerOf[tokenId];
require(ownerOf[tokenId] != address(0), "NOT_MINTED");
totalSupply--;
balanceOf[owner_]--;
delete ownerOf[tokenId];
emit Transfer(owner_, address(0), tokenId);
}
}
| contract ERC721 {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed spender, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/*///////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
address implementation_;
address public admin; //Lame requirement from opensea
/*///////////////////////////////////////////////////////////////
ERC-721 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
uint256 public oldSupply;
uint256 public minted;
mapping(address => uint256) public balanceOf;
mapping(uint256 => address) public ownerOf;
mapping(uint256 => address) public getApproved;
mapping(address => mapping(address => bool)) public isApprovedForAll;
/*///////////////////////////////////////////////////////////////
VIEW FUNCTION
//////////////////////////////////////////////////////////////*/
function owner() external view returns (address) {
return admin;
}
/*///////////////////////////////////////////////////////////////
ERC-20-LIKE LOGIC
//////////////////////////////////////////////////////////////*/
function transfer(address to, uint256 tokenId) external {
require(msg.sender == ownerOf[tokenId], "NOT_OWNER");
_transfer(msg.sender, to, tokenId);
}
/*///////////////////////////////////////////////////////////////
ERC-721 LOGIC
//////////////////////////////////////////////////////////////*/
function supportsInterface(bytes4 interfaceId) external pure returns (bool supported) {
supported = interfaceId == 0x80ac58cd || interfaceId == 0x5b5e139f;
}
function approve(address spender, uint256 tokenId) external {
address owner_ = ownerOf[tokenId];
require(msg.sender == owner_ || isApprovedForAll[owner_][msg.sender], "NOT_APPROVED");
getApproved[tokenId] = spender;
emit Approval(owner_, spender, tokenId);
}
function setApprovalForAll(address operator, bool approved) external {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(address from, address to, uint256 tokenId) public {
require(
msg.sender == from
|| msg.sender == getApproved[tokenId]
|| isApprovedForAll[from][msg.sender],
"NOT_APPROVED"
);
_transfer(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) external {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {
transferFrom(from, to, tokenId);
if (to.code.length != 0) {
// selector = `onERC721Received(address,address,uint,bytes)`
(, bytes memory returned) = to.staticcall(abi.encodeWithSelector(0x150b7a02,
msg.sender, from, tokenId, data));
bytes4 selector = abi.decode(returned, (bytes4));
require(selector == 0x150b7a02, "NOT_ERC721_RECEIVER");
}
}
/*///////////////////////////////////////////////////////////////
INTERNAL UTILS
//////////////////////////////////////////////////////////////*/
function _transfer(address from, address to, uint256 tokenId) internal {
require(ownerOf[tokenId] == from, "not owner");
balanceOf[from]--;
balanceOf[to]++;
delete getApproved[tokenId];
ownerOf[tokenId] = to;
emit Transfer(from, to, tokenId);
}
function _mint(address to, uint256 tokenId) internal {
require(ownerOf[tokenId] == address(0), "ALREADY_MINTED");
totalSupply++;
// This is safe because the sum of all user
// balances can't exceed type(uint256).max!
unchecked {
balanceOf[to]++;
}
ownerOf[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal {
address owner_ = ownerOf[tokenId];
require(ownerOf[tokenId] != address(0), "NOT_MINTED");
totalSupply--;
balanceOf[owner_]--;
delete ownerOf[tokenId];
emit Transfer(owner_, address(0), tokenId);
}
}
| 49,942 |
7 | // External Functions / |
function mint_actor() external override
|
function mint_actor() external override
| 47,944 |
88 | // Internal function that burns an amount of the token of a given account.Update pointsCorrection to keep funds unchanged. account The account whose tokens will be burnt. amount The amount that will be burnt. / | function _burn(address account, uint256 amount) internal virtual override {
super._burn(account, amount);
_correctPoints(account, int256(amount));
}
| function _burn(address account, uint256 amount) internal virtual override {
super._burn(account, amount);
_correctPoints(account, int256(amount));
}
| 26,783 |
56 | // if this equals false whitelist can nolonger be added to. | bool public canWhitelist = true;
| bool public canWhitelist = true;
| 8,695 |
45 | // the freeze token | mapping(address => uint256) frozenTokens;
uint16 public frozenRate;
bool public canBuy = true;
bool public projectFailed = false;
uint16 public backEthRatio = 10000;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value);
event UpdateTargetToken(address _target, uint16 _exchangeRate, uint16 _freezeRate);
| mapping(address => uint256) frozenTokens;
uint16 public frozenRate;
bool public canBuy = true;
bool public projectFailed = false;
uint16 public backEthRatio = 10000;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value);
event UpdateTargetToken(address _target, uint16 _exchangeRate, uint16 _freezeRate);
| 40,412 |
269 | // No need to init as it cannot be killed by devops199 | if (_regFactory != address(0)) {
regFactory = EVMScriptRegistryFactory(_regFactory);
}
| if (_regFactory != address(0)) {
regFactory = EVMScriptRegistryFactory(_regFactory);
}
| 27,645 |
23 | // Make sure the allower has provided the right allowance. | ERC20Interface = ERC20(tokenAddress);
uint256 ourAllowance = ERC20Interface.allowance(allower, address(this));
require(amount <= ourAllowance, "Festaking: Make sure to add enough allowance");
_;
| ERC20Interface = ERC20(tokenAddress);
uint256 ourAllowance = ERC20Interface.allowance(allower, address(this));
require(amount <= ourAllowance, "Festaking: Make sure to add enough allowance");
_;
| 15,039 |
34 | // After the extraction, the reserves in cToken should decrease. Instead of getting reserves from cToken again, we subtract `totalReserves` with `reduceAmount` to save gas. | totalReserves = totalReserves - reduceAmount;
| totalReserves = totalReserves - reduceAmount;
| 9,028 |
174 | // PalPool errors | string public constant INSUFFICIENT_CASH = '9';
string public constant INSUFFICIENT_BALANCE = '10';
string public constant FAIL_DEPOSIT = '11';
string public constant FAIL_LOAN_INITIATE = '12';
string public constant FAIL_BORROW = '13';
string public constant ZERO_BORROW = '27';
string public constant BORROW_INSUFFICIENT_FEES = '23';
string public constant LOAN_CLOSED = '14';
string public constant NOT_LOAN_OWNER = '15';
string public constant LOAN_OWNER = '16';
| string public constant INSUFFICIENT_CASH = '9';
string public constant INSUFFICIENT_BALANCE = '10';
string public constant FAIL_DEPOSIT = '11';
string public constant FAIL_LOAN_INITIATE = '12';
string public constant FAIL_BORROW = '13';
string public constant ZERO_BORROW = '27';
string public constant BORROW_INSUFFICIENT_FEES = '23';
string public constant LOAN_CLOSED = '14';
string public constant NOT_LOAN_OWNER = '15';
string public constant LOAN_OWNER = '16';
| 38,680 |
41 | // Divide a scalar by an Exp, then truncate to return an unsigned integer. / | function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) {
(MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);
if (err != MathError.NO_ERROR) {
return (err, 0);
}
return (MathError.NO_ERROR, truncate(fraction));
}
| function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) {
(MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);
if (err != MathError.NO_ERROR) {
return (err, 0);
}
return (MathError.NO_ERROR, truncate(fraction));
}
| 860 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.