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
239
// Allows anyone to buy an amount of tokens at a price which matchesthe signature that the owner or alternate signer has approved /
function mint( uint256 version, uint256 amount, uint256[4] memory pricesAndTimestamps, bytes memory signature
function mint( uint256 version, uint256 amount, uint256[4] memory pricesAndTimestamps, bytes memory signature
8,600
0
// _USDTContract = IUSDT(0xdAC17F958D2ee523a2206206994597C13D831ec7);
_pause();
_pause();
17,610
278
// Emitted when fees was compuonded to the pool/amount0 Total amount of fees compounded in terms of token 0/amount1 Total amount of fees compounded in terms of token 1
event CompoundFees( uint256 amount0, uint256 amount1 );
event CompoundFees( uint256 amount0, uint256 amount1 );
42,348
86
// RepublicToken.
RepublicToken public ren;
RepublicToken public ren;
22,944
34
// Emits a {CallExecuted} event. /
function _call( bytes32 id, uint256 index, address target, uint256 value, bytes calldata data ) private { (bool success, ) = target.call{value: value}(data);
function _call( bytes32 id, uint256 index, address target, uint256 value, bytes calldata data ) private { (bool success, ) = target.call{value: value}(data);
37,690
2
// assert(a == bc + a % b);There is no case in which this doesn't hold
return c;
return c;
279
14
// Minimum points in ring is 3. (minimum cells is 6).
require(points.length >= CELLS_PER_POINT * MIN_POINTS_AMOUNT_PER_RING); require(points.length % CELLS_PER_POINT == 0); uint32 _pointsAmount = uint32(points.length / CELLS_PER_POINT); ringsSizes.push(_pointsAmount); pointsAmount = pointsAmount.add(_pointsAmount); rings[uint8(ringsSizes.length - 1)] = points.toBytes();
require(points.length >= CELLS_PER_POINT * MIN_POINTS_AMOUNT_PER_RING); require(points.length % CELLS_PER_POINT == 0); uint32 _pointsAmount = uint32(points.length / CELLS_PER_POINT); ringsSizes.push(_pointsAmount); pointsAmount = pointsAmount.add(_pointsAmount); rings[uint8(ringsSizes.length - 1)] = points.toBytes();
20,145
6
// Set the maximum amount of tokens that a user can receive for the entire time amount new maximum amount /
function setMaxReceiveAmount(uint256 amount) external;
function setMaxReceiveAmount(uint256 amount) external;
10,395
4
// Emitted when an admin is removed from the admin list./_initiator The address which initiated this event to be emitted./_removedAdmin The address of the removed admin.
event AdminRemoved(address indexed _initiator, address indexed _removedAdmin);
event AdminRemoved(address indexed _initiator, address indexed _removedAdmin);
25,217
20
// freeze part
function freeze(address _addr, uint256 _value) public onlyOwner returns (bool success) { require(balances[_addr] >= _value); require(_value > 0); balances[_addr] = sub(balances[_addr], _value); frozen[_addr] = add(frozen[_addr], _value); emit Freeze(_addr, _value); return true; }
function freeze(address _addr, uint256 _value) public onlyOwner returns (bool success) { require(balances[_addr] >= _value); require(_value > 0); balances[_addr] = sub(balances[_addr], _value); frozen[_addr] = add(frozen[_addr], _value); emit Freeze(_addr, _value); return true; }
4,647
16
// Set common engagement property
EngagementProperty.Data storage engagement = _engagements[ENGAGEMENT_ID]; engagement.engagementId = ENGAGEMENT_ID; engagement.takerAddress = takerAddress; engagement.engagementCreationTimestamp = now; engagement.engagementDueTimestamp = now.add(_bip.tenorDays * 1 days); engagement.engagementState = EngagementProperty.EngagementState.Active; emit EngagementCreated(_issuanceProperty.issuanceId, ENGAGEMENT_ID, takerAddress);
EngagementProperty.Data storage engagement = _engagements[ENGAGEMENT_ID]; engagement.engagementId = ENGAGEMENT_ID; engagement.takerAddress = takerAddress; engagement.engagementCreationTimestamp = now; engagement.engagementDueTimestamp = now.add(_bip.tenorDays * 1 days); engagement.engagementState = EngagementProperty.EngagementState.Active; emit EngagementCreated(_issuanceProperty.issuanceId, ENGAGEMENT_ID, takerAddress);
39,161
3
// Active brains of Governor
address public implementation;
address public implementation;
18,445
163
// compute the fees _expectedAmount amount expected for the requestreturn/
function collectEstimation(int256 _expectedAmount) public view returns(uint256)
function collectEstimation(int256 _expectedAmount) public view returns(uint256)
47,245
1
// MEMBERS The reference to the active token implementation.
BlackCaspian public BlackCaspian;
BlackCaspian public BlackCaspian;
9,251
7
// Equivalent to require(denominator != 0 && (x == 0 || (xy) / x == y))
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) }
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) }
14,239
63
// Modifier to check if value send fulfills player stake requirements.
modifier onlyValidValue() { require(minStake <= msg.value && msg.value <= maxStake); _; }
modifier onlyValidValue() { require(minStake <= msg.value && msg.value <= maxStake); _; }
35,190
466
// Reads the bytes5 at `mPtr` in memory.
function readBytes5( MemoryPointer mPtr
function readBytes5( MemoryPointer mPtr
19,811
667
// Numerator: 1. val = 1. val := mulmod(val, 1, PRIME). Denominator: point^(trace_length / 4096) - trace_generator^(251trace_length / 256). val = denominator_invs[16].
val := mulmod(val, mload(0x4920), PRIME)
val := mulmod(val, mload(0x4920), PRIME)
21,746
118
// Crowdsale Crowdsale is a base contract for managing a token crowdsale /
contract Crowdsale is Ownable { using SafeMath for uint256; using SafeERC20 for RESTOToken; uint256 hardCap = 50000 * 1 ether; address myAddress = this; RESTOToken public token = new RESTOToken(myAddress); uint64 crowdSaleStartTime = 1537401600; // 20.09.2018 uint64 crowdSaleEndTime = 1544745600; // 14.12.2018 //Addresses for store tokens TeamAddress1 public teamAddress1 = new TeamAddress1(); TeamAddress2 public teamAddress2 = new TeamAddress2(); MarketingAddress public marketingAddress = new MarketingAddress(); RetailersAddress public retailersAddress = new RetailersAddress(); ReserveAddress public reserveAddress = new ReserveAddress(); BountyAddress public bountyAddress = new BountyAddress(); // How many token units a buyer gets per wei. uint256 public rate; // Amount of wei raised uint256 public weiRaised; event Withdraw( address indexed from, address indexed to, uint256 amount ); event TokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor() public { uint256 totalTokens = token.INITIAL_SUPPLY(); /** * @dev Inicial distributing tokens to special adresses * TeamAddress1 - 4.5% * TeamAddress2 - 13.5% (hold one year) * MarketingAddress - 18% * RetailersAddress - 9% * ReserveAddress - 8% * BountyAddress - 1% */ _deliverTokens(teamAddress1, totalTokens.mul(45).div(1000)); _deliverTokens(teamAddress2, totalTokens.mul(135).div(1000)); _deliverTokens(marketingAddress, totalTokens.mul(18).div(100)); _deliverTokens(retailersAddress, totalTokens.mul(9).div(100)); _deliverTokens(reserveAddress, totalTokens.mul(8).div(100)); _deliverTokens(bountyAddress, totalTokens.div(100)); rate = 10000; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function */ function () external payable { require(msg.data.length == 0,"Only for simple payments"); buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokensPurchased( msg.sender, _beneficiary, weiAmount, tokens ); } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev called by the owner to pause, triggers stopped state */ function pauseCrowdsale() public onlyOwner { token.pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpauseCrowdsale() public onlyOwner { token.unpause(); } /** * @dev function set kyc bool to true * @param _investor The investor who passed the procedure KYC */ function setKYCpassed(address _investor) public restricted returns(bool){ token.kycPass(_investor); return true; } /** * @dev the function tranfer tokens from TeamAddress1 to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromTeamAddress1(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(teamAddress1), _investor, _value); return true; } /** * @dev the function tranfer tokens from TeamAddress1 to investor * only after 1 year * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromTeamAddress2(address _investor, uint256 _value) public restricted returns(bool){ require (now >= (crowdSaleEndTime + 365 days), "Only after 1 year"); token.transferTokensFromSpecialAddress(address(teamAddress2), _investor, _value); return true; } /** * @dev the function tranfer tokens from MarketingAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromMarketingAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(marketingAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from RetailersAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromRetailersAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(retailersAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from ReserveAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromReserveAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(reserveAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from BountyAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromBountyAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(bountyAddress), _investor, _value); return true; } /** * @dev Validation of an incoming purchase. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase * Start Crowdsale 20/09/2018 - 1537401600 * Finish Crowdsale 14/12/2018 - 1544745600 * Greate pause until 01/11/2020 - 1604188800 */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view{ require(_beneficiary != address(0),"Invalid address"); require(_weiAmount != 0,"Invalid amount"); require((now > crowdSaleStartTime && now <= crowdSaleEndTime) || now > 1604188800,"At this time contract don`t sell tokens, sorry"); require(weiRaised < hardCap,"HardCap is passed, contract don`t accept ether."); } /** * @dev internal function * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.safeTransfer(_beneficiary, _tokenAmount); } /** * @dev Function transfer token to new investors * Access restricted owner and manager */ function transferTokens(address _newInvestor, uint256 _tokenAmount) public restricted { uint256 value = _tokenAmount; require (value >= 1,"Min _tokenAmount is 1"); value = value.mul(1 ether); _deliverTokens(_newInvestor, value); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } /** * @dev this function is ether converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 bonus = 0; uint256 resultAmount = _weiAmount; /** * Start PreSale 20/09/2018 - 1537401600 * Start ICO 10/10/2018 - 1539129600 * Finish ICO 14/12/2018 - 1544745600 */ if (now < 1539129600) { // Calculating bonus for PreSale period if (_weiAmount >= 100 * 1 ether) { bonus = 300; } else { bonus = 100; } } else { // Calculating bonus for ICO period if (_weiAmount >= 100 * 1 ether) { bonus = 200; } else { /** * ICO bonus UnisTimeStamp * Start date End date * 10.10.2018-16.10.2018 - 40% 1539129600 * 17.10.2018-23.10.2018 - 30% 1539734400 * 24.10.2018-31.10.2018 - 20% 1540339200 * 01.11.2018-16.11.2018 - 10% 1541030400 1542326400 */ if (now >= 1539129600 && now < 1539734400) { bonus = 40; } if (now >= 1539734400 && now < 1540339200) { bonus = 30; } if (now >= 1540339200 && now < 1541030400) { bonus = 20; } if (now >= 1541030400 && now < 1542326400) { bonus = 10; } } } if (bonus > 0) { resultAmount += _weiAmount.mul(bonus).div(100); } return resultAmount.mul(rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function forwardFunds() public onlyOwner { uint256 transferValue = myAddress.balance.div(8); // Addresses where funds are collected address wallet1 = 0x0C4324DC212f7B09151148c3960f71904E5C074D; address wallet2 = 0x49C0fAc36178DB055dD55df6a6656dd457dc307A; address wallet3 = 0x510aC42D296D0b06d5B262F606C27d5cf22B9726; address wallet4 = 0x48dfeA3ce1063191B45D06c6ECe7462B244A40B6; address wallet5 = 0x5B1689B453bb0DBd38A0d9710a093A228ab13170; address wallet6 = 0xDFA0Cba1D28E625C3f3257B4758782164e4622f2; address wallet7 = 0xF3Ff96FE7eE76ACA81aFb180264D6A31f726BAbE; address wallet8 = 0x5384EFFdf2bb24a8b0489633A64D4Bfc53BdFEb6; wallet1.transfer(transferValue); wallet2.transfer(transferValue); wallet3.transfer(transferValue); wallet4.transfer(transferValue); wallet5.transfer(transferValue); wallet6.transfer(transferValue); wallet7.transfer(transferValue); wallet8.transfer(myAddress.balance); } function withdrawFunds (address _to, uint256 _value) public onlyOwner { require (now > crowdSaleEndTime, "CrowdSale is not finished yet. Access denied."); require (myAddress.balance >= _value,"Value is more than balance"); require(_to != address(0),"Invalid address"); _to.transfer(_value); emit Withdraw(msg.sender, _to, _value); } }
contract Crowdsale is Ownable { using SafeMath for uint256; using SafeERC20 for RESTOToken; uint256 hardCap = 50000 * 1 ether; address myAddress = this; RESTOToken public token = new RESTOToken(myAddress); uint64 crowdSaleStartTime = 1537401600; // 20.09.2018 uint64 crowdSaleEndTime = 1544745600; // 14.12.2018 //Addresses for store tokens TeamAddress1 public teamAddress1 = new TeamAddress1(); TeamAddress2 public teamAddress2 = new TeamAddress2(); MarketingAddress public marketingAddress = new MarketingAddress(); RetailersAddress public retailersAddress = new RetailersAddress(); ReserveAddress public reserveAddress = new ReserveAddress(); BountyAddress public bountyAddress = new BountyAddress(); // How many token units a buyer gets per wei. uint256 public rate; // Amount of wei raised uint256 public weiRaised; event Withdraw( address indexed from, address indexed to, uint256 amount ); event TokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor() public { uint256 totalTokens = token.INITIAL_SUPPLY(); /** * @dev Inicial distributing tokens to special adresses * TeamAddress1 - 4.5% * TeamAddress2 - 13.5% (hold one year) * MarketingAddress - 18% * RetailersAddress - 9% * ReserveAddress - 8% * BountyAddress - 1% */ _deliverTokens(teamAddress1, totalTokens.mul(45).div(1000)); _deliverTokens(teamAddress2, totalTokens.mul(135).div(1000)); _deliverTokens(marketingAddress, totalTokens.mul(18).div(100)); _deliverTokens(retailersAddress, totalTokens.mul(9).div(100)); _deliverTokens(reserveAddress, totalTokens.mul(8).div(100)); _deliverTokens(bountyAddress, totalTokens.div(100)); rate = 10000; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function */ function () external payable { require(msg.data.length == 0,"Only for simple payments"); buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokensPurchased( msg.sender, _beneficiary, weiAmount, tokens ); } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev called by the owner to pause, triggers stopped state */ function pauseCrowdsale() public onlyOwner { token.pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpauseCrowdsale() public onlyOwner { token.unpause(); } /** * @dev function set kyc bool to true * @param _investor The investor who passed the procedure KYC */ function setKYCpassed(address _investor) public restricted returns(bool){ token.kycPass(_investor); return true; } /** * @dev the function tranfer tokens from TeamAddress1 to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromTeamAddress1(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(teamAddress1), _investor, _value); return true; } /** * @dev the function tranfer tokens from TeamAddress1 to investor * only after 1 year * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromTeamAddress2(address _investor, uint256 _value) public restricted returns(bool){ require (now >= (crowdSaleEndTime + 365 days), "Only after 1 year"); token.transferTokensFromSpecialAddress(address(teamAddress2), _investor, _value); return true; } /** * @dev the function tranfer tokens from MarketingAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromMarketingAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(marketingAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from RetailersAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromRetailersAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(retailersAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from ReserveAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromReserveAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(reserveAddress), _investor, _value); return true; } /** * @dev the function tranfer tokens from BountyAddress to investor * @param _value is entered in whole tokens (1 = 1 token) */ function transferTokensFromBountyAddress(address _investor, uint256 _value) public restricted returns(bool){ token.transferTokensFromSpecialAddress(address(bountyAddress), _investor, _value); return true; } /** * @dev Validation of an incoming purchase. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase * Start Crowdsale 20/09/2018 - 1537401600 * Finish Crowdsale 14/12/2018 - 1544745600 * Greate pause until 01/11/2020 - 1604188800 */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view{ require(_beneficiary != address(0),"Invalid address"); require(_weiAmount != 0,"Invalid amount"); require((now > crowdSaleStartTime && now <= crowdSaleEndTime) || now > 1604188800,"At this time contract don`t sell tokens, sorry"); require(weiRaised < hardCap,"HardCap is passed, contract don`t accept ether."); } /** * @dev internal function * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.safeTransfer(_beneficiary, _tokenAmount); } /** * @dev Function transfer token to new investors * Access restricted owner and manager */ function transferTokens(address _newInvestor, uint256 _tokenAmount) public restricted { uint256 value = _tokenAmount; require (value >= 1,"Min _tokenAmount is 1"); value = value.mul(1 ether); _deliverTokens(_newInvestor, value); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } /** * @dev this function is ether converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 bonus = 0; uint256 resultAmount = _weiAmount; /** * Start PreSale 20/09/2018 - 1537401600 * Start ICO 10/10/2018 - 1539129600 * Finish ICO 14/12/2018 - 1544745600 */ if (now < 1539129600) { // Calculating bonus for PreSale period if (_weiAmount >= 100 * 1 ether) { bonus = 300; } else { bonus = 100; } } else { // Calculating bonus for ICO period if (_weiAmount >= 100 * 1 ether) { bonus = 200; } else { /** * ICO bonus UnisTimeStamp * Start date End date * 10.10.2018-16.10.2018 - 40% 1539129600 * 17.10.2018-23.10.2018 - 30% 1539734400 * 24.10.2018-31.10.2018 - 20% 1540339200 * 01.11.2018-16.11.2018 - 10% 1541030400 1542326400 */ if (now >= 1539129600 && now < 1539734400) { bonus = 40; } if (now >= 1539734400 && now < 1540339200) { bonus = 30; } if (now >= 1540339200 && now < 1541030400) { bonus = 20; } if (now >= 1541030400 && now < 1542326400) { bonus = 10; } } } if (bonus > 0) { resultAmount += _weiAmount.mul(bonus).div(100); } return resultAmount.mul(rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function forwardFunds() public onlyOwner { uint256 transferValue = myAddress.balance.div(8); // Addresses where funds are collected address wallet1 = 0x0C4324DC212f7B09151148c3960f71904E5C074D; address wallet2 = 0x49C0fAc36178DB055dD55df6a6656dd457dc307A; address wallet3 = 0x510aC42D296D0b06d5B262F606C27d5cf22B9726; address wallet4 = 0x48dfeA3ce1063191B45D06c6ECe7462B244A40B6; address wallet5 = 0x5B1689B453bb0DBd38A0d9710a093A228ab13170; address wallet6 = 0xDFA0Cba1D28E625C3f3257B4758782164e4622f2; address wallet7 = 0xF3Ff96FE7eE76ACA81aFb180264D6A31f726BAbE; address wallet8 = 0x5384EFFdf2bb24a8b0489633A64D4Bfc53BdFEb6; wallet1.transfer(transferValue); wallet2.transfer(transferValue); wallet3.transfer(transferValue); wallet4.transfer(transferValue); wallet5.transfer(transferValue); wallet6.transfer(transferValue); wallet7.transfer(transferValue); wallet8.transfer(myAddress.balance); } function withdrawFunds (address _to, uint256 _value) public onlyOwner { require (now > crowdSaleEndTime, "CrowdSale is not finished yet. Access denied."); require (myAddress.balance >= _value,"Value is more than balance"); require(_to != address(0),"Invalid address"); _to.transfer(_value); emit Withdraw(msg.sender, _to, _value); } }
12,049
48
// If there are no royalties, return the initial amount
if (totalRecipients == 0) return _amount;
if (totalRecipients == 0) return _amount;
19,175
29
// Returns the current time.Useful to abstract calls to "now" for tests./
function currentTime() public view returns (uint _currentTime) { return block.timestamp; }
function currentTime() public view returns (uint _currentTime) { return block.timestamp; }
20,543
216
// 正序
else { uint index = offset; uint end = index + count; if (end > length) { end = length; }
else { uint index = offset; uint end = index + count; if (end > length) { end = length; }
66,192
205
// Store the length.
mstore(str, length)
mstore(str, length)
3,878
90
// : Squeebo /
abstract contract ERC721B is Context, ERC165, IERC721, IERC721Metadata { using Address for address; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address address[] internal _owners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); uint count = 0; uint length = _owners.length; for( uint i = 0; i < length; ++i ){ if( owner == _owners[i] ){ ++count; } } delete length; return count; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721B.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length && _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721B.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _owners.push(to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721B.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _owners[tokenId] = address(0); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721B.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721B.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
abstract contract ERC721B is Context, ERC165, IERC721, IERC721Metadata { using Address for address; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address address[] internal _owners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); uint count = 0; uint length = _owners.length; for( uint i = 0; i < length; ++i ){ if( owner == _owners[i] ){ ++count; } } delete length; return count; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721B.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length && _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721B.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _owners.push(to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721B.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _owners[tokenId] = address(0); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721B.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721B.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
19,754
18
// If a token URI resolver is provided, use it to resolve the token URI.
if (address(_resolver) != address(0)) return _resolver.getUri(_tokenId);
if (address(_resolver) != address(0)) return _resolver.getUri(_tokenId);
11,772
12
// Returns true if the caller is the current owner. /
function isOwner() public view returns (bool) { return msg.sender == _owner; }
function isOwner() public view returns (bool) { return msg.sender == _owner; }
10,600
14
// Returns the scaled balance of the user. The scaled balance is the sum of all theupdated stored balance divided by the reserve's liquidity index at the moment of the update user The user whose balance is calculatedreturn The scaled balance of the user /
function scaledBalanceOf(address user) external view override returns (uint256) { return super.balanceOf(user); }
function scaledBalanceOf(address user) external view override returns (uint256) { return super.balanceOf(user); }
27,035
18
// Add to presale
function addTopresale(address[] memory newPresale, uint256 mintId) public onlyOwner { for (uint256 i = 0; i < newPresale.length; i++) { presale[mintId][newPresale[i]] = 1; presaleCount = presaleCount + 1; } }
function addTopresale(address[] memory newPresale, uint256 mintId) public onlyOwner { for (uint256 i = 0; i < newPresale.length; i++) { presale[mintId][newPresale[i]] = 1; presaleCount = presaleCount + 1; } }
26,084
86
// SnapshotTokenAn ERC20 token which enables taking snapshots of accounts' balances. This can be useful to safely implement voting weighed by balance. /
contract SnapshotToken is StandardToken { using ArrayUtils for uint256[]; // The 0 id represents no snapshot was taken yet. uint256 public currSnapshotId; mapping (address => uint256[]) internal snapshotIds; mapping (address => uint256[]) internal snapshotBalances; event Snapshot(uint256 id); function transfer(address _to, uint256 _value) public returns (bool) { _updateSnapshot(msg.sender); _updateSnapshot(_to); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { _updateSnapshot(_from); _updateSnapshot(_to); return super.transferFrom(_from, _to, _value); } function snapshot() public returns (uint256) { currSnapshotId += 1; emit Snapshot(currSnapshotId); return currSnapshotId; } function balanceOfAt(address _account, uint256 _snapshotId) public view returns (uint256) { require(_snapshotId > 0 && _snapshotId <= currSnapshotId); uint256 idx = snapshotIds[_account].findUpperBound(_snapshotId); if (idx == snapshotIds[_account].length) { return balanceOf(_account); } else { return snapshotBalances[_account][idx]; } } function _updateSnapshot(address _account) internal { if (_lastSnapshotId(_account) < currSnapshotId) { snapshotIds[_account].push(currSnapshotId); snapshotBalances[_account].push(balanceOf(_account)); } } function _lastSnapshotId(address _account) internal view returns (uint256) { uint256[] storage snapshots = snapshotIds[_account]; if (snapshots.length == 0) { return 0; } else { return snapshots[snapshots.length - 1]; } } }
contract SnapshotToken is StandardToken { using ArrayUtils for uint256[]; // The 0 id represents no snapshot was taken yet. uint256 public currSnapshotId; mapping (address => uint256[]) internal snapshotIds; mapping (address => uint256[]) internal snapshotBalances; event Snapshot(uint256 id); function transfer(address _to, uint256 _value) public returns (bool) { _updateSnapshot(msg.sender); _updateSnapshot(_to); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { _updateSnapshot(_from); _updateSnapshot(_to); return super.transferFrom(_from, _to, _value); } function snapshot() public returns (uint256) { currSnapshotId += 1; emit Snapshot(currSnapshotId); return currSnapshotId; } function balanceOfAt(address _account, uint256 _snapshotId) public view returns (uint256) { require(_snapshotId > 0 && _snapshotId <= currSnapshotId); uint256 idx = snapshotIds[_account].findUpperBound(_snapshotId); if (idx == snapshotIds[_account].length) { return balanceOf(_account); } else { return snapshotBalances[_account][idx]; } } function _updateSnapshot(address _account) internal { if (_lastSnapshotId(_account) < currSnapshotId) { snapshotIds[_account].push(currSnapshotId); snapshotBalances[_account].push(balanceOf(_account)); } } function _lastSnapshotId(address _account) internal view returns (uint256) { uint256[] storage snapshots = snapshotIds[_account]; if (snapshots.length == 0) { return 0; } else { return snapshots[snapshots.length - 1]; } } }
54,137
1
// assert(b > 0);Solidity automatically throws when dividing by 0
uint256 c = a / b;
uint256 c = a / b;
942
22
// Register a future flight for insuring./
function registerFlight( string memory flightNumber, uint256 timestamp, uint256 ticketPrice
function registerFlight( string memory flightNumber, uint256 timestamp, uint256 ticketPrice
36,788
68
// send tokens and ETH for liquidity to contract directly, then call this (not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch)
function launch(address[] memory presaleWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(presaleWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < presaleWallets.length; i++){ address wallet = presaleWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); setLiquidityAddress(address(0xdead)); return true; }
function launch(address[] memory presaleWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(presaleWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < presaleWallets.length; i++){ address wallet = presaleWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); setLiquidityAddress(address(0xdead)); return true; }
21,800
156
// Update merkle root to reflect changes in Allowlist_id token if for merkle root_newMerkleRoot new merkle root to reflect most recent Allowlist/
function updateMerkleRoot(uint256 _id, bytes32 _newMerkleRoot) public onlyOwner { require(_newMerkleRoot != merkleRoot[_id], "Merkle root will be unchanged!"); merkleRoot[_id] = _newMerkleRoot; }
function updateMerkleRoot(uint256 _id, bytes32 _newMerkleRoot) public onlyOwner { require(_newMerkleRoot != merkleRoot[_id], "Merkle root will be unchanged!"); merkleRoot[_id] = _newMerkleRoot; }
28,869
25
// Return the removed accounts so the caller can emit removal events
return removedAccounts;
return removedAccounts;
38,798
22
// Get Ether balance /
function getEtherBalance() public view returns (uint) { return address(this).balance; }
function getEtherBalance() public view returns (uint) { return address(this).balance; }
46,736
33
// Set up a Token Threshold action action Token threshold action to be configured admin Address that will be granted with admin rights for the Token Threshold action params Params to customize the Token Threshold action /
function setupTokenThresholdAction( TokenThresholdAction action, address admin, TokenThresholdActionParams memory params
function setupTokenThresholdAction( TokenThresholdAction action, address admin, TokenThresholdActionParams memory params
32,149
196
// Declare and check identifier variable within an isolated scope.
{
{
17,453
46
// Source of tokens._beneficiary Address performing the token purchase_tokenAmount Number of tokens to be emitted/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { ISecurityToken(securityToken).issue(_beneficiary, _tokenAmount, ""); }
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { ISecurityToken(securityToken).issue(_beneficiary, _tokenAmount, ""); }
17,527
73
// internal functions //The following function should be used to update any balances within an epoch, whichwill not be immediately final. E.g. the BatchExchange credits new balances tothe buyers in an auction, but as there are might be better solutions, the updates arenot final. In order to prevent withdraws from non-final updates, we disallow withdrawsby setting lastCreditBatchId to the current batchId and allow only withdraws in batcheswith a higher batchId. /
function addBalanceAndBlockWithdrawForThisBatch( address user, address token, uint256 amount
function addBalanceAndBlockWithdrawForThisBatch( address user, address token, uint256 amount
10,839
1
// Check the signature length
if (sig.length != 65) { return (address(0)); }
if (sig.length != 65) { return (address(0)); }
22,961
1
// [address][epoch]
mapping(address => mapping(uint16 => uint256)) public userApplyAmount; mapping(address => uint256) public userBuybackedAmount; IBEP20 buybackToken; // BUSD IBEP20 sellToken; // Gokgweingi uint256 public buybackPrice; uint256 public epochBuybackAmount; uint16 public currentEpoch = 0; uint256 public nextEpochTimestamp;
mapping(address => mapping(uint16 => uint256)) public userApplyAmount; mapping(address => uint256) public userBuybackedAmount; IBEP20 buybackToken; // BUSD IBEP20 sellToken; // Gokgweingi uint256 public buybackPrice; uint256 public epochBuybackAmount; uint16 public currentEpoch = 0; uint256 public nextEpochTimestamp;
34,377
60
// else, reduce outstanding value of bond
loans[msg.sender][p].price = loans[msg.sender][p].price - _amount;
loans[msg.sender][p].price = loans[msg.sender][p].price - _amount;
18,976
54
// constructor function that is called once at deployment of the contract.recipient Address to receive initial supply./
constructor(address initialOwner, address recipient) public Ownable(initialOwner) { // name of the token _name = "Finandy"; // symbol of the token _symbol = "FIN"; // decimals of the token _decimals = 8; // creation of initial supply _mint(recipient, INITIAL_SUPPLY); }
constructor(address initialOwner, address recipient) public Ownable(initialOwner) { // name of the token _name = "Finandy"; // symbol of the token _symbol = "FIN"; // decimals of the token _decimals = 8; // creation of initial supply _mint(recipient, INITIAL_SUPPLY); }
15,797
4
// a token controlled by LockedAccount, read ERC20 + extensions to read what token is it (ETH/EUR etc.)
IERC677Token private ASSET_TOKEN; Neumark private NEUMARK;
IERC677Token private ASSET_TOKEN; Neumark private NEUMARK;
53,367
11
// check whether the account is a valid country or not
function is_country_check(address address_of_country) public view returns(bool){ for(uint index=0; index<country.length; index++){ if(country[index]==address_of_country) return true; } return false; }
function is_country_check(address address_of_country) public view returns(bool){ for(uint index=0; index<country.length; index++){ if(country[index]==address_of_country) return true; } return false; }
27,465
15
// Create a new service_minimumPrice Service starting price._data IPFS 32byte hash./
function createService(uint256 _minimumPrice, bytes32 _data) public whenNotPaused() { services[serviceId] = Service({id: serviceId, data: _data, minimumPrice: _minimumPrice, seller: msg.sender}); sellers[serviceId] = msg.sender; serviceList.push(serviceId); emit ServiceCreated(serviceId); serviceId = serviceId.add(1); }
function createService(uint256 _minimumPrice, bytes32 _data) public whenNotPaused() { services[serviceId] = Service({id: serviceId, data: _data, minimumPrice: _minimumPrice, seller: msg.sender}); sellers[serviceId] = msg.sender; serviceList.push(serviceId); emit ServiceCreated(serviceId); serviceId = serviceId.add(1); }
32,880
3
// Accrued token per share
uint256 public accTokenPerShare;
uint256 public accTokenPerShare;
22,394
19
// Mark the contract as initialized.
__setInitialized(); emit GroupIdentityManagerRouterImplInitialized(initialGroupIdentityManager);
__setInitialized(); emit GroupIdentityManagerRouterImplInitialized(initialGroupIdentityManager);
16,163
12
// ----- HELPER FUNCTIONS ----- /
function whichSwapCalled() private view returns (SwapRouterVersion version) { address sender = _msgSender(); if (sender == address(swapRouterV3)) { return SwapRouterVersion.V3; } else if (sender == address(swapRouterV2)) { return SwapRouterVersion.V2; } return SwapRouterVersion.NotSupported; }
function whichSwapCalled() private view returns (SwapRouterVersion version) { address sender = _msgSender(); if (sender == address(swapRouterV3)) { return SwapRouterVersion.V3; } else if (sender == address(swapRouterV2)) { return SwapRouterVersion.V2; } return SwapRouterVersion.NotSupported; }
42,713
1
// Token ID -> Royalty
mapping(uint256 => uint256) private royalties;
mapping(uint256 => uint256) private royalties;
23,576
41
// transfer the raw ERC1155s to this contract
raw.safeTransferFrom( address(msg.sender), address(this), (refinery.inputType), _amount, "" );
raw.safeTransferFrom( address(msg.sender), address(this), (refinery.inputType), _amount, "" );
35,713
83
// Proxy This contract is the base proxy contract that all proxy contracts should useIt deals with the agentManager contract dependency and imports all necessary utilities /
contract BaseProxy is Ownable { using Address for address; using SafeMath for uint256; using SafeERC20 for IERC20; uint256 public constant FEE_PRECISION = 10**6; uint256 public actionFee; address public feeDepositAddress; IAgentManager internal agentManager; event feeDeposited( address indexed depositAddress, address indexed tokenAddress, uint256 indexed amount ); modifier agentVerified(string calldata agentId, address user) { require( agentManager.verifyAgentAddress(agentId, msg.sender, user), "Agent not authorised for provided user" ); _; } /** * @param _agentManagerAddress: The agent manager address to connect to * @param _actionFee: The action fee value * @param _feeDepositAddress: The fee deposit address */ constructor( address _agentManagerAddress, uint256 _actionFee, address _feeDepositAddress ) { agentManager = IAgentManager(_agentManagerAddress); actionFee = _actionFee; feeDepositAddress = _feeDepositAddress; } function calcAndTransferFee(address tokenAddress, uint256 inputAmount) internal returns (uint256) { uint256 feeAmount = inputAmount.mul(actionFee).div(100).div( FEE_PRECISION ); if (feeAmount > 0) { IERC20(tokenAddress).safeTransfer(feeDepositAddress, feeAmount); emit feeDeposited(feeDepositAddress, tokenAddress, feeAmount); } return inputAmount.sub(feeAmount); } /** * @notice Updates agent manager contract, can only be called by owner of the contract * @param agentManagerAddress: New agent manager address */ function updateAgentManagerContract(address agentManagerAddress) external onlyOwner returns (bool) { agentManager = IAgentManager(agentManagerAddress); return true; } /** * @notice Updates action fee, can only be called by owner of the contract * @param _actionFee: New action fee value */ function setActionFee(uint256 _actionFee) external onlyOwner returns (bool) { require(_actionFee < FEE_PRECISION.mul(10**2), "Invalid action fee"); actionFee = _actionFee; return true; } /** * @notice Updates fee deposit address, can only be called by owner of the contract * @param _feeDepositAddress: New fee deposit address */ function setFeeDepositAddress(address _feeDepositAddress) external onlyOwner returns (bool) { feeDepositAddress = _feeDepositAddress; return true; } }
contract BaseProxy is Ownable { using Address for address; using SafeMath for uint256; using SafeERC20 for IERC20; uint256 public constant FEE_PRECISION = 10**6; uint256 public actionFee; address public feeDepositAddress; IAgentManager internal agentManager; event feeDeposited( address indexed depositAddress, address indexed tokenAddress, uint256 indexed amount ); modifier agentVerified(string calldata agentId, address user) { require( agentManager.verifyAgentAddress(agentId, msg.sender, user), "Agent not authorised for provided user" ); _; } /** * @param _agentManagerAddress: The agent manager address to connect to * @param _actionFee: The action fee value * @param _feeDepositAddress: The fee deposit address */ constructor( address _agentManagerAddress, uint256 _actionFee, address _feeDepositAddress ) { agentManager = IAgentManager(_agentManagerAddress); actionFee = _actionFee; feeDepositAddress = _feeDepositAddress; } function calcAndTransferFee(address tokenAddress, uint256 inputAmount) internal returns (uint256) { uint256 feeAmount = inputAmount.mul(actionFee).div(100).div( FEE_PRECISION ); if (feeAmount > 0) { IERC20(tokenAddress).safeTransfer(feeDepositAddress, feeAmount); emit feeDeposited(feeDepositAddress, tokenAddress, feeAmount); } return inputAmount.sub(feeAmount); } /** * @notice Updates agent manager contract, can only be called by owner of the contract * @param agentManagerAddress: New agent manager address */ function updateAgentManagerContract(address agentManagerAddress) external onlyOwner returns (bool) { agentManager = IAgentManager(agentManagerAddress); return true; } /** * @notice Updates action fee, can only be called by owner of the contract * @param _actionFee: New action fee value */ function setActionFee(uint256 _actionFee) external onlyOwner returns (bool) { require(_actionFee < FEE_PRECISION.mul(10**2), "Invalid action fee"); actionFee = _actionFee; return true; } /** * @notice Updates fee deposit address, can only be called by owner of the contract * @param _feeDepositAddress: New fee deposit address */ function setFeeDepositAddress(address _feeDepositAddress) external onlyOwner returns (bool) { feeDepositAddress = _feeDepositAddress; return true; } }
36,607
95
// See {IERC1155-balanceOfBatch(address[],uint256[])}.
function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external view virtual override returns (uint256[] memory) { require(owners.length == ids.length, "Inventory: inconsistent arrays"); uint256[] memory balances = new uint256[](owners.length); for (uint256 i = 0; i != owners.length; ++i) { balances[i] = balanceOf(owners[i], ids[i]); }
function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external view virtual override returns (uint256[] memory) { require(owners.length == ids.length, "Inventory: inconsistent arrays"); uint256[] memory balances = new uint256[](owners.length); for (uint256 i = 0; i != owners.length; ++i) { balances[i] = balanceOf(owners[i], ids[i]); }
77,211
0
// EVENTS
event NoteCreated(uint64 id, bytes2 publicKey); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event NoteCreated(uint64 id, bytes2 publicKey); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
10,199
40
// Call the unstake function with the final balance
return unstake(userBalance);
return unstake(userBalance);
18,042
95
// Returns the version string of the {IRelayHub} for which this recipient implementation was built. If{_upgradeRelayHub} is used, the new {IRelayHub} instance should be compatible with this version. / This function is view for future-proofing, it may require reading from storage in the future.
function relayHubVersion() public view virtual returns (string memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return "1.0.0"; }
function relayHubVersion() public view virtual returns (string memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return "1.0.0"; }
6,472
121
// Checks if address is a contract It prevents contract from being targetted /
function _isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; }
function _isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; }
19,913
139
// Update rewards per block
_updateRewardsPerBlock(endBlock); uint256 previousEndBlock = endBlock;
_updateRewardsPerBlock(endBlock); uint256 previousEndBlock = endBlock;
20,060
19
// Check if address is owner /
function isOwner(address account) public view returns (bool) { return account == owner; }
function isOwner(address account) public view returns (bool) { return account == owner; }
18,546
191
// Governor addresses of the system
Governor private governor;
Governor private governor;
68,969
84
// In case you ever find yourself in a situation like this, just contact the {} support, however nothing precludes you from invoking this method yourself.
function refundBet(uint commit) external {
function refundBet(uint commit) external {
10,475
83
// Loopring Token Exchange Protocol Contract Interface/Daniel Wang - <daniel@loopring.org>/Kongliang Zhong - <kongliang@loopring.org>
contract LoopringProtocol { //////////////////////////////////////////////////////////////////////////// /// Constants /// //////////////////////////////////////////////////////////////////////////// uint public constant FEE_SELECT_LRC = 0; uint public constant FEE_SELECT_MARGIN_SPLIT = 1; uint public constant FEE_SELECT_MAX_VALUE = 1; uint public constant MARGIN_SPLIT_PERCENTAGE_BASE = 10000; //////////////////////////////////////////////////////////////////////////// /// Structs /// //////////////////////////////////////////////////////////////////////////// /// @param tokenS Token to sell. /// @param tokenB Token to buy. /// @param amountS Maximum amount of tokenS to sell. /// @param amountB Minimum amount of tokenB to buy if all amountS sold. /// @param timestamp Indicating whtn this order is created/signed. /// @param ttl Indicating after how many seconds from `timestamp` /// this order will expire. /// @param salt A random number to make this order's hash unique. /// @param lrcFee Max amount of LRC to pay for miner. The real amount /// to pay is proportional to fill amount. /// @param buyNoMoreThanAmountB - /// If true, this order does not accept buying more /// than `amountB`. /// @param marginSplitPercentage - /// The percentage of margin paid to miner. /// @param v ECDSA signature parameter v. /// @param r ECDSA signature parameters r. /// @param s ECDSA signature parameters s. struct Order { address owner; address tokenS; address tokenB; uint amountS; uint amountB; uint timestamp; uint ttl; uint salt; uint lrcFee; bool buyNoMoreThanAmountB; uint8 marginSplitPercentage; uint8 v; bytes32 r; bytes32 s; } //////////////////////////////////////////////////////////////////////////// /// Public Functions /// //////////////////////////////////////////////////////////////////////////// /// @dev Submit a order-ring for validation and settlement. /// @param addressList List of each order's owner and tokenS. Note that next /// order's `tokenS` equals this order's `tokenB`. /// @param uintArgsList List of uint-type arguments in this order: /// amountS, AmountB, rateAmountS, timestamp, ttl, salt, /// and lrcFee. /// @param uint8ArgsList - /// List of unit8-type arguments, in this order: /// marginSplitPercentageList, feeSelectionList. /// @param vList List of v for each order. This list is 1-larger than /// the previous lists, with the last element being the /// v value of the ring signature. /// @param rList List of r for each order. This list is 1-larger than /// the previous lists, with the last element being the /// r value of the ring signature. /// @param sList List of s for each order. This list is 1-larger than /// the previous lists, with the last element being the /// s value of the ring signature. /// @param ringminer The address that signed this tx. /// @param feeRecepient The recepient address for fee collection. If this is /// '0x0', all fees will be paid to the address who had /// signed this transaction, not `msg.sender`. Noted if /// LRC need to be paid back to order owner as the result /// of fee selection model, LRC will also be sent from /// this address. /// @param throwIfLRCIsInsuffcient - /// If true, throw exception if any order's spendable /// LRC amount is smaller than requried; if false, ring- /// minor will give up collection the LRC fee. function submitRing( address[2][] addressList, uint[7][] uintArgsList, uint8[2][] uint8ArgsList, bool[] buyNoMoreThanAmountBList, uint8[] vList, bytes32[] rList, bytes32[] sList, address ringminer, address feeRecepient, bool throwIfLRCIsInsuffcient ) public; /// @dev Cancel a order. cancel amount(amountS or amountB) can be specified /// in orderValues. /// @param addresses owner, tokenS, tokenB /// @param orderValues amountS, amountB, timestamp, ttl, salt, lrcFee, /// cancelAmountS, and cancelAmountB. /// @param marginSplitPercentage - /// @param buyNoMoreThanAmountB - /// @param v Order ECDSA signature parameter v. /// @param r Order ECDSA signature parameters r. /// @param s Order ECDSA signature parameters s. function cancelOrder( address[3] addresses, uint[7] orderValues, bool buyNoMoreThanAmountB, uint8 marginSplitPercentage, uint8 v, bytes32 r, bytes32 s ) public; /// @dev Set a cutoff timestamp to invalidate all orders whose timestamp /// is smaller than or equal to the new value of the address's cutoff /// timestamp. /// @param cutoff The cutoff timestamp, will default to `block.timestamp` /// if it is 0. function setCutoff(uint cutoff) public; }
contract LoopringProtocol { //////////////////////////////////////////////////////////////////////////// /// Constants /// //////////////////////////////////////////////////////////////////////////// uint public constant FEE_SELECT_LRC = 0; uint public constant FEE_SELECT_MARGIN_SPLIT = 1; uint public constant FEE_SELECT_MAX_VALUE = 1; uint public constant MARGIN_SPLIT_PERCENTAGE_BASE = 10000; //////////////////////////////////////////////////////////////////////////// /// Structs /// //////////////////////////////////////////////////////////////////////////// /// @param tokenS Token to sell. /// @param tokenB Token to buy. /// @param amountS Maximum amount of tokenS to sell. /// @param amountB Minimum amount of tokenB to buy if all amountS sold. /// @param timestamp Indicating whtn this order is created/signed. /// @param ttl Indicating after how many seconds from `timestamp` /// this order will expire. /// @param salt A random number to make this order's hash unique. /// @param lrcFee Max amount of LRC to pay for miner. The real amount /// to pay is proportional to fill amount. /// @param buyNoMoreThanAmountB - /// If true, this order does not accept buying more /// than `amountB`. /// @param marginSplitPercentage - /// The percentage of margin paid to miner. /// @param v ECDSA signature parameter v. /// @param r ECDSA signature parameters r. /// @param s ECDSA signature parameters s. struct Order { address owner; address tokenS; address tokenB; uint amountS; uint amountB; uint timestamp; uint ttl; uint salt; uint lrcFee; bool buyNoMoreThanAmountB; uint8 marginSplitPercentage; uint8 v; bytes32 r; bytes32 s; } //////////////////////////////////////////////////////////////////////////// /// Public Functions /// //////////////////////////////////////////////////////////////////////////// /// @dev Submit a order-ring for validation and settlement. /// @param addressList List of each order's owner and tokenS. Note that next /// order's `tokenS` equals this order's `tokenB`. /// @param uintArgsList List of uint-type arguments in this order: /// amountS, AmountB, rateAmountS, timestamp, ttl, salt, /// and lrcFee. /// @param uint8ArgsList - /// List of unit8-type arguments, in this order: /// marginSplitPercentageList, feeSelectionList. /// @param vList List of v for each order. This list is 1-larger than /// the previous lists, with the last element being the /// v value of the ring signature. /// @param rList List of r for each order. This list is 1-larger than /// the previous lists, with the last element being the /// r value of the ring signature. /// @param sList List of s for each order. This list is 1-larger than /// the previous lists, with the last element being the /// s value of the ring signature. /// @param ringminer The address that signed this tx. /// @param feeRecepient The recepient address for fee collection. If this is /// '0x0', all fees will be paid to the address who had /// signed this transaction, not `msg.sender`. Noted if /// LRC need to be paid back to order owner as the result /// of fee selection model, LRC will also be sent from /// this address. /// @param throwIfLRCIsInsuffcient - /// If true, throw exception if any order's spendable /// LRC amount is smaller than requried; if false, ring- /// minor will give up collection the LRC fee. function submitRing( address[2][] addressList, uint[7][] uintArgsList, uint8[2][] uint8ArgsList, bool[] buyNoMoreThanAmountBList, uint8[] vList, bytes32[] rList, bytes32[] sList, address ringminer, address feeRecepient, bool throwIfLRCIsInsuffcient ) public; /// @dev Cancel a order. cancel amount(amountS or amountB) can be specified /// in orderValues. /// @param addresses owner, tokenS, tokenB /// @param orderValues amountS, amountB, timestamp, ttl, salt, lrcFee, /// cancelAmountS, and cancelAmountB. /// @param marginSplitPercentage - /// @param buyNoMoreThanAmountB - /// @param v Order ECDSA signature parameter v. /// @param r Order ECDSA signature parameters r. /// @param s Order ECDSA signature parameters s. function cancelOrder( address[3] addresses, uint[7] orderValues, bool buyNoMoreThanAmountB, uint8 marginSplitPercentage, uint8 v, bytes32 r, bytes32 s ) public; /// @dev Set a cutoff timestamp to invalidate all orders whose timestamp /// is smaller than or equal to the new value of the address's cutoff /// timestamp. /// @param cutoff The cutoff timestamp, will default to `block.timestamp` /// if it is 0. function setCutoff(uint cutoff) public; }
7,208
70
// do not allow to drain lpToken if less than 3 months after farming
require(_token != bsd, "!bsd"); for (uint256 pid = 0; pid < poolLength; ++pid) { PoolInfo storage pool = poolInfo[pid]; require(_token != pool.lpToken, "!pool.lpToken"); }
require(_token != bsd, "!bsd"); for (uint256 pid = 0; pid < poolLength; ++pid) { PoolInfo storage pool = poolInfo[pid]; require(_token != pool.lpToken, "!pool.lpToken"); }
2,167
92
// Update new and old observations if elapsed time is greater than or equal to anchor period
uint timeElapsed = block.timestamp - newObservation.timestamp; if (timeElapsed >= anchorPeriod) { oldObservations[symbolHash].timestamp = newObservation.timestamp; oldObservations[symbolHash].acc = newObservation.acc; newObservations[symbolHash].timestamp = block.timestamp; newObservations[symbolHash].acc = cumulativePrice; emit UniswapWindowUpdated(config.symbolHash, newObservation.timestamp, block.timestamp, newObservation.acc, cumulativePrice); }
uint timeElapsed = block.timestamp - newObservation.timestamp; if (timeElapsed >= anchorPeriod) { oldObservations[symbolHash].timestamp = newObservation.timestamp; oldObservations[symbolHash].acc = newObservation.acc; newObservations[symbolHash].timestamp = block.timestamp; newObservations[symbolHash].acc = cumulativePrice; emit UniswapWindowUpdated(config.symbolHash, newObservation.timestamp, block.timestamp, newObservation.acc, cumulativePrice); }
2,092
39
// Mark a store front as (de)activated./
function storeFrontActivator(uint _sFID, bool status) public ownsStore(_sFID)
function storeFrontActivator(uint _sFID, bool status) public ownsStore(_sFID)
43,929
22
// Construct a new Comp token account The initial account to grant all the tokens /
constructor(address account, uint256 cap) public { require(cap > 0, "Capped: cap is 0"); _cap = cap; balances[account] = _totalSupply; emit Transfer(address(0), account, _totalSupply); }
constructor(address account, uint256 cap) public { require(cap > 0, "Capped: cap is 0"); _cap = cap; balances[account] = _totalSupply; emit Transfer(address(0), account, _totalSupply); }
10,578
43
// Get revert error message from a .call method
function getRevertMsg(bytes memory _returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_returnData.length < 68) return "Transaction reverted silently"; assembly { // Slice the sighash. _returnData := add(_returnData, 0x04) } return abi.decode(_returnData, (string)); // All that remains is the revert string }
function getRevertMsg(bytes memory _returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_returnData.length < 68) return "Transaction reverted silently"; assembly { // Slice the sighash. _returnData := add(_returnData, 0x04) } return abi.decode(_returnData, (string)); // All that remains is the revert string }
20,870
9
// -------------------- Admin functions
function getStatus() external view returns(uint)
function getStatus() external view returns(uint)
48,424
37
// Burns a specific amount of tokens. _value The amount of token to be burned. /
function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _value); }
function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _value); }
940
1
// Runlog request /
) public override onlyOwner returns (bytes32 requestId) { Chainlink.Request memory req = buildChainlinkRequest( stringToBytes32(jobId), address(this), this.fulfillUInt256.selector ); req.add('url', url); req.add('path', path); req.addInt('times', times); requestId = sendChainlinkRequestTo(oracle, req, payment); emit RequestUInt256(requestId, oracle, jobId, payment, url, path, times); }
) public override onlyOwner returns (bytes32 requestId) { Chainlink.Request memory req = buildChainlinkRequest( stringToBytes32(jobId), address(this), this.fulfillUInt256.selector ); req.add('url', url); req.add('path', path); req.addInt('times', times); requestId = sendChainlinkRequestTo(oracle, req, payment); emit RequestUInt256(requestId, oracle, jobId, payment, url, path, times); }
29,636
51
// Merge all subtrees to form the shortest possible tree.This function can be called either once to merge all subtrees in asingle transaction, or multiple times to do the same in multipletransactions. If _numSrQueueOps is set to 0, this function will attemptto merge all subtrees in one go. If it is set to a number greater than0, it will perform up to that number of queueSubRoot() operations. _numSrQueueOps The number of times this function will callqueueSubRoot(), up to the maximum number of timesis necessary. If it is set to 0, it will callqueueSubRoot() as many times as is necessary. Setthis to
function mergeSubRoots( uint256 _numSrQueueOps
function mergeSubRoots( uint256 _numSrQueueOps
37,573
20
// The balance of any account can be calculated from the Transfer events history. However, since we need to keep the balances to validate transfer request, there is no extra cost to also privide a querry function.
return balances[_id][_owner];
return balances[_id][_owner];
50,803
1
// Returns if the given address is qualified, implemented on demand. /
function ifQualified (address testee) external view returns (bool);
function ifQualified (address testee) external view returns (bool);
60,445
60
// Function to add minter address. return True if the operation was successful./
function addMinter( address _minter) public onlyOwner canMint returns (bool)
function addMinter( address _minter) public onlyOwner canMint returns (bool)
22,299
13
// store the ad, return the index
Ad memory ad = Ad(msg.sender, _x, _y, _width, _height, _title, _link, _ipfsHash, false, true, price); idx = ads.push(ad) - 1;
Ad memory ad = Ad(msg.sender, _x, _y, _width, _height, _title, _link, _ipfsHash, false, true, price); idx = ads.push(ad) - 1;
26,004
303
// Whether or not the crowdsale is post-purchase
function isFinished() internal pure returns (bytes32)
function isFinished() internal pure returns (bytes32)
74,608
14
// if not last index, swap with last element
uint256 index = priceFeederIndices[_account]; uint256 lastIndex = priceFeeders.length - 1; if (index != lastIndex) { priceFeeders[index] = priceFeeders[lastIndex]; }
uint256 index = priceFeederIndices[_account]; uint256 lastIndex = priceFeeders.length - 1; if (index != lastIndex) { priceFeeders[index] = priceFeeders[lastIndex]; }
41,608
33
// PAUSE/ Modifier to make a function callable only when the contract is not paused. /
modifier whenNotPaused() { if(msg.sender != owner()) { require(!paused, "Pausable: paused"); } _; }
modifier whenNotPaused() { if(msg.sender != owner()) { require(!paused, "Pausable: paused"); } _; }
30,086
41
// Allows for Limbo to be upgraded 1 user at a time without introducing a system wide security risk
function unstakeFor( address token, uint256 amount, address holder
function unstakeFor( address token, uint256 amount, address holder
36,064
215
// the address that is approved for spending this token
address operator;
address operator;
26,570
162
// Declare a boolean to indicate if call should return early.
bool returnEarly;
bool returnEarly;
33,080
2
// a bitmask for 247 bits where each set bit is blocking and signals closed
function blockedTimes(bytes32 id) public constant returns (uint);
function blockedTimes(bytes32 id) public constant returns (uint);
10,010
96
// A new investor
investorCount++;
investorCount++;
24,914
14
// Stage Transitions
error FunctionInvalidAtThisStage(); error SaleKeyNotSet(); error SaleMaxBatchNotSet(); error SaleMaxPerAddressNotSet(); error SaleTotalAllotmentNotSet(); error SalePriceNotSet();
error FunctionInvalidAtThisStage(); error SaleKeyNotSet(); error SaleMaxBatchNotSet(); error SaleMaxPerAddressNotSet(); error SaleTotalAllotmentNotSet(); error SalePriceNotSet();
16,288
7
// `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. _Available since v4.7._ /
function multiProofVerify( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] calldata leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; }
function multiProofVerify( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] calldata leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; }
8,762
9
// This view returns maximum valid deposit/asset_source Contract address for given ERC20 token/ return Maximum valid deposit of given ERC20 token
function get_deposit_maximum(address asset_source) public virtual view returns(uint256);
function get_deposit_maximum(address asset_source) public virtual view returns(uint256);
14,681
117
// when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); }
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); }
8,187
49
// Updates the execution grace period/_newGracePeriod The new grace period
function updateGracePeriod(uint256 _newGracePeriod) external { // Ensure the caller is the treasury itself if (msg.sender != address(this)) revert ONLY_TREASURY(); emit GracePeriodUpdated(settings.gracePeriod, _newGracePeriod); // Update the grace period settings.gracePeriod = SafeCast.toUint128(_newGracePeriod); }
function updateGracePeriod(uint256 _newGracePeriod) external { // Ensure the caller is the treasury itself if (msg.sender != address(this)) revert ONLY_TREASURY(); emit GracePeriodUpdated(settings.gracePeriod, _newGracePeriod); // Update the grace period settings.gracePeriod = SafeCast.toUint128(_newGracePeriod); }
16,409
6
// Get address of sender
address payable bettor; bettor = msg.sender;
address payable bettor; bettor = msg.sender;
42,010
39
// pragma solidity >=0.5.0;
interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
78,399
35
// vestedAmount = lockedAmount elapsedBatchCount / batchCount
uint256 vestedAmount = lockedAmount .mul(elapsedBatchCount) .div(incvBatchCount); if(vestedAmount > lockedAmount){ vestedAmount = lockedAmount; }
uint256 vestedAmount = lockedAmount .mul(elapsedBatchCount) .div(incvBatchCount); if(vestedAmount > lockedAmount){ vestedAmount = lockedAmount; }
25,415
35
// function to get animal details by id /
{ if(animalAgainstId[aid].eggPhase==true) { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, 2**256 - 1, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } else { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, animalAgainstId[aid].id, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } }
{ if(animalAgainstId[aid].eggPhase==true) { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, 2**256 - 1, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } else { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, animalAgainstId[aid].id, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } }
1,228
204
// Emitted after a successful withdrawal./user The address that withdrew from the Vault./underlyingAmount The amount of underlying tokens that were withdrawn.
event Withdraw(address indexed user, uint256 underlyingAmount);
event Withdraw(address indexed user, uint256 underlyingAmount);
25,862
7
// the token owners
uint256[] private tokenHashes;
uint256[] private tokenHashes;
31,983
256
// Value of newly placed bid on ReserveAuctionV3 item
event PartyBidPlaced(uint256 auctionID, uint256 value);
event PartyBidPlaced(uint256 auctionID, uint256 value);
25,438
28
// future listing
Marketplace.ListingParameters memory listing; listing.assetContract = address(erc721); listing.tokenId = tokenId; listing.startTime = 200 days; listing.secondsUntilEndTime = 1 * 24 * 60 * 60; // 1 day listing.quantityToList = 1; listing.currencyToAccept = NATIVE_TOKEN; listing.reservePricePerToken = 0; listing.buyoutPricePerToken = 1 ether; listing.listingType = IMarketplace.ListingType.Direct;
Marketplace.ListingParameters memory listing; listing.assetContract = address(erc721); listing.tokenId = tokenId; listing.startTime = 200 days; listing.secondsUntilEndTime = 1 * 24 * 60 * 60; // 1 day listing.quantityToList = 1; listing.currencyToAccept = NATIVE_TOKEN; listing.reservePricePerToken = 0; listing.buyoutPricePerToken = 1 ether; listing.listingType = IMarketplace.ListingType.Direct;
51,930
1,194
// This newSettleTime will be set to the new `oldSettleTime`. The bits between 1 and `lastSettleBit` (inclusive) will be shifted out of the bitmap and settled. The reason that lastSettleBit is inclusive is that it refers to newSettleTime which always less than the current block time.
newSettleTime = DateTime.getTimeUTC0(blockTime);
newSettleTime = DateTime.getTimeUTC0(blockTime);
63,521
15
// Writes the property name and boolean value (as a JSON literal "true" or "false") as part of a name/value pair of a JSON object. /
function writeBooleanProperty( Json memory json, string memory propertyName, bool value
function writeBooleanProperty( Json memory json, string memory propertyName, bool value
33,865
22
// returns the number of votes of a given candidate
function getCandidateVotes(address candidateAddress) public view returns (uint256)
function getCandidateVotes(address candidateAddress) public view returns (uint256)
4,472
38
// Collection name
bytes32 name;
bytes32 name;
33,691