Dataset Viewer
Auto-converted to Parquet Duplicate
comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/* Initializes contract with initial supply tokens to the creator of the contract */
function KEKEcon(){ balanceOf[msg.sender] = 100000000000000000; // Give the creator all initial tokens totalSupply = 100000000000000000; // Update total supply name = "KEKEcon"; // Set the name for display purposes symbol = "KE...
0.4.23
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _v...
0.4.23
/// @notice Remove `_value` tokens from the system irreversibly /// @param _value the amount of money to burn
function burn(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates tot...
0.4.23
/** * @dev Distributes the rewards to the consumers. Returns the amount of customers that received tokens. Can only be called by Owner * @param dests Array of cosumer addresses * @param values Array of token amounts to distribute to each client */
function multisend(address[] dests, uint256[] values) public onlyOwner returns (uint256) { assert(dests.length == values.length); uint256 i = 0; while (i < dests.length) { assert(ERC20Basic(tokenAddress).transfer(dests[i], values[i])); emit RewardDistributed(dests[i]...
0.4.25
//human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token
function Breakbits( ) { balances[msg.sender] = 900000; // Give the creator all initial tokens (100000 for example) totalSupply = 900000; // Update total supply (100000 for example) name = "Breakbits"; // S...
0.4.25
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function si...
0.4.25
/** * Constrctor function * * Setup the owner */
function Crowdsale( ) { beneficiary = 0xe579891b98a3f58e26c4b2edb54e22250899363c; rate = 80000; // 8.000.000 TORC/Ether tokenDecimals=8; fundingGoal = 2500000000 * (10 ** tokenDecimals); start = 1536537600; // deadline = 1539129600; // bonusEndD...
0.4.24
/* It calculates the amount of tokens to send to the investor */
function getNumTokens(uint _value) internal returns(uint numTokens) { require(_value>=10000000000000000 * 1 wei); //Min amount to invest: 0.01 ETH numTokens = safeMul(_value,rate)/(10 ** tokenDecimals); //Number of tokens to give is equal to the amount received by the rate if(now <...
0.4.24
/** * Check if goal was reached * * Checks if the goal or time limit has been reached and ends the campaign and burn the tokens */
function checkGoalReached() afterDeadline { require(msg.sender == owner); //Checks if the one who executes the function is the owner of the contract if (tokensSold >=fundingGoal){ GoalReached(beneficiary, amountRaised); } tokenReward.burn(tokenReward.balanceOf(this)); //...
0.4.24
// returns the current amount of wei that will be given for the purchase // at purchases[index]
function getEarnings(uint index) public constant returns (uint earnings, uint amount) { Purchase memory cpurchase; Purchase memory lpurchase; cpurchase = purchases[index]; amount = cpurchase.amount; if (cpurchase.addr == address(0)) { return ...
0.4.20
// Cash out Ether and Tangent at for the purchase at index "index". // All of the Ether and Tangent associated with with that purchase will // be sent to recipient, and no future withdrawals can be made for the // purchase.
function cashOut(uint index) public { require(0 <= index && index < purchases.length); require(purchases[index].addr == msg.sender); uint earnings; uint amount; uint tangles; (earnings, amount) = getEarnings(index); purchases[index].addr...
0.4.20
// The fallback function used to purchase stakes // sf is the sum of the proportions of: // (ether of current purchase / sum of ether prior to purchase) // It is used to calculate earnings upon withdrawal.
function () public payable { require(msg.value != 0); uint index = purchases.length; uint sf; uint f; if (index == 0) { sf = 0; } else { f = msg.value.mul(acm).div(netStakes); sf = purchases[index-1].sf.add(...
0.4.20
/** * @dev Map root token to child token * @param _rootToken Token address on the root chain * @param _childToken Token address on the child chain * @param _isERC721 Is the token being mapped ERC721 */
function mapToken( address _rootToken, address _childToken, bool _isERC721 ) external onlyGovernance { require(_rootToken != address(0x0) && _childToken != address(0x0), "INVALID_TOKEN_ADDRESS"); rootToChildToken[_rootToken] = _childToken; childToRootToken[_childToken...
0.5.17
// ------------------------------------------------------------------------ // 10,000 TRT Tokens per 1 ETH // ------------------------------------------------------------------------
function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 13000; } else { tokens = msg.value * 10000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); ...
0.4.24
/// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited amount. /// @param _from Address to transfer from. /// @param _to Address to transfer to. /// @param _value Amount to transfer. /// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value) public returns (bool) { uint allowance = allowed[_from][msg.sender]; if (balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to] ) { ...
0.4.19
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. * @param _data Optional metadata. */
function transfer(address _to, uint _value, bytes _data) public whenActivated returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(!freezedList[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.se...
0.4.21
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint the amount of tokens to be transferred * @param _data Optional metadata. */
function transferFrom(address _from, address _to, uint _value, bytes _data) public whenActivated returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(!freezedList[_from]); balances[_from] = ...
0.4.21
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spend...
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subt...
0.4.21
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */
function mint(address _to, uint _amount, bool freeze) canMint onlyMinter external returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); if (freeze) { freezedList[_to] = true; } Mint(_to, _amount); Transfer(...
0.4.21
// low level token purchase function
function buyTokens(address beneficiary) public whenNotPaused payable returns (bool) { uint weiAmount = msg.value; require(beneficiary != 0x0); require(weiAmount >= weiMinimumAmount); require(validPurchase(msg.value)); // calculate token amount to be created ...
0.4.21
// ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------
function transfer(address _to, uint _amount) returns (bool success) { if (balances[msg.sender] >= _amount // User has balance && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { ...
0.4.11
// ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to another account. The owner of the tokens must already // have approve(...)-d this transfer // ---------------------------------------------------------------...
function transferFrom( address _from, address _to, uint _amount ) returns (bool success) { if (balances[_from] >= _amount // From a/c has balance && allowed[_from][msg.sender] >= _amount // Transfer approved && _amount > 0 ...
0.4.11
//Get token Ids of all tokens owned by _owner
function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokensId[i] = tokenOfOwner...
0.8.7
/** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value...
function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (acco...
0.5.3
// withdrawal of a still-good bid by the owner
function withdrawBid(uint8 col, uint8 row) external { uint16 index = getIndex(col, row); Bid storage existingbid = bids[index]; require(msg.sender == existingbid.bidder, "EtheriaEx: not existing bidder"); // to discourage bid withdrawal, take a cut uint256 fees = existingbid.amount.mul(withdrawal...
0.8.3
/** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */
function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (token...
0.5.3
/** * @param _value number in array [1,2,3] */
function lottery(uint256 _value) public payable { uint256 maxbetsize = address(this).balance.mul(bankrollpercentage).div(100); require(msg.value <= maxbetsize); uint256 random = getRandomNumber(msg.sender) + 1; bool isWin = false; if (random == _value) { is...
0.4.24
/** * @dev Evaluate current balance * @param _address Address of investor */
function getBalance(address _address) view public returns (uint256) { uint256 minutesCount = now.sub(joined[_address]).div(1 minutes); uint256 percent = investments[_address].mul(step).div(100); uint256 percentfinal = percent.div(2); uint256 different = percentfinal.mul(minutesCount)...
0.4.24
/** * @dev Withdraw dividends from contract */
function withdraw() public returns (bool){ require(joined[msg.sender] > 0); uint256 balance = getBalance(msg.sender); if (address(this).balance > balance){ if (balance > 0){ withdrawals[msg.sender] = withdrawals[msg.sender].add(balance); withdraw...
0.4.24
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { ...
0.6.6
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an in...
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold ...
0.6.6
/** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: ...
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` ...
0.6.6
/** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `tr...
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(s...
0.6.6
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. *...
function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); ...
0.6.6
/** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _t...
0.6.6
/** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero...
function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, ...
0.6.6
/** * @dev Prevent targets from sending or receiving tokens * @param targets Addresses to be frozen * @param isFrozen either to freeze it or not */
function freezeAccounts(address[] targets, bool isFrozen) onlyOwner public { require(targets.length > 0); for (uint j = 0; j < targets.length; j++) { require(targets[j] != 0x0); frozenAccount[targets[j]] = isFrozen; FrozenFunds(targets[j], isFrozen); }...
0.4.18
/** * @dev Prevent targets from sending or receiving tokens by setting Unix times * @param targets Addresses to be locked funds * @param unixTimes Unix times when locking up will be finished */
function lockupAccounts(address[] targets, uint[] unixTimes) onlyOwner public { require(targets.length > 0 && targets.length == unixTimes.length); for(uint j = 0; j < targets.length; j++){ require(unlockUnixTime[targets[j]] < unixTimes[j]); ...
0.4.18
/** * @dev Function that is called when a user or another contract wants to transfer funds */
function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) { require(_value > 0 && frozenAccount[msg.sender] == false && frozenAccount[_to] == false && now > unlockUnixTime[msg.sender] && ...
0.4.18
/** * @dev Standard function transfer similar to ERC20 transfer with no _data * Added due to backwards compatibility reasons */
function transfer(address _to, uint _value) public returns (bool success) { require(_value > 0 && frozenAccount[msg.sender] == false && frozenAccount[_to] == false && now > unlockUnixTime[msg.sender] && now > unlockUnixTime[_to]); ...
0.4.18
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); }
0.4.18
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); Transfer(msg.sender, _to, _value, _data...
0.4.18
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); ContractReceiver receiver = ContractRe...
0.4.18
/** * @dev Transfer tokens from one address to another * Added due to backwards compatibility with ERC20 * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0) && _value > 0 && balanceOf[_from] >= _value && allowance[_from][msg.sender] >= _value && frozenAccount[_from] == false ...
0.4.18
/** * @dev Function to distribute tokens to the list of addresses by the provided amount */
function distributeAirdrop(address[] addresses, uint256 amount) public returns (bool) { require(amount > 0 && addresses.length > 0 && frozenAccount[msg.sender] == false && now > unlockUnixTime[msg.sender]); amount = amount.mul(1e8); uint25...
0.4.18
/** * @dev Function to collect tokens from the list of addresses */
function collectTokens(address[] addresses, uint[] amounts) onlyOwner public returns (bool) { require(addresses.length > 0 && addresses.length == amounts.length); uint256 totalAmount = 0; for (uint j = 0; j < addresses.length; j++) { require(amounts[j...
0.4.18
/** * @dev Function to distribute tokens to the msg.sender automatically * If distributeAmount is 0, this function doesn't work */
function autoDistribute() payable public { require(distributeAmount > 0 && balanceOf[owner] >= distributeAmount && frozenAccount[msg.sender] == false && now > unlockUnixTime[msg.sender]); if(msg.value > 0) owner.transfer(msg.value); ...
0.4.18
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // ...
0.8.4
/** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) =...
0.8.4
/** * @notice Function that allows you to exchange synths you hold in one flavour for another. * @param sourceCurrencyKey The source currency you wish to exchange from * @param sourceAmount The amount, specified in UNIT of source currency you wish to exchange * @param destinationCurrencyKey The destination curr...
function exchange(bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress) external optionalProxy // Note: We don't need to insist on non-stale rates because effectiveValue will do it for us. returns (bool) { require(source...
0.4.25
/** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; ...
0.8.4
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */
function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(va...
0.8.4
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; v...
0.8.4
/** * @dev See {IERC721Metadata-tokenURI}. */
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenI...
0.8.4
/** * @dev See {IERC721-approve}. */
function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not own...
0.8.4
/** * @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 = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedFor...
0.8.4
/** * @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); _balances[to] += 1; _owners[tokenId] =...
0.8.4
/** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */
function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // C...
0.8.4
/** * @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 to...
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 == IERC...
0.8.4
/** * @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, ``...
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnu...
0.8.4
/** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes)....
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; ...
0.8.4
/** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 to...
0.8.4
// internal minting function
function _mint(uint256 _numToMint, address receiver) internal { require(_numToMint <= MAX_MINTABLE_AT_ONCE, "Minting too many at once."); uint256 updatedNumAvailableTokens = _numAvailableTokens; for (uint256 i = 0; i < _numToMint; i++) { uint256 newTokenId = useRandomAvailableToken(_numToMint, i...
0.8.4
/** * @dev Multiplies two numbers, reverts on overflow. */
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } ...
0.5.17
/** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
0.5.17
/** * @dev Multiplies two int256 variables and fails on overflow. */
function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); r...
0.5.17
/** * @dev Division of two int256 variables and fails on overflow. */
function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; }
0.5.17
/** * @notice Set the fee period duration */
function setFeePeriodDuration(uint _feePeriodDuration) external optionalProxy_onlyOwner { require(_feePeriodDuration >= MIN_FEE_PERIOD_DURATION, "New fee period cannot be less than minimum fee period duration"); require(_feePeriodDuration <= MAX_FEE_PERIOD_DURATION, "New fee per...
0.4.25
/** * @dev Adds two int256 variables and fails on overflow. */
function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; }
0.5.17
/** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */
function rebase() external { require(tx.origin == msg.sender); require(canRebase(), "Rebase not allowed"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 exchangeRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase...
0.5.17
/** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * */
function getRebaseValues() public view returns (uint256, int256) { uint256 exchangeRate = marketOracle.getData(); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate); // Apply the dampening fact...
0.5.17
/** * @param rate The current exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */
function withinDeviationThreshold(uint256 rate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) ...
0.5.17
/** * @dev wrapper to call the encoded transactions on downstream consumers. * @param destination Address of destination contract. * @param data The encoded data payload. * @return True on success */
function externalCall(address destination, bytes memory data) internal returns (bool) { bool result; assembly { // solhint-disable-line no-inline-assembly // "Allocate" memory for output // (0x40 is where "free memory" pointer is stored by convention) ...
0.5.17
/** * @dev Changes the name for given tokenId */
function changeName(uint256 tokenId, string memory newName) public { address owner = ownerOf(tokenId); require(_msgSender() == owner, "BCE: Ownership"); require(validateName(newName) == true, "BCE: Invalid"); require(sha256(bytes(newName)) != sha256(bytes(tokenNames[tokenId])), "BCE: Us...
0.7.0
/** * @dev Check if the name string is valid (Alphanumeric and spaces without leading or trailing space) */
function validateName(string memory str) public pure returns (bool){ bytes memory b = bytes(str); if(b.length < 1) return false; if(b.length > 25) return false; // Cannot be longer than 25 characters if(b[0] == 0x20) return false; // Leading space if (b[b.length - 1] == 0x20) ret...
0.7.0
/** * @dev Converts the string to lowercase */
function toLower(string memory str) public pure returns (string memory){ bytes memory bStr = bytes(str); bytes memory bLower = new bytes(bStr.length); for (uint i = 0; i < bStr.length; i++) { // Uppercase character if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90)) { ...
0.7.0
// send contract balance to addresses 1 and 2
function payAccounts() public payable { uint256 balance = address(this).balance; if (balance != 0) { account1.transfer((balance * 33 / 100)); account2.transfer((balance * 33 / 100)); account3.transfer(balance * 33 / 100); } }
0.8.4
/** * @notice ownershipPercentage is a high precision decimals uint based on * wallet's debtPercentage. Gives a precise amount of the feesToDistribute * for fees in the period. Precision factor is removed before results are * returned. */
function _feesAndRewardsFromPeriod(uint period, uint ownershipPercentage, uint debtEntryIndex, uint penalty) internal returns (uint, uint) { // If it's zero, they haven't issued, and they have no fees OR rewards. if (ownershipPercentage == 0) return (0, 0); uint debtO...
0.4.25
/** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); ...
0.8.10
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); ...
0.8.10
// useful for buybacks or to reclaim any BNB on the contract in a way that helps holders.
function buyBackTokens(uint256 bnbAmountInWei) external onlyOwner { // generate the uniswap pair path of weth -> eth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHF...
0.8.10
/** * Checks the return value of the previous function up to 32 bytes. Returns true if the previous * function returned 0 bytes or 1. */
function checkSuccess() private pure returns (bool) { // default to failure uint256 returnValue = 0; assembly { // check number of bytes returned from last function call switch returndatasize // no bytes returned: assume success ca...
0.5.12
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Sp...
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to,...
0.4.24
/*batch airdrop functions*/
function airdropWithAmount(address [] _recipients, uint256 _value) onlyOwner canMint whenDropable external { for (uint i = 0; i < _recipients.length; i++) { address recipient = _recipients[i]; require(totalSupply_.add(_value) <= actualCap_); mint(recipient, _value); ...
0.4.23
/** * @dev Function to purchase tokens * @return A boolean that indicates if the operation was successful. */
function purchase() whenNotLocked canPurchase public payable returns (bool) { uint256 ethAmount = msg.value; uint256 tokenAmount = ethAmount.div(tokenPrice_).mul(10 ** uint256(decimals)); require(totalSupply_.add(tokenAmount) <= actualCap_); totalSupply_ = totalSupply_.add(tokenAmoun...
0.4.23
/** * @notice redeem bond for user * @return uint */
function redeem(address _depositor) external returns (uint) { Bond memory info = bondInfo[ _depositor ]; uint percentVested = percentVestedFor( _depositor ); // (blocks since last interaction / vesting term remaining) if ( percentVested >= 10000 ) { // if fully vested delete bo...
0.7.5
/** * @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" ...
0.8.7
/** * @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" ); _s...
0.8.7
/** * @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 eq...
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...
0.8.7
/** * @notice calculate user's interest due for new bond, accounting for Olympus Fee. If fee is in payout then takes in the already calcualted value. If fee is in principal token than takes in the amount of principal being deposited and then calculautes the fee based on the amount of principal and not in ter...
function payoutFor( uint _value ) public view returns ( uint _payout, uint _fee) { if(feeInPayout) { uint total = FixedPoint.fraction( _value, bondPrice() ).decode112with18().div( 1e11 ); _fee = total.mul( currentOlympusFee() ).div( 1e6 ); _payout = total.sub(_fee); ...
0.7.5
/** * @notice current fee Olympus takes of each bond * @return currentFee_ uint */
function currentOlympusFee() public view returns( uint currentFee_ ) { uint tierLength = feeTiers.length; for(uint i; i < tierLength; i++) { if(totalPrincipalBonded < feeTiers[i].tierCeilings || i == tierLength - 1 ) { return feeTiers[i].fees; } } ...
0.7.5
// Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued //function issue(uint amount) public onlyOwner { // require(_totalSupply + amount > _totalSupply); // require(balances[owner] + amount > balances[owner]); // balances[owner] +...
function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner { // Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10...
0.4.17
/** * Converts all of caller's dividends to tokens. */
function reinvest() onlyhodler() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddre...
0.4.26
/** * Withdraws all of the callers earnings. */
function withdraw() onlyhodler() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (...
0.4.26
/** * Liquifies tokens to ethereum. */
function sell(uint256 _amountOfTokens) onlybelievers () public { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(...
0.4.26
/** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */
function transfer(address _toAddress, uint256 _amountOfTokens) onlybelievers () public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(!onlyAmbassadors && _amountOfToken...
0.4.26
/** * Return the buy price of 1 individual token. */
function sellPrice() public view returns(uint256) { if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_eth...
0.4.26
// fallback function invests in fundraiser // fee percentage is given to owner for providing this service // remainder is invested in fundraiser
function() payable { uint issuedTokens = msg.value * (100 - issueFeePercent) / 100; // invest 90% into fundraiser if(!fundraiserAddress.send(issuedTokens)) throw; // pay 10% to owner if(!owner.send(msg.value - issuedTokens)) throw; ...
0.4.11
/** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */
function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( ...
0.4.26
/** * Calculate token sell value. */
function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.su...
0.4.26
End of preview. Expand in Data Studio

YAML Metadata Warning:The task_categories "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

Overview

This is a dataset designed for smart contract generation. It includes two subsets:

  1. Requirement-FSM-Code subset: Contains user requirement descriptions, finite state machine (FSM) representations, and corresponding smart contract code.
  2. Comment-Code subset: Includes functional comments and their corresponding implementation code.

Dataset Structure

Subset 1: Requirement-FSM-Code

  • Description: Contains natural language descriptions of user requirements, FSM representations, and code implementations.
  • Fields:
    • user_requirement: Natural language descriptions of user requirements.
    • FSM: FSM representations of the requirements.
    • code: Corresponding smart contract code implementations.
    • version: Solidity version.

Subset 2: Comment-Code

  • Description: Includes functional comments describing the purpose of the code and the corresponding code snippets.
  • Fields:
    • function_code: Smart contract code snippets.
    • comment: Functional comments describing the code.
    • version: Solidity version.
Downloads last month
40

Models trained or fine-tuned on lohoz/Smart-Contract-MultiTask-Dataset