comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
// Frees up to `value` sub-tokens owned by address `from`. Returns how many tokens were freed.
// Otherwise, identical to `freeFrom`. | function freeFromUpTo(address from, uint256 value) public returns (uint256 freed) {
address spender = msg.sender;
uint256 from_balance = s_balances[from];
if (value > from_balance) {
value = from_balance;
}
mapping(address => uint256) from_allowances = s_allow... | 0.4.20 |
/// @notice Creates a vesting position
/// @param account Account which to add vesting position for
/// @param startTime when the positon should start
/// @param amount Amount to add to vesting position
/// @dev The startstime paramter allows some leeway when creating
/// positions for new employees | function vest(address account, uint256 startTime, uint256 amount) external override onlyOwner {
require(account != address(0), "vest: !account");
require(amount > 0, "vest: !amount");
if (startTime + START_TIME_LOWER_BOUND < block.timestamp) {
startTime = block.timestamp;
}
... | 0.8.4 |
/// @notice owner can withdraw excess tokens
/// @param amount amount to be withdrawns | function withdraw(uint256 amount) external onlyOwner {
( , , uint256 available ) = globallyUnlocked();
require(amount <= available, 'withdraw: not enough assets available');
// Need to accoount for the withdrawn assets, they are no longer available
// in the employee pool
... | 0.8.4 |
/// @notice claim an amount of tokens
/// @param amount amount to be claimed | function claim(uint256 amount) external override {
require(amount > 0, "claim: No amount specified");
(uint256 unlocked, uint256 available, , ) = unlockedBalance(msg.sender);
require(available >= amount, "claim: Not enough user assets available");
uint256 _withdrawn = unlocked - availa... | 0.8.4 |
/// @notice stops an employees vesting position
/// @param employee employees account | function stopVesting(address employee) external onlyOwner {
(uint256 unlocked, uint256 available, uint256 startTime, ) = unlockedBalance(employee);
require(startTime > 0, 'stopVesting: No position for user');
EmployeePosition storage ep = employeePositions[employee];
vestingAssets -= ep.... | 0.8.4 |
/// @notice see the amount of vested assets the account has accumulated
/// @param account Account to get vested amount for | function unlockedBalance(address account)
internal
view
override
returns ( uint256, uint256, uint256, uint256 )
{
EmployeePosition storage ep = employeePositions[account];
uint256 startTime = ep.startTime;
if (block.timestamp < startTime + VESTING_CLIFF) {
... | 0.8.4 |
// Transfer a part to an address | function _transfer(address _from, address _to, uint256 _tokenId) internal {
// No cap on number of parts
// Very unlikely to ever be 2^256 parts owned by one account
// Shouldn't waste gas checking for overflow
// no point making it less than a uint --> mappings don't pack
a... | 0.4.20 |
// helper functions adapted from Jossie Calderon on stackexchange | function stringToUint32(string s) internal pure returns (uint32) {
bytes memory b = bytes(s);
uint result = 0;
for (uint i = 0; i < b.length; i++) { // c = b[i] was not needed
if (b[i] >= 48 && b[i] <= 57) {
result = result * 10 + (uint(b[i]) - 48); // bytes and ... | 0.4.20 |
/// internal function which checks whether the token with id (_tokenId)
/// is owned by the (_claimant) address | function ownsAll(address _owner, uint256[] _tokenIds) public view returns (bool) {
require(_tokenIds.length > 0);
for (uint i = 0; i < _tokenIds.length; i++) {
if (partIndexToOwner[_tokenIds[i]] != _owner) {
return false;
}
}
return true;
... | 0.4.20 |
// transfers a part to another account | function transfer(address _to, uint256 _tokenId) public whenNotPaused payable {
// payable for ERC721 --> don't actually send eth @_@
require(msg.value == 0);
// Safety checks to prevent accidental transfers to common accounts
require(_to != address(0));
require(_to != add... | 0.4.20 |
// approves the (_to) address to use the transferFrom function on the token with id (_tokenId)
// if you want to clear all approvals, simply pass the zero address | function approve(address _to, uint256 _deedId) external whenNotPaused payable {
// payable for ERC721 --> don't actually send eth @_@
require(msg.value == 0);
// use internal function?
// Cannot approve the transfer of tokens you don't own
require(owns(msg.sender, _deedId));
... | 0.4.20 |
// approves many token ids | function approveMany(address _to, uint256[] _tokenIds) external whenNotPaused payable {
for (uint i = 0; i < _tokenIds.length; i++) {
uint _tokenId = _tokenIds[i];
// Cannot approve the transfer of tokens you don't own
require(owns(msg.sender, _tokenId));
... | 0.4.20 |
// transfer the part with id (_tokenId) from (_from) to (_to)
// (_to) must already be approved for this (_tokenId) | function transferFrom(address _from, address _to, uint256 _tokenId) public whenNotPaused {
// Safety checks to prevent accidents
require(_to != address(0));
require(_to != address(this));
// sender must be approved
require(partIndexToApproved[_tokenId] == msg.sender);
... | 0.4.20 |
// This is public so it can be called by getPartsOfOwner. It should NOT be called by another contract
// as it is very gas hungry. | function getPartsOfOwnerWithinRange(address _owner, uint _start, uint _numToSearch) public view returns(bytes24[]) {
uint256 tokenCount = balanceOf(_owner);
uint resultIndex = 0;
bytes24[] memory result = new bytes24[](tokenCount);
for (uint partId = _start; partId < _start + _numT... | 0.4.20 |
// every level, you need 1000 more exp to go up a level | function getLevel(uint32 _exp) public pure returns(uint32) {
uint32 c = 0;
for (uint32 i = FIRST_LEVEL; i <= FIRST_LEVEL + _exp; i += c * INCREMENT) {
c++;
}
return c;
} | 0.4.20 |
// code duplicated | function _tokenOfOwnerByIndex(address _owner, uint _index) private view returns (uint _tokenId){
// The index should be valid.
require(_index < balanceOf(_owner));
// can loop through all without
uint256 seen = 0;
uint256 totalTokens = totalSupply();
for (uint i... | 0.4.20 |
// sum of perks (excluding prestige) | function _sumActivePerks(uint8[32] _perks) internal pure returns (uint256) {
uint32 sum = 0;
//sum from after prestige_index, to count+1 (for prestige index).
for (uint8 i = PRESTIGE_INDEX+1; i < PERK_COUNT+1; i++) {
sum += _perks[i];
}
return sum;
} | 0.4.20 |
// you can unlock a new perk every two levels (including prestige when possible) | function choosePerk(uint8 _i) external {
require((_i >= PRESTIGE_INDEX) && (_i < PERK_COUNT+1));
User storage currentUser = addressToUser[msg.sender];
uint256 _numActivePerks = _sumActivePerks(currentUser.perks);
bool canPrestige = (_numActivePerks == PERK_COUNT);
//add pr... | 0.4.20 |
// Calculates price and transfers purchase to owner. Part is NOT transferred to buyer. | function _purchase(uint256 _partId, uint256 _purchaseAmount) internal returns (uint256) {
Auction storage auction = tokenIdToAuction[_partId];
// check that this token is being auctioned
require(_isActiveAuction(auction));
// enforce purchase >= the current price
uint2... | 0.4.20 |
// computes the current price of an deflating-price auction | function _computeCurrentPrice( uint256 _startPrice, uint256 _endPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256 _price) {
_price = _startPrice;
if (_secondsPassed >= _duration) {
// Has been up long enough to hit endPrice.
// Return this pric... | 0.4.20 |
// Creates an auction and lists it. | function createAuction( uint256 _partId, uint256 _startPrice, uint256 _endPrice, uint256 _duration, address _seller ) external whenNotPaused {
// Sanity check that no inputs overflow how many bits we've allocated
// to store them in the auction struct.
require(_startPrice == uint256(uint128(_... | 0.4.20 |
// Purchases an open auction
// Will transfer ownership if successful. | function purchase(uint256 _partId) external payable whenNotPaused {
address seller = tokenIdToAuction[_partId].seller;
// _purchase will throw if the purchase or funds transfer fails
uint256 price = _purchase(_partId, msg.value);
_transfer(msg.sender, _partId);
/... | 0.4.20 |
// Returns the details of an auction from its _partId. | function getAuction(uint256 _partId) external view returns ( address seller, uint256 startPrice, uint256 endPrice, uint256 duration, uint256 startedAt ) {
Auction storage auction = tokenIdToAuction[_partId];
require(_isActiveAuction(auction));
return ( auction.seller, auction.startPrice, auct... | 0.4.20 |
// list a part for auction. | function createAuction(
uint256 _partId,
uint256 _startPrice,
uint256 _endPrice,
uint256 _duration ) external whenNotPaused
{
// user must have current control of the part
// will lose control if they delegate to the auction
// therefore no duplic... | 0.4.20 |
/// An internal method that creates a new part and stores it. This
/// method doesn't do any checking and should only be called when the
/// input data is known to be valid. Will generate both a Forge event
/// and a Transfer event. | function _createPart(uint8[4] _partArray, address _owner) internal returns (uint) {
uint32 newPartId = uint32(parts.length);
assert(newPartId == parts.length);
Part memory _part = Part({
tokenId: newPartId,
partType: _partArray[0],
partSubType: _partAr... | 0.4.20 |
// uint8[] public defenceElementBySubtypeIndex = [1,2,4,3,4,1,3,3,2,1,4];
// uint8[] public meleeElementBySubtypeIndex = [3,1,3,2,3,4,2,2,1,1,1,1,4,4];
// uint8[] public bodyElementBySubtypeIndex = [2,1,2,3,4,3,1,1,4,2,3,4,1,0,1]; // no more lambos :'(
// uint8[] public turretElementBySubtypeIndex = [4,3,2,1,2,1,1,3,4,... | function setRewardChance(uint _newChance) external onlyOwner {
require(_newChance > 980); // not too hot
require(_newChance <= 1000); // not too cold
PART_REWARD_CHANCE = _newChance; // just right
// come at me goldilocks
} | 0.4.20 |
// function _randomIndex(uint _rand, uint8 _startIx, uint8 _endIx, uint8 _modulo) internal pure returns (uint8) {
// require(_startIx < _endIx);
// bytes32 randBytes = bytes32(_rand);
// uint result = 0;
// for (uint8 i=_startIx; i<_endIx; i++) {
// result = result | uint8(randBytes[i]);
// ... | function _generateRandomPart(uint _rand, address _owner) internal {
// random uint 20 in length - MAYBE 20.
// first randomly gen a part type
_rand = uint(keccak256(_rand));
uint8[4] memory randomPart;
randomPart[0] = uint8(_rand % 4) + 1;
_rand = uint(keccak256(_ra... | 0.4.20 |
// scraps a part for shards | function scrap(uint partId) external {
require(owns(msg.sender, partId));
User storage u = addressToUser[msg.sender];
_addShardsToUser(u, (SHARDS_TO_PART * scrapPercent) / 100);
Scrap(msg.sender, partId);
// this doesn't need to be secure
// no way to manipulate it ... | 0.4.20 |
// store the part information of purchased crates | function openAll() public {
uint len = addressToPurchasedBlocks[msg.sender].length;
require(len > 0);
uint8 count = 0;
// len > i to stop predicatable wraparound
for (uint i = len - 1; i >= 0 && len > i; i--) {
uint crateBlock = addressToPurchasedBlocks[msg.send... | 0.4.20 |
// convert old string representation of robot into 4 new ERC721 parts | function _convertBlueprint(string original) pure private returns(uint8[4] body,uint8[4] melee, uint8[4] turret, uint8[4] defence ) {
/* ------ CONVERSION TIME ------ */
body[0] = BODY;
body[1] = _getPartId(original, 3, 5, 15);
body[2] = _getRarity(original, 0, 3);
... | 0.4.20 |
// Users can open pending crates on the new contract. | function openCrates() public whenNotPaused {
uint[] memory pc = pendingCrates[msg.sender];
require(pc.length > 0);
uint8 count = 0;
for (uint i = 0; i < pc.length; i++) {
uint crateBlock = pc[i];
require(block.number > crateBlock);
// can't open... | 0.4.20 |
// in PerksRewards | function redeemBattleCrates() external {
uint8 count = 0;
uint len = pendingRewards[msg.sender].length;
require(len > 0);
for (uint i = 0; i < len; i++) {
Reward memory rewardStruct = pendingRewards[msg.sender][i];
// can't open on the same timestamp
... | 0.4.20 |
// don't need to do any scaling
// should already have been done by previous stages | function _addUserExperience(address user, int32 exp) internal {
// never allow exp to drop below 0
User memory u = addressToUser[user];
if (exp < 0 && uint32(int32(u.experience) + exp) > u.experience) {
u.experience = 0;
return;
} else if (exp > 0) {
... | 0.4.20 |
//requires parts in order | function hasOrderedRobotParts(uint[] partIds) external view returns(bool) {
uint len = partIds.length;
if (len != 4) {
return false;
}
for (uint i = 0; i < len; i++) {
if (parts[partIds[i]].partType != i+1) {
return false;
}
... | 0.4.20 |
/*
* @notice Mints specified amount of tokens on the public sale
* @dev Non reentrant. Emits PublicSaleMint event
* @param _amount Amount of tokens to mint
*/ | function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused {
require(saleState == 3, "public sale isn't active");
require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount");
uint256 maxTotalSupply_ = maxTotalSupply;
uint256 totalSupply_ = totalSup... | 0.8.5 |
/*
* @notice Mints specified IDs to specified addresses
* @dev Only owner can call it. Lengths of arrays must be equal.
* @param _accounts The list of addresses to mint tokens to
*/ | function giveaway(address[] memory _accounts) external onlyOwner {
uint256 maxTotSup = maxTotalSupply;
uint256 currentTotalSupply = totalSupply();
require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded");
require(airdropCounter + _accounts.length <= amountForGi... | 0.8.5 |
/*
* @dev The main logic for the pre sale mint. Emits PreSaleMint event
* @param _amount The amount of tokens
*/ | function _preSaleMintVipPl(uint256 _amount) private {
require(saleState == 1, "VIP Presale isn't active");
require(_amount > 0, "invalid amount");
require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded");
uint256 totalSupply_ = totalSuppl... | 0.8.5 |
/*
* @dev Mints tokens for the user and refunds ETH if too much was passed
* @param _amount The amount of tokens
* @param _price The price for each token
*/ | function _buyAndRefund(uint256 _amount, uint256 _price) internal {
uint256 totalCost = _amount * _price;
require(msg.value >= totalCost, "not enough funds");
_safeMint(_msgSender(), _amount);
// totalSupply += uint16(_amount);
mintCounter += uint16(_amount);
uint256 refun... | 0.8.5 |
// METHODS
// constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them (msg.sender is not added to the owners!). | function multiowned(address[] _owners, uint _required)
validNumOwners(_owners.length)
multiOwnedValidRequirement(_required, _owners.length)
{
assert(c_maxOwners <= 255);
m_numOwners = _owners.length;
m_multiOwnedRequired = _required;
for (uint i = 0; i < _owners.le... | 0.4.18 |
// All pending operations will be canceled! | function removeOwner(address _owner)
external
ownerExists(_owner)
validNumOwners(m_numOwners - 1)
multiOwnedValidRequirement(m_multiOwnedRequired, m_numOwners - 1)
onlymanyowners(sha3(msg.data))
{
assertOwnersAreConsistent();
clearPending();
uint ownerIndex = c... | 0.4.18 |
// Reclaims free slots between valid owners in m_owners.
// TODO given that its called after each removal, it could be simplified. | function reorganizeOwners() private {
uint free = 1;
while (free < m_numOwners)
{
// iterating to the first free slot from the beginning
while (free < m_numOwners && m_owners[free] != 0) free++;
// iterating to the first occupied slot from the end
... | 0.4.18 |
/**
* @dev transfer tokens to the specified address
* @param _to The address to transfer to
* @param _value The amount to be transferred
* @return bool A successful transfer returns true
*/ | function transfer(address _to, uint256 _value) returns (bool success) {
require(_to != address(0));
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to... | 0.4.16 |
// ------------------------------------------------------------------------
// 100 BFCL Tokens per 1 ETH
// ------------------------------------------------------------------------ | function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
if (now <= bonusEnds) {
tokens = msg.value * 360;
} else {
tokens = msg.value * 300;
}
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
... | 0.4.24 |
// ============ Main View Functions ============== | function getPools(string[] calldata poolIds)
external
view
override
returns (address[] memory poolAddresses)
{
poolAddresses = new address[](poolIds.length);
for (uint256 i = 0; i < poolIds.length; i++) {
poolAddresses[i] = pools[poolIds[i]];
}
... | 0.7.6 |
/**
* @dev transfer tokens from one address to another
* @param _from address The address that you want to send tokens from
* @param _to address The address that you want to transfer to
* @param _value uint256 The amount to be transferred
* @return bool A successful transfer returns true
*/ | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
require(_to != address(0));
uint256 _allowance = allowed[_from][msg.sender];
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender... | 0.4.16 |
/**
* @dev Extend parent behavior requiring beneficiary to be in whitelist.
* @param _beneficiary Token beneficiary
* @param _weiAmount Amount of wei contributed
*/ | function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
whenNotPaused
{
super._preValidatePurchase(_beneficiary, _weiAmount);
if(block.timestamp <= openingTime + (2 weeks)) {
require(whitelist[_beneficiary]);
... | 0.4.24 |
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/ | function _forwardFunds()
internal
{
// referer bonus
if(msg.data.length == 20) {
address referrerAddress = bytesToAddres(bytes(msg.data));
require(referrerAddress != address(token) && referrerAddress != msg.sender);
uint256 referrerAmount = msg.value.mu... | 0.4.24 |
/**
* Set the Pool Config, initializes an instance of and start the pool.
*
* @param _numOfWinners Number of winners in the pool
* @param _participantLimit Maximum number of paricipants
* @param _enterAmount Exact amount to enter this pool
* @param _feePercentage Manager fee of t... | function setPoolRules(
uint256 _numOfWinners,
uint256 _participantLimit,
uint256 _enterAmount,
uint256 _feePercentage,
uint256 _randomSeed
) external onlyOwner {
require(poolStatus == PoolStatus.NOTSTARTED, "in progress");
require(_numOfWinners != 0, "... | 0.6.10 |
/*
* Function to mint NFTs
*/ | function mint(address to, uint32 count) internal {
if (count > 1) {
uint256[] memory ids = new uint256[](uint256(count));
uint256[] memory amounts = new uint256[](uint256(count));
for (uint32 i = 0; i < count; i++) {
ids[i] = totalSupply + i;
... | 0.8.7 |
/*
* Function to withdraw collected amount during minting by the owner
*/ | function withdraw(
address _to
)
public
onlyOwner
{
uint balance = address(this).balance;
require(balance > 0, "Balance should be more then zero");
if(balance <= devSup) {
payable(devAddress).transfer(balance);
devSup = devSup.sub(balance)... | 0.8.7 |
/*
* Function to mint new NFTs during the public sale
* It is payable. Amount is calculated as per (NFTPrice.mul(_numOfTokens))
*/ | function mintNFT(
uint32 _numOfTokens
)
public
payable
{
require(isActive, 'Contract is not active');
require(!isPrivateSaleActive, 'Private sale still active');
require(!isPresaleActive, 'Presale still active');
require(totalSupply.add(_numOfTokens).sub(g... | 0.8.7 |
/*
* Function to mint new NFTs during the private sale & presale
* It is payable.
*/ | function mintNFTDuringPresale(
uint32 _numOfTokens,
bytes32[] memory _proof
)
public
payable
{
require(isActive, 'Contract is not active');
require(verify(_proof, bytes32(uint256(uint160(msg.sender)))), "Not whitelisted");
if (!isPresaleActive) {
... | 0.8.7 |
/*
* Function to mint all NFTs for giveaway and partnerships
*/ | function mintMultipleByOwner(
address[] memory _to
)
public
onlyOwner
{
require(totalSupply.add(_to.length) < MAX_NFT, "Tokens number to mint cannot exceed number of MAX tokens");
require(giveawayCount.add(_to.length)<=maxGiveaway,"Cannot do that much giveaway");
... | 0.8.7 |
/*
* Function to verify the proof
*/ | function verify(bytes32[] memory proof, bytes32 leaf) public view returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + curr... | 0.8.7 |
/**
* Enter pool with ETH
*/ | function enterPoolEth() external payable onlyValidPool onlyEOA returns (uint256) {
require(msg.value == poolConfig.enterAmount, "insufficient amount");
if (!_isEthPool()) {
revert("not accept ETH");
}
// wrap ETH to WETH
IWETH(controller.getWeth()).deposit{ valu... | 0.6.10 |
/**
* @dev Set time of dividend Payments.
* @return Start_reward
*/ | function dividendPaymentsTime (uint256 _start) public onlyOwner returns (uint256 Start_reward, uint256 End_reward) {
uint256 check_time = block.timestamp;
require (check_time < _start, "WRONG TIME, LESS THEM CURRENT");
// require (check_time < _start.add(2629743), "ONE MONTH BEFORE THE START OF PAYMENTS"... | 0.5.16 |
/*@dev call _token_owner address
* @return Revard _dividend
* private function dividend withdraw
*/ | function reward () public view returns (uint256 Reward) {
uint256 temp_allowance = project_owner.balance;
require(temp_allowance > 0, "BALANCE IS EMPTY");
require(balances[msg.sender] != 0, "ZERO BALANCE");
uint256 temp_Fas_count = balances[msg.sender];
uint256 _percentage = temp_Fas_count.mul(100000).... | 0.5.16 |
/**
* Distribution of benefits
* param _token_owner Divider's Token address
* binds the time stamp of receipt of dividends in struct 'Holder' to
* 'holders' to exclude multiple receipt of dividends, valid for 30 days.
* Dividends are received once a month.
* Dividends are debited from the Treasury address.
* The... | function dividendToReward() internal {
uint256 temp_allowance = project_owner.balance;
require(balances[msg.sender] != 0, "ZERO BALANCE");
require(temp_allowance > 0, "BALANCE IS EMPTY");
uint256 withdraw_time = block.timestamp;
require (withdraw_time > divide... | 0.5.16 |
/**@dev New member accepts the invitation of the Board of Directors.
* param Owner_Id used to confirm your consent to the invitation
* to the Board of Directors of the company valid for 24 hours.
* if the Owner_Id is not used during the day, the invitation is canceled
* 'Owner_Id' is deleted.
* only a new member o... | function acceptOwnership() public {
address new_owner = temporary_address;
require(msg.sender == new_owner, "ACCESS DENIED");
uint256 time_accept = block.timestamp;
difference_time = time_accept - acception_Id;
if (difference_time < 86400){
FASList.push(new_owner... | 0.5.16 |
/**@dev Removes a member from the company's Board of Directors.
* param address_owner this is the address of the Board member being
* removed. Only the project owner has access to call the function.
* The 'project_owner' cannot be deleted.
*/ | function delOwner (address address_owner) public {
require(msg.sender == project_owner, "ACCESS DENIED");
require (address_owner != project_owner, "IT IS IMPOSSIBLE TO REMOVE PROJECT OWNER");
uint256 Id_toDel = owners[address_owner].ID;
delete owners[address_owner];
delete FasID[Id_toDel].owner_addr... | 0.5.16 |
/**Invitation of a new member of the company's Board of Directors.
* Only the project owner has access to the function call.
* param _to address of the invited member of the company's Board of Directors
* A new member of the company's Board of Directors receives 'Owner_Id'.
*/ | function newOwnerInvite(address _to) public {
require (msg.sender == project_owner, "ACCESS DENIED");
require (balances[_to]>0, "ZERO BALANCE");
for (uint256 j = 0; j< Fas_number; j++){
require (FASList[j] != _to);
}
beforeNewOwnerInvite(_to);
... | 0.5.16 |
/** @dev Function to start the voting process. Call access only project_owner.
* Clears the previous result of the vote. Sets a time stamp for the
* start of voting.
* @return votes_num
*/ | function createVote() public returns (uint256){
require (msg.sender == project_owner, "ACCESS DENIED");
votes_num = votes_num.add(1);
vote_start = block.timestamp;
voteEndTime = vote_start.add(voting_period);
voteResult_Agree = 0;
voteResult_Dissagree = 0;
lastVot... | 0.5.16 |
/**
* vote for a given votes_num
* param Owner_Id the given rights to vote
* param _vote_status_value uint256 the vote of status, 1 Agree, 0 Disagree
* Only a member of the company's Board of Directors has the right to vote.
* You can only vote once during the voting period
*/ | function vote(uint256 Owner_Id, uint256 _vote_status_value) public{
require(_vote_status_value >= 0, "INPUT: 1 = AGREE, 0 = DISAGREE");
require(_vote_status_value <= 1, "INPUT: 1 = AGREE, 0 = DISAGREE");
uint256 voting_time = block.timestamp;
address check_address = FasID[Owner_Id].owner... | 0.5.16 |
/**
* @dev Called only after the end of the voting time.
* @return the voting restult: vote_num, voteResult, quorum_summ, vote_start, vote_end
*/ | function getVoteResult() public returns (uint256[] memory){
uint256 current_time = block.timestamp;
require (vote_start < current_time, "VOTING HAS NOT STARTED");
voteEndTime = vote_start.add(voting_period);
require (current_time > voteEndTime, "THE VOTE ISN'T OVER YET");
... | 0.5.16 |
/**
* Reset the pool, clears the existing state variable values and the pool can be initialized again.
*/ | function _resetPool() internal {
poolStatus = PoolStatus.INPROGRESS;
delete totalEnteredAmount;
delete rewardPerParticipant;
isRNDGenerated = false;
randomResult = 0;
areWinnersGenerated = false;
delete winnerIndexes;
delete participants;
... | 0.6.10 |
/**
* Set the Pool Config, initializes an instance of and start the pool.
*
* @param _numOfWinners Number of winners in the pool
* @param _participantLimit Maximum number of paricipants
* @param _rewardAmount Reward amount of this pool
* @param _randomSeed Seed for Random Numbe... | function setPoolRules(
uint256 _numOfWinners,
uint256 _participantLimit,
uint256 _rewardAmount,
uint256 _randomSeed
) external onlyOwner {
require(poolStatus != PoolStatus.INPROGRESS, "in progress");
require(_numOfWinners != 0, "invalid numOfWinners");
... | 0.6.10 |
/**
* @dev Emits event to mint a token to the senders adress
* @param _tokenId address of the future owner of the token
*/ | function mintNFTWithID(uint256 _tokenId) public payable {
require(!_exists(_tokenId), "token_exists");
require(tx.gasprice * gasToMint <= msg.value, "min_price");
// pay owner the gas fee it needs to call mintTo
address payable payowner = address(uint160(owner()));
... | 0.5.17 |
/**
* @dev Track token transfers / upgrade potentials
*/ | function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override {
super._beforeTokenTransfer(from, to, tokenId);
// Skip freshly minted tokens to save gas
if (from != address(0)) {
tokenTransferCounts[tokenId] += 1;
... | 0.8.4 |
/**
* @dev Upgrade a token if it's ready
*/ | function upgradeToken(uint256 tokenId) external {
require(_exists(tokenId), "Update nonexistent token");
require(_msgSender() == ERC721.ownerOf(tokenId), "Must own token for upgrade");
require(tokenLevels[tokenId] < tokenTransferCounts[tokenId], "Token is not ready for upgrade");
u... | 0.8.4 |
/**
* @dev Return the mooncake text for a given tokenId and its level
*/ | function getMooncakeTextWithLevel(uint256 tokenId, uint256 level) public view returns (string memory) {
uint8[6] memory slotIds = getMooncakeTextSlotIds(tokenId, level);
string memory output = slot0[slotIds[0]];
if (slotIds[1] < 255) {
output = string(abi.encodePacked(output, s... | 0.8.4 |
/**
* @dev Mint tokens
*/ | function mintWithAffiliate(uint256 numberOfNfts, address affiliate) public payable nonReentrant {
// Checks
require(!contractSealed, "Contract sealed");
require(block.timestamp >= SALES_START_TIMESTAMP, "Not started");
require(numberOfNfts > 0, "Cannot mint 0 NFTs");
req... | 0.8.4 |
/**
* @dev Claim a free one
*/ | function claimOneFreeNft() external payable nonReentrant {
// Checks
require(!contractSealed, "Contract sealed");
require(block.timestamp >= CLAIM_START_TIMESTAMP, "Not started");
uint256 total = totalSupply();
require(total + 1 <= maxNftSupply, "Sold out");
req... | 0.8.4 |
/**
* @dev Return detail information about an owner's token (tokenId, current level, potential level, uri)
*/ | function tokenDetailOfOwnerByIndex(address _owner, uint256 index)
public
view
returns (
uint256,
uint256,
uint256,
string memory
)
{
uint256 tokenId = tokenOfOwnerByIndex(_owner, index);
uint256 tokenLevel = t... | 0.8.4 |
/**
* @dev Reserve tokens and gift tokens
*/ | function deployerMintMultiple(address[] calldata recipients) external payable onlyDeployer {
require(!contractSealed, "Contract sealed");
uint256 total = totalSupply();
require(total + recipients.length <= maxNftSupply, "Sold out");
for (uint256 i = 0; i < recipients.length; i++)... | 0.8.4 |
/**
* @dev Deployer parameters
*/ | function deployerSetParam(uint256 key, uint256 value) external onlyDeployer {
require(!contractSealed, "Contract sealed");
if (key == 0) {
SALES_START_TIMESTAMP = value;
} else if (key == 1) {
CLAIM_START_TIMESTAMP = value;
} else if (key == 2) {
... | 0.8.4 |
/**
* @dev Mints multiple tokens to an address and mints unminted maco cash.
* @dev Called by server
* @param _tokenIds array of ids of the token
* @param _to address of the future owner of the token
*/ | function mintMultipleTo(uint256[] memory _tokenIds, address _to, uint256 _notMinted) public onlyL2Account {
for(uint i = 0; i < _tokenIds.length;i++) {
require(!_exists(_tokenIds[i]), "token_exists");
_mint(_to, _tokenIds[i]);
}
mintedSupply = mintedSupply + uint32(_... | 0.5.17 |
/**
* @dev Deposits token on contract to use off-chain
* @param _tokenId address of the future owner of the token
*/ | function deposit(uint256 _tokenId) public {
require(ownerOf(_tokenId) == msg.sender, "deposit_not_by_owner");
// would be nicer to have address(this) instead of owner, but then
// for the release, the owner can not be approved by the contract
transferFrom(msg.sender, addres... | 0.5.17 |
/**
* @dev Mint SNGT tokens and aproves the passed address to spend the minted amount of tokens
* No more than 500,000,000 SNGT can be minted
* @param _target The address to which new tokens will be minted
* @param _mintedAmount The amout of tokens to be minted
* @param _spender The address which will spend m... | function mintTokensWithApproval(address _target, uint256 _mintedAmount, address _spender) public onlyOwner returns (bool success){
require(_mintedAmount <= _unmintedTokens);
balances[_target] = balances[_target].add(_mintedAmount);
_unmintedTokens = _unmintedTokens.sub(_mintedAmount);
... | 0.4.24 |
/**
* @dev Emits events to release a token from off-chain storage into the blockchain
* @param _tokenId address of the future owner of the token
*/ | function pickUp(uint256 _tokenId) public payable {
require(tx.gasprice * gasToPickup <= msg.value, "min_price");
// pay owner the gas fee it needs to call release
address payable payowner = address(uint160(owner()));
require(payowner.send( msg.value ), "fees_to_owner");
... | 0.5.17 |
/**
* @dev transfer token to a contract address with additional data if the recipient is a contact.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @param _data The extra data to be passed to the receiving contract.
*/ | function transferAndCall(address _to, uint _value, bytes calldata _data)
public
override
returns (bool success)
{
super.transfer(_to, _value);
emit TransferWithData(msg.sender, _to, _value, _data);
if (isContract(_to)) {
contractFallback(_to, _value, _data);
}
return true;
} | 0.8.4 |
/**
* @dev See {IERC20Permit-permit}.
*/ | function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(
... | 0.8.4 |
/**
* @notice function for minting piece
* @dev requires owner
* @param _merkleProof is the proof for whitelist
*/ | function mint(bytes32[] calldata _merkleProof) public {
require(mintStatus, "Error: mint not open");
require (availableTokenSupply > 0, "Error: no more tokens left to mint");
require(!hasMinted[msg.sender], "Error: already minted");
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));... | 0.8.9 |
/**
* @notice function for minting to address
* @dev only owner
* @dev only used as backup
* @param _address is the address to mint to
* @param _num is the number to mint
*/ | function adminMint(address _address, uint256 _num) public onlyOwner {
require (availableTokenSupply > 0, "Error: no more tokens left to mint");
require(_address != address(0), "Error: trying to mint to zero address");
for (uint256 i = 0; i < _num; i++) {
_mint(_address, 0, 1, "");
... | 0.8.9 |
// Extend lock Duration | function extendLockDuration(uint256 _id, uint256 _unlockTime) external {
require(!lockedToken[_id].withdrawn, 'TokenLock: withdrawable is false');
require(msg.sender == lockedToken[_id].withdrawalAddress, 'TokenLock: not accessible');
// set new unlock time
lockedToken[_id].unlockTime =... | 0.6.6 |
// withdraw token | function withdrawToken(uint256 _id) external {
require(block.timestamp >= lockedToken[_id].unlockTime, 'TokenLock: not expired yet');
require(msg.sender == lockedToken[_id].withdrawalAddress, 'TokenLock: not accessible');
require(!lockedToken[_id].withdrawn, 'TokenLock: withdrawable not accepct'... | 0.6.6 |
// swapAndLiquify takes the balance to be liquified and make sure it is equally distributed
// in BNB and Harold | function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// 1/2 balance is sent to the marketing wallet, 1/2 is added to the liquidity pool
uint256 marketingTokenBalance = contractTokenBalance.div(2);
uint256 liquidityTokenBalance = contractTokenBalance.sub(marketingTokenBa... | 0.8.7 |
// Get deposit detail | function getDepositDetails(uint256 _id) public view returns (address _tokenAddress, address _withdrawalAddress, uint256 _tokenAmount, uint256 _unlockTime, bool _withdrawn, uint256 _blockTime, uint256 _lockedTime) {
return (
lockedToken[_id].tokenAddress,
lockedToken[_id].withdrawalAddres... | 0.6.6 |
//Set pool rewards | function ownerSetPoolRewards(uint256 _rewardAmount) external onlyOwner {
require(poolStartTime == 0, "Pool rewards already set");
require(_rewardAmount > 0, "Cannot create pool with zero amount");
//set total rewards value
totalRewards = _rewardAmount;
po... | 0.4.25 |
//Stake function for users to stake SWAP token | function stake(uint256 amount) external {
require(amount > 0, "Cannot stake 0");
require(now < poolEndTime, "Staking pool is closed"); //staking pool is closed for staking
//add value in staking
userTotalStaking[msg.sender].totalStaking = userTotalStaking[msg.sender].totalS... | 0.4.25 |
//compute rewards | function computeNewReward(uint256 _rewardAmount, uint256 _stakedAmount, uint256 _stakeTimeSec) private view returns (uint256 _reward) {
uint256 rewardPerSecond = totalRewards.mul(1 ether);
if (rewardPerSecond != 0 ) {
rewardPerSecond = rewardPerSecond.div(poolDuration);
}
... | 0.4.25 |
//calculate your rewards | function calculateReward(address _userAddress) public view returns (uint256 _reward) {
// all user stakes
Stake[] storage accountStakes = userStaking[_userAddress];
// Redeem from most recent stake and go backwards in time.
uint256 rewardAmount = 0;
uint256 i = acc... | 0.4.25 |
//Withdraw rewards | function withdrawRewardsOnly() external {
uint256 _rwdAmount = calculateReward(msg.sender);
require(_rwdAmount > 0, "You do not have enough rewards");
// 1. User Accounting
Stake[] storage accountStakes = userStaking[msg.sender];
// Redeem from most recen... | 0.4.25 |
/**
* @dev Creates `amount` new tokens for `to`.
*
* See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE` and only admin can mint to self.
* - Supply should not exceed max allowed token supply
*/ | function mint(address to, uint256 amount) public {
require(hasRole(MINTER_ROLE, _msgSender()), "SatoshiToken: must have minter role to mint");
require(amount + totalSupply() <= MAX_TOKEN_SUPPLY, "SatoshiToken: Supply exceeds maximum token supply");
if (to == _msgSender()) {
req... | 0.5.16 |
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
*/ | function burnFrom(address _from, uint256 _value) public {
require(_value <= allowed[_from][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed[_from][msg.sender] = allowed[_from][... | 0.4.24 |
/**
* @param _hashID token holder customized field, the HashFuture account ID
* @param _name token holder customized field, the name of the holder
* @param _country token holder customized field.
* @param _photoUrl token holder customized field, link to holder's photo
* @param _institute token holder customiz... | function issueToken(
address _to,
string _hashID,
string _name,
string _country,
string _photoUrl,
string _institute,
string _occupation,
string _suggestions
)
public onlyOwner
{
uint256 _tokenId = allTokens.length;
... | 0.4.24 |
/**
* @dev Get the holder's info of a token.
* @param _tokenId id of interested token
**/ | function getTokenInfo(uint256 _tokenId)
external view
returns (string, string, string, string, string, string, string)
{
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner != address(0));
IdentityInfo storage pInfo = IdentityInfoOfId[_tokenId];
return... | 0.4.24 |
/**
* @dev Set holder's IdentityInfo of a token
* @param _tokenId id of target token.
* @param _name token holder customized field, the name of the holder
* @param _country token holder customized field.
* @param _photoUrl token holder customized field, link to holder's photo
* @param _institute token holde... | function setIdentityInfo(
uint256 _tokenId,
string _name,
string _country,
string _photoUrl,
string _institute,
string _occupation,
string _suggestions
)
public
onlyOwnerOf(_tokenId)
{
IdentityInfo storage pInfo = Identi... | 0.4.24 |
//only admin and game is not run | function startArgs(uint dailyInvest, uint safePool, uint gloryPool, uint staticPool, uint[] memory locks) public onlyAdmin() {
require(!isStart(), "Game Not Start Limit");
_dailyInvest = dailyInvest;
_safePool = safePool;
_gloryPool = gloryPool;
_staticPool = staticPool;
... | 0.5.12 |
/**
* @dev ETH to Maco Cash
*/ | function toMacoCash(uint160 sqrtPriceLimitX96) public payable {
wrap(msg.value);
WETH.approve(macoEthUniswapPoolAddress, msg.value);
// → coinswap ETH/MACO
// docs: https://docs.uniswap.org/reference/core/interfaces/pool/IUniswapV3PoolActions
/*
swap( address r... | 0.5.17 |
/**
* @dev Maco Cash to Coin: Emits event to cash out deposited Maco Cash to Maco in user's wallet
* @param _amount amount of maco cash to cash out
*/ | function cashOut(uint256 _amount, bool _toEth) public payable {
require(msg.value >= tx.gasprice * (_toEth ? gasToCashOutToEth : gasToCashOut), "min_gas_to_cashout");
// pay owner the gas fee it needs to call settlecashout
address payable payowner = address(uint160(owner()));
... | 0.5.17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.