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
|
|---|---|---|---|---|
27
|
// Transfer token to a specified address. to The address to transfer to. value The amount to be transferred. /
|
function transfer(address to, uint256 value) public override returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
|
function transfer(address to, uint256 value) public override returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
| 34,574
|
2
|
// Returns the role-member from a list of members for a role, at a given index. Returns `member` who has `role`, at `index` of role-members list. See struct {RoleMembers}, and mapping {roleMembers} role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")indexIndex in list of current members for the role.return memberAddress of account that has `role` /
|
function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) {
uint256 currentIndex = roleMembers[role].index;
uint256 check;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (roleMembers[role].members[i] != address(0)) {
if (check == index) {
member = roleMembers[role].members[i];
|
function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) {
uint256 currentIndex = roleMembers[role].index;
uint256 check;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (roleMembers[role].members[i] != address(0)) {
if (check == index) {
member = roleMembers[role].members[i];
| 16,635
|
6
|
// Returns the asset price in ETH. symbol. Asset symbol. For ex. "DAI".return Price in ETH with 8 decimal digits. /
|
function tokEthPrice(string calldata symbol) external returns (uint256);
|
function tokEthPrice(string calldata symbol) external returns (uint256);
| 52,244
|
230
|
// Remove the fee set for an app_appId App identifier/
|
function unsetAppFee(bytes32 _appId) external;
|
function unsetAppFee(bytes32 _appId) external;
| 38,787
|
2
|
// todo: validate
|
_requestId = oracleRequests.length;
oracleRequests.push();
|
_requestId = oracleRequests.length;
oracleRequests.push();
| 22,946
|
11
|
// The AO set the NameTAOPosition Address _nameTAOPositionAddress The address of NameTAOPosition /
|
function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO {
require (_nameTAOPositionAddress != address(0));
nameTAOPositionAddress = _nameTAOPositionAddress;
}
|
function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO {
require (_nameTAOPositionAddress != address(0));
nameTAOPositionAddress = _nameTAOPositionAddress;
}
| 16,125
|
127
|
// Create lock using permit
|
function createLockWithPermit(
uint256 _value,
uint256 _unlockTime,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external returns (uint256 lockId);
|
function createLockWithPermit(
uint256 _value,
uint256 _unlockTime,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external returns (uint256 lockId);
| 59,906
|
23
|
// There is only 100m Orion tokens, fits i64
|
require(_orionAmount == int64(_orionAmount), "E11");
int192 onBalanceOrion = assetBalances[user][orionTokenAddress];
require(onBalanceOrion >= _orionAmount, "E10");
assetBalances[user][orionTokenAddress] -= _orionAmount;
assetBalances[liquidator][orionTokenAddress] += _orionAmount;
|
require(_orionAmount == int64(_orionAmount), "E11");
int192 onBalanceOrion = assetBalances[user][orionTokenAddress];
require(onBalanceOrion >= _orionAmount, "E10");
assetBalances[user][orionTokenAddress] -= _orionAmount;
assetBalances[liquidator][orionTokenAddress] += _orionAmount;
| 19,466
|
75
|
// Expose vault function that decrement user's balance in the vaultOnly available to system modules. _tokensThe addresses of the ERC20 tokens_owner The address of the token owner_quantitiesThe numbers of tokens to attribute to owner /
|
function batchDecrementTokenOwnerModule(
|
function batchDecrementTokenOwnerModule(
| 18,115
|
53
|
// PRDZ token contract address
|
address public constant tokenAddress = 0x4e085036A1b732cBe4FfB1C12ddfDd87E7C3664d;
address public constant burnAddress = 0x0000000000000000000000000000000000000000;
|
address public constant tokenAddress = 0x4e085036A1b732cBe4FfB1C12ddfDd87E7C3664d;
address public constant burnAddress = 0x0000000000000000000000000000000000000000;
| 3,049
|
11
|
// ==========Events==========
|
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, IERC20 indexed lpToken);
event LogUpdatePool(uint256 indexed pid, uint256 lastRewardBlock, uint256 lpSupply, uint256 accRewardsPerShare);
event RewardsAdded(uint256 amount);
event ExtendPool(uint256 indexed pid, uint256 rewardBlock, uint256 endOfEpochBlock);
|
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, IERC20 indexed lpToken);
event LogUpdatePool(uint256 indexed pid, uint256 lastRewardBlock, uint256 lpSupply, uint256 accRewardsPerShare);
event RewardsAdded(uint256 amount);
event ExtendPool(uint256 indexed pid, uint256 rewardBlock, uint256 endOfEpochBlock);
| 71,170
|
112
|
// Updates the pending claim start variable,the lowest claim id with a pending decision/payout. /
|
function setpendingClaimStart(uint _start) external onlyInternal {
require(pendingClaimStart <= _start);
pendingClaimStart = _start;
}
|
function setpendingClaimStart(uint _start) external onlyInternal {
require(pendingClaimStart <= _start);
pendingClaimStart = _start;
}
| 82,010
|
60
|
// Check if there&39;s an active campaign
|
function active() public view returns(bool) {
if(campaigns.length == 0) {
return false;
} else {
return campaigns[lastCampaignID].deadline >= now;
}
}
|
function active() public view returns(bool) {
if(campaigns.length == 0) {
return false;
} else {
return campaigns[lastCampaignID].deadline >= now;
}
}
| 39,016
|
7
|
// Function called by the sender, receiver or a delegate, with all the neededsignatures to close the channel immediately. receiver The address that receives tokens. blockNumber The block number at which a channel was created. balance The amount of tokens owed by the sender to the receiver. senderBalanceSign The sender's balance proof message signature. receiverBalanceSign The receiver's balance proof message signature. /
|
function closeChannel(address receiver, uint32 blockNumber, uint192 balance, bytes calldata senderBalanceSign, bytes calldata receiverBalanceSign) external {
address senderAddr = extractBalanceProofSignature(
receiver,
blockNumber,
balance,
senderBalanceSign
);
address receiverAddr = extractBalanceProofSignature(
senderAddr,
blockNumber,
balance,
receiverBalanceSign
);
require(receiver == receiverAddr);
// Both signatures have been verified and the channel can be closed.
_closeChannel(senderAddr, receiverAddr, blockNumber, balance);
emit ChannelClosed(senderAddr, receiver, blockNumber, balance);
}
|
function closeChannel(address receiver, uint32 blockNumber, uint192 balance, bytes calldata senderBalanceSign, bytes calldata receiverBalanceSign) external {
address senderAddr = extractBalanceProofSignature(
receiver,
blockNumber,
balance,
senderBalanceSign
);
address receiverAddr = extractBalanceProofSignature(
senderAddr,
blockNumber,
balance,
receiverBalanceSign
);
require(receiver == receiverAddr);
// Both signatures have been verified and the channel can be closed.
_closeChannel(senderAddr, receiverAddr, blockNumber, balance);
emit ChannelClosed(senderAddr, receiver, blockNumber, balance);
}
| 21,505
|
206
|
// A onchain reference to accounts which have been lost/hacked etc
|
mapping(address => bool) public reportedArtistAccounts;
|
mapping(address => bool) public reportedArtistAccounts;
| 23,024
|
415
|
// lockdays are passed as seconds
|
function deleteLockMultiplier(uint256 lockDays) external onlyOwner {
delete lockMultipliers[lockDays];
}
|
function deleteLockMultiplier(uint256 lockDays) external onlyOwner {
delete lockMultipliers[lockDays];
}
| 52,936
|
7
|
// cash
|
Operator(cash).transferOperator(target);
Operator(cash).transferOwnership(target);
ICustomERC20(cash).transfer(
target,
ICustomERC20(cash).balanceOf(address(this))
);
|
Operator(cash).transferOperator(target);
Operator(cash).transferOwnership(target);
ICustomERC20(cash).transfer(
target,
ICustomERC20(cash).balanceOf(address(this))
);
| 24,945
|
36
|
// mask out the bit relevant for Dice game
|
mask = gameOptions & GAME_OPTIONS_DICE_MASK_BITS;
|
mask = gameOptions & GAME_OPTIONS_DICE_MASK_BITS;
| 37,363
|
112
|
// Triggers stopped state Only possible when contract not paused. /
|
function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
|
function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
| 28,845
|
176
|
// As a winner, check price (wei) to pay for the artworknftId - nftId of the artwork /
|
function getArtworkPrice(uint nftId) public view returns (uint) {
require(
_winners[nftId] == msg.sender,
"Caller does not have Winner Access"
);
uint eth_eur = getThePrice_eth_eur();
uint wei2pay = 1e18 wei * _winnerCostsEuroCents[nftId] / ( eth_eur * 100 );
return wei2pay;
}
|
function getArtworkPrice(uint nftId) public view returns (uint) {
require(
_winners[nftId] == msg.sender,
"Caller does not have Winner Access"
);
uint eth_eur = getThePrice_eth_eur();
uint wei2pay = 1e18 wei * _winnerCostsEuroCents[nftId] / ( eth_eur * 100 );
return wei2pay;
}
| 50,034
|
27
|
// check uint in claimable mapping for msg.sender and transfer erc20 to msg.sender
|
require(
presaleContract.claimable(msg.sender) > 0,
"No tokens to be claimed"
);
require(isClaimed[msg.sender] == false, "Tokens already claimed");
uint256 amount = presaleContract.claimable(msg.sender);
isClaimed[msg.sender] = true;
token.transfer(msg.sender, amount);
emit ClaimTokenEvent(msg.sender, 0);
|
require(
presaleContract.claimable(msg.sender) > 0,
"No tokens to be claimed"
);
require(isClaimed[msg.sender] == false, "Tokens already claimed");
uint256 amount = presaleContract.claimable(msg.sender);
isClaimed[msg.sender] = true;
token.transfer(msg.sender, amount);
emit ClaimTokenEvent(msg.sender, 0);
| 14,271
|
29
|
// Get current bonus rate. Override the base function from StandardTokenCrowdsale _weiAmount Value in wei to be converted into bonus tokensreturn Number of bonus tokens that will be awarded for a purchase of _weiAmount /
|
function _getBonusTokenAmount(uint256 _weiAmount) internal view returns (uint256)
|
function _getBonusTokenAmount(uint256 _weiAmount) internal view returns (uint256)
| 22,307
|
165
|
// creates a Token.Instance record and initializes the ElasticGovernanceToken. _controller the address which can control the core DAO functions _name name of the token _symbol symbol of the token _eByL initial ETH/token ratio _elasticity the percentage by which capitalDelta should increase _k a constant, initially set by the DAO _maxLambdaPurchase maximum amount of lambda (shares) that can beminted on each call to the join function in ElasticDAO.sol _ecosystem the DAO's ecosystem instancereturn token Token.Instance /
|
function _buildToken(
address _controller,
string memory _name,
string memory _symbol,
uint256 _eByL,
uint256 _elasticity,
uint256 _k,
uint256 _maxLambdaPurchase,
Ecosystem.Instance memory _ecosystem
|
function _buildToken(
address _controller,
string memory _name,
string memory _symbol,
uint256 _eByL,
uint256 _elasticity,
uint256 _k,
uint256 _maxLambdaPurchase,
Ecosystem.Instance memory _ecosystem
| 15,552
|
44
|
// NOTE: move event up here, avoid stack too deep if too many approved tokens
|
emit SummonComplete(_summoner, _approvedTokens, block.timestamp, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward);
for (uint256 i = 0; i < _approvedTokens.length; i++) {
require(_approvedTokens[i] != address(0), "_approvedToken cannot be 0");
require(!tokenWhitelist[_approvedTokens[i]], "duplicate approved token");
tokenWhitelist[_approvedTokens[i]] = true;
approvedTokens.push(_approvedTokens[i]);
}
|
emit SummonComplete(_summoner, _approvedTokens, block.timestamp, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward);
for (uint256 i = 0; i < _approvedTokens.length; i++) {
require(_approvedTokens[i] != address(0), "_approvedToken cannot be 0");
require(!tokenWhitelist[_approvedTokens[i]], "duplicate approved token");
tokenWhitelist[_approvedTokens[i]] = true;
approvedTokens.push(_approvedTokens[i]);
}
| 10,114
|
108
|
// do withdraw
|
_withdraw(cut, value, spenders);
|
_withdraw(cut, value, spenders);
| 9,073
|
36
|
// signsee{Sign}./ Requirements- owner sign verification failed when signture was mismatched. /
|
function verifySign(
string memory _tokenURI,
address caller,
Sign memory sign
) internal view {
bytes32 hash = keccak256(
abi.encodePacked(this, caller, _tokenURI, sign.nonce)
);
require(
|
function verifySign(
string memory _tokenURI,
address caller,
Sign memory sign
) internal view {
bytes32 hash = keccak256(
abi.encodePacked(this, caller, _tokenURI, sign.nonce)
);
require(
| 15,225
|
0
|
// BurnableTokenInterface for Basic ERC20 interactions and allowing burningof tokens (c) Philip Louw / Zero Carbon Project 2018. The MIT Licence. /
|
contract ERC20Burnable is ERC20Basic {
function burn(uint256 _value) public;
}
|
contract ERC20Burnable is ERC20Basic {
function burn(uint256 _value) public;
}
| 20,236
|
18
|
// Public grant tokens administrative function /
|
function tokenGrantVestedTokens(
address _token,
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public
|
function tokenGrantVestedTokens(
address _token,
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public
| 18,998
|
40
|
// ------------------------------------------------------------------------ Transfer the balance from owner's account to another account, with a check that the crowdsale is finalised ------------------------------------------------------------------------
|
function transfer(address _to, uint _amount) returns (bool success) {
// Cannot transfer before crowdsale ends or cap reached
require(now > ENDDATE || totalEthers == CAP);
// Standard transfer
return super.transfer(_to, _amount);
}
|
function transfer(address _to, uint _amount) returns (bool success) {
// Cannot transfer before crowdsale ends or cap reached
require(now > ENDDATE || totalEthers == CAP);
// Standard transfer
return super.transfer(_to, _amount);
}
| 9,738
|
67
|
// Access for adding deposit.
|
mapping(address => bool) private depositAccess;
|
mapping(address => bool) private depositAccess;
| 2,057
|
1
|
// max size of voucher metadata memory range 32(2^16) bytes
|
uint256 constant VOUCHER_METADATA_LOG2_SIZE = 21;
|
uint256 constant VOUCHER_METADATA_LOG2_SIZE = 21;
| 49,736
|
202
|
// Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
|
sender := and(
mload(add(array, index)),
0xffffffffffffffffffffffffffffffffffffffff
)
|
sender := and(
mload(add(array, index)),
0xffffffffffffffffffffffffffffffffffffffff
)
| 22,752
|
23
|
// Transfer token for a specified addressto The address to transfer to.value The amount to be transferred./
|
function transfer(address to, uint256 value) public virtual override returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
|
function transfer(address to, uint256 value) public virtual override returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
| 66,054
|
76
|
// Sell the balance accumulated from taxes. /
|
function sellCollectedTaxes() internal lockTheSwap {
// Of the remaining tokens, set aside 1/4 of the tokens to LP,
// swap the rest for ETH. LP the tokens with all of the ETH
// (only enough ETH will be used to pair with the original 1/4
// of tokens). Send the remaining ETH (about half the original
// balance) to my wallet.
uint tokensForLiq = balanceOf[address(this)] / 5;
uint tokensToSwap = balanceOf[address(this)] - tokensForLiq;
// Sell
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = router.WETH();
router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokensToSwap,
0,
path,
address(this),
block.timestamp
);
uint EthforLP = address(this).balance / 4;
router.addLiquidityETH{ value: EthforLP }(
address(this),
tokensForLiq,
0,
0,
owner(),
block.timestamp);
myWallet.call{value: address(this).balance}("");
}
|
function sellCollectedTaxes() internal lockTheSwap {
// Of the remaining tokens, set aside 1/4 of the tokens to LP,
// swap the rest for ETH. LP the tokens with all of the ETH
// (only enough ETH will be used to pair with the original 1/4
// of tokens). Send the remaining ETH (about half the original
// balance) to my wallet.
uint tokensForLiq = balanceOf[address(this)] / 5;
uint tokensToSwap = balanceOf[address(this)] - tokensForLiq;
// Sell
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = router.WETH();
router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokensToSwap,
0,
path,
address(this),
block.timestamp
);
uint EthforLP = address(this).balance / 4;
router.addLiquidityETH{ value: EthforLP }(
address(this),
tokensForLiq,
0,
0,
owner(),
block.timestamp);
myWallet.call{value: address(this).balance}("");
}
| 6,193
|
103
|
// max amount to be withdrawn is the releasable amount, excess stays in lock-up, unless all lock-ups have ended solium-disable-next-line security/no-block-members
|
if(balances[msg.sender] >= unreleased && lockupEndTime[lockupEndTime.length-1] > now)
{
tobeReleased = unreleased;
}
|
if(balances[msg.sender] >= unreleased && lockupEndTime[lockupEndTime.length-1] > now)
{
tobeReleased = unreleased;
}
| 47,065
|
46
|
// Returns whether the specified token exists _tokenId uint ID of the token to query the existence ofreturn whether the token exists /
|
function exists(uint _tokenId) public view returns (bool) {
address owner = core.tokenToOwner(tokenIsChamp,_tokenId);
return owner != address(0);
}
|
function exists(uint _tokenId) public view returns (bool) {
address owner = core.tokenToOwner(tokenIsChamp,_tokenId);
return owner != address(0);
}
| 38,163
|
0
|
// This interfaces defines the functions of the KeeperDAO liquidity pool/ that our contract needs to know about. The only function we need is the/ borrow function, which allows us to take flash loans from the liquidity/ pool.
|
interface LiquidityPool {
/// @dev Borrow ETH/ERC20s from the liquidity pool. This function will (1)
/// send an amount of tokens to the `msg.sender`, (2) call
/// `msg.sender.call(_data)` from the KeeperDAO borrow proxy, and then (3)
/// check that the balance of the liquidity pool is greater than it was
/// before the borrow.
///
/// @param _token The address of the ERC20 to be borrowed. ETH can be
/// borrowed by specifying "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".
/// @param _amount The amount of the ERC20 (or ETH) to be borrowed. At least
/// more than this amount must be returned to the liquidity pool before the
/// end of the transaction, otherwise the transaction will revert.
/// @param _data The calldata that encodes the callback to be called on the
/// `msg.sender`. This is the mechanism through which the borrower is able
/// to implement their custom keeper logic. The callback will be called from
/// the KeeperDAO borrow proxy.
function borrow(
address _token,
uint256 _amount,
bytes calldata _data
) external;
}
|
interface LiquidityPool {
/// @dev Borrow ETH/ERC20s from the liquidity pool. This function will (1)
/// send an amount of tokens to the `msg.sender`, (2) call
/// `msg.sender.call(_data)` from the KeeperDAO borrow proxy, and then (3)
/// check that the balance of the liquidity pool is greater than it was
/// before the borrow.
///
/// @param _token The address of the ERC20 to be borrowed. ETH can be
/// borrowed by specifying "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".
/// @param _amount The amount of the ERC20 (or ETH) to be borrowed. At least
/// more than this amount must be returned to the liquidity pool before the
/// end of the transaction, otherwise the transaction will revert.
/// @param _data The calldata that encodes the callback to be called on the
/// `msg.sender`. This is the mechanism through which the borrower is able
/// to implement their custom keeper logic. The callback will be called from
/// the KeeperDAO borrow proxy.
function borrow(
address _token,
uint256 _amount,
bytes calldata _data
) external;
}
| 7,696
|
10
|
// An event emitted when a transfer is executed
|
event ExecutedTransfer(
address indexed from,
address indexed to,
uint256 normalizedAmount,
uint256 fee,
uint256 sourceChainId,
BridgeService bridge,
uint256 indexed id
);
|
event ExecutedTransfer(
address indexed from,
address indexed to,
uint256 normalizedAmount,
uint256 fee,
uint256 sourceChainId,
BridgeService bridge,
uint256 indexed id
);
| 28,627
|
0
|
// some call it 'provenance'
|
string public PROOF_OF_ANCESTRY;
|
string public PROOF_OF_ANCESTRY;
| 55,620
|
85
|
// Shortcut for the actual value
|
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock) return 0;
|
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock) return 0;
| 33,796
|
113
|
// Emits an event to notify update of the drop URI. This method assume msg.sender is an nft contract and itsERC165 interface id matches INonFungibleSeaDropToken. Note: Be sure only authorized users can call this fromtoken contracts that implement INonFungibleSeaDropToken.dropURI The new drop URI. /
|
function updateDropURI(string calldata dropURI) external;
|
function updateDropURI(string calldata dropURI) external;
| 25,974
|
38
|
// Year
|
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
} else {
|
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
} else {
| 20,028
|
13
|
// weekly token
|
} else if (end - start == 604800) {
|
} else if (end - start == 604800) {
| 2,946
|
5
|
// Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any)
|
function buy(address _referredBy) public payable returns (uint) {
purchaseTokens(msg.value, _referredBy);
}
|
function buy(address _referredBy) public payable returns (uint) {
purchaseTokens(msg.value, _referredBy);
}
| 22,579
|
0
|
// Remote chain block header./https:github.com/lazyledger/lazyledger-specs/blob/master/specs/data_structures.mdheader
|
struct Header {
uint64 height;
uint64 timestamp;
bytes32 lastBlockID;
bytes32 lastCommitRoot;
bytes32 consensusRoot;
bytes32 stateCommitment;
bytes32 availableDataRoot;
bytes32 proposerAddress; // Note: this needs to be converted to a 20-byte address when used
}
|
struct Header {
uint64 height;
uint64 timestamp;
bytes32 lastBlockID;
bytes32 lastCommitRoot;
bytes32 consensusRoot;
bytes32 stateCommitment;
bytes32 availableDataRoot;
bytes32 proposerAddress; // Note: this needs to be converted to a 20-byte address when used
}
| 51,171
|
224
|
// The ID of the project contract that this funding cycle belongs to.
|
uint256 projectId;
|
uint256 projectId;
| 23,624
|
19
|
// Throws if Lease Contract is already ended /
|
modifier isOngoingLease(uint256 _leaseId) {
DeedLease storage lease = deedLeases[_leaseId];
require(lease.leaseEndDate > block.timestamp && lease.leaseEndDate > lease.noticePeriodDate, "DeedRenting#isOngoingLease - Lease is already ended");
_;
}
|
modifier isOngoingLease(uint256 _leaseId) {
DeedLease storage lease = deedLeases[_leaseId];
require(lease.leaseEndDate > block.timestamp && lease.leaseEndDate > lease.noticePeriodDate, "DeedRenting#isOngoingLease - Lease is already ended");
_;
}
| 12,522
|
9
|
// _operatorStore A contract storing operator assignments.
|
constructor(IJBOperatorStore _operatorStore) {
operatorStore = _operatorStore;
}
|
constructor(IJBOperatorStore _operatorStore) {
operatorStore = _operatorStore;
}
| 14,427
|
54
|
// Transfers the ownership of a given token ID to another address Usage of this method is discouraged, use `safeTransferFrom` whenever possible Requires the msg sender to be the owner, approved, or operator _from current owner of the token _to address to receive the ownership of the given token ID _tokenId uint256 ID of the token to be transferred/
|
function transferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) {
require(_from != address(0));
require(_to != address(0));
clearApproval(_from, _tokenId);
removeTokenFrom(_from, _tokenId);
addTokenTo(_to, _tokenId);
emit Transfer(_from, _to, _tokenId);
}
|
function transferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) {
require(_from != address(0));
require(_to != address(0));
clearApproval(_from, _tokenId);
removeTokenFrom(_from, _tokenId);
addTokenTo(_to, _tokenId);
emit Transfer(_from, _to, _tokenId);
}
| 26,294
|
8
|
//
|
# | '-(_{;}_) ; \ '_ / | : .' '_ | | (_ o _). . (_ o _) |
# | (_,_) | _`,/ \ _/ | ' ( \.-.| (_,_). '. | (_,_)___|
# | _ _--. | : ( '\_/ \ ; ' (`. _` /| .---. \ : ' \ .---.
# |( ' ) | | \ `"/ \ ) / | (_ (_) _) \ `-' | \ `-' /
# (_{;}_)| | '. \_/``".' \ / . \ / \ / \ /
# '(_,_) '---' '-----' ``-'`-'' `-...-' `'-..-'
# .-------. .---. ____ ,---. .--. ,---------. .-'''-.
# \ _(`)_ \ | ,_| .' __ `. | \ | | \ \ / _ \
# | (_ o._)| ,-./ ) / ' \ \ | , \ | | `--. ,---' (`' )/`--'
# | (_,_) / \ '_ '`) |___| / | | |\_ \| | | \ (_ o _).
# | '-.-' > (_) ) _.-` | | _( )_\ | :_ _: (_,_). '.
# | | ( . .-' .' _ | | (_ o _) | (_I_) .---. \ :
# | | `-'`-'|___ | _( )_ | | (_,_)\ | (_(=)_) \ `-' |
# / ) | \ \ (_ o _) / | | | | (_I_) \ /
# `---' `--------` '.(_,_).' '--' '--' '---' `-...-' */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract House_Plants is ERC721Enumerable, ReentrancyGuard, Ownable {
using Counters for Counters.Counter;
using SafeMath for uint256;
constructor (string memory customBaseURI_) ERC721("House Plants", "HPFZ") {
customBaseURI = customBaseURI_;
}
// Reserve 50 Villains for Felt team - Giveaways/Prizes etc
uint public HousePlantsReserve = 500;
/** MINTING **/
uint256 public constant MAX_SUPPLY = 5000;
uint256 public constant MAX_MULTIMINT = 50;
uint256 public constant PRICE = 20000000000000000;
function GrowPlants(uint256 count) public payable nonReentrant {
require(saleIsActive, "Sale not active");
require(totalSupply() + count - 1 < MAX_SUPPLY, "Exceeds max supply");
require(count <= MAX_MULTIMINT, "Mint at most 50 at a time");
require(
msg.value >= PRICE * count, "Insufficient payment, 0.02 ETH per item"
);
for (uint256 i = 0; i < count; i++) {
_safeMint(_msgSender(), totalSupply());
}
}
function reserveHousePlants(address _to, uint256 _reserveAmount) public onlyOwner {
uint supply = totalSupply();
require(_reserveAmount > 0 && _reserveAmount <= HousePlantsReserve, "Nah fam, there's no more left for Felt.");
for (uint i = 0; i < _reserveAmount; i++) {
_safeMint(_to, supply + i);
}
HousePlantsReserve = HousePlantsReserve.sub(_reserveAmount);
}
/** ACTIVATION **/
bool public saleIsActive = true;
function setSaleIsActive(bool saleIsActive_) external onlyOwner {
saleIsActive = saleIsActive_;
}
/** URI HANDLING **/
string private customBaseURI;
function setBaseURI(string memory customBaseURI_) external onlyOwner {
customBaseURI = customBaseURI_;
}
function _baseURI() internal view virtual override returns (string memory) {
return customBaseURI;
}
/** PAYOUT **/
address private constant payoutAddress1 =
0xF871A4FB983b89C123CD4e70f768DC9EF5ce5f71;
address private constant payoutAddress2 =
0x3ae285B8f6ADcf9C728d0B761948e25DD065610E;
address private constant payoutAddress3 =
0x050A2Af16d500bCDB5CE7a21fBD95A5C831210aB;
function withdraw() public {
uint256 balance = address(this).balance;
payable(payoutAddress1).transfer(balance * 10 / 100);
payable(payoutAddress2).transfer(balance * 50 / 100);
payable(payoutAddress3).transfer(balance * 40 / 100);
}
}
|
# | '-(_{;}_) ; \ '_ / | : .' '_ | | (_ o _). . (_ o _) |
# | (_,_) | _`,/ \ _/ | ' ( \.-.| (_,_). '. | (_,_)___|
# | _ _--. | : ( '\_/ \ ; ' (`. _` /| .---. \ : ' \ .---.
# |( ' ) | | \ `"/ \ ) / | (_ (_) _) \ `-' | \ `-' /
# (_{;}_)| | '. \_/``".' \ / . \ / \ / \ /
# '(_,_) '---' '-----' ``-'`-'' `-...-' `'-..-'
# .-------. .---. ____ ,---. .--. ,---------. .-'''-.
# \ _(`)_ \ | ,_| .' __ `. | \ | | \ \ / _ \
# | (_ o._)| ,-./ ) / ' \ \ | , \ | | `--. ,---' (`' )/`--'
# | (_,_) / \ '_ '`) |___| / | | |\_ \| | | \ (_ o _).
# | '-.-' > (_) ) _.-` | | _( )_\ | :_ _: (_,_). '.
# | | ( . .-' .' _ | | (_ o _) | (_I_) .---. \ :
# | | `-'`-'|___ | _( )_ | | (_,_)\ | (_(=)_) \ `-' |
# / ) | \ \ (_ o _) / | | | | (_I_) \ /
# `---' `--------` '.(_,_).' '--' '--' '---' `-...-' */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract House_Plants is ERC721Enumerable, ReentrancyGuard, Ownable {
using Counters for Counters.Counter;
using SafeMath for uint256;
constructor (string memory customBaseURI_) ERC721("House Plants", "HPFZ") {
customBaseURI = customBaseURI_;
}
// Reserve 50 Villains for Felt team - Giveaways/Prizes etc
uint public HousePlantsReserve = 500;
/** MINTING **/
uint256 public constant MAX_SUPPLY = 5000;
uint256 public constant MAX_MULTIMINT = 50;
uint256 public constant PRICE = 20000000000000000;
function GrowPlants(uint256 count) public payable nonReentrant {
require(saleIsActive, "Sale not active");
require(totalSupply() + count - 1 < MAX_SUPPLY, "Exceeds max supply");
require(count <= MAX_MULTIMINT, "Mint at most 50 at a time");
require(
msg.value >= PRICE * count, "Insufficient payment, 0.02 ETH per item"
);
for (uint256 i = 0; i < count; i++) {
_safeMint(_msgSender(), totalSupply());
}
}
function reserveHousePlants(address _to, uint256 _reserveAmount) public onlyOwner {
uint supply = totalSupply();
require(_reserveAmount > 0 && _reserveAmount <= HousePlantsReserve, "Nah fam, there's no more left for Felt.");
for (uint i = 0; i < _reserveAmount; i++) {
_safeMint(_to, supply + i);
}
HousePlantsReserve = HousePlantsReserve.sub(_reserveAmount);
}
/** ACTIVATION **/
bool public saleIsActive = true;
function setSaleIsActive(bool saleIsActive_) external onlyOwner {
saleIsActive = saleIsActive_;
}
/** URI HANDLING **/
string private customBaseURI;
function setBaseURI(string memory customBaseURI_) external onlyOwner {
customBaseURI = customBaseURI_;
}
function _baseURI() internal view virtual override returns (string memory) {
return customBaseURI;
}
/** PAYOUT **/
address private constant payoutAddress1 =
0xF871A4FB983b89C123CD4e70f768DC9EF5ce5f71;
address private constant payoutAddress2 =
0x3ae285B8f6ADcf9C728d0B761948e25DD065610E;
address private constant payoutAddress3 =
0x050A2Af16d500bCDB5CE7a21fBD95A5C831210aB;
function withdraw() public {
uint256 balance = address(this).balance;
payable(payoutAddress1).transfer(balance * 10 / 100);
payable(payoutAddress2).transfer(balance * 50 / 100);
payable(payoutAddress3).transfer(balance * 40 / 100);
}
}
| 72,854
|
359
|
// Only creator allowed
|
uint256 internal constant ONLY_CREATOR = 17;
|
uint256 internal constant ONLY_CREATOR = 17;
| 15,717
|
67
|
// token addresses
|
address public constant __weth =
address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public constant __dai =
address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address public constant __uniswap =
address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address public constant __idleUnderlying =
address(0x3fE7940616e5Bc47b0775a0dccf6237893353bB4);
address public constant __comp =
address(0xc00e94Cb662C3520282E6f5717214004A7f26888);
|
address public constant __weth =
address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public constant __dai =
address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address public constant __uniswap =
address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address public constant __idleUnderlying =
address(0x3fE7940616e5Bc47b0775a0dccf6237893353bB4);
address public constant __comp =
address(0xc00e94Cb662C3520282E6f5717214004A7f26888);
| 75,826
|
111
|
// store the result and increase reveal number if match isn't finalized
|
if (!thisMatch.finalized) {
bytes32 storeResult = keccak256(abi.encodePacked(matchHash, homeScore, awayScore));
storeMatchReveal(sender, league, matchHash, storeResult, homeScore, awayScore);
}
|
if (!thisMatch.finalized) {
bytes32 storeResult = keccak256(abi.encodePacked(matchHash, homeScore, awayScore));
storeMatchReveal(sender, league, matchHash, storeResult, homeScore, awayScore);
}
| 1,453
|
82
|
// Referrer Earning
|
if (stakingDetails[msg.sender].referrer[stakeId] != address(0)) {
uint256 refEarned =
(rewardsEarned.mul(refPercentage)).div(100 ether);
rewardsEarned = rewardsEarned.sub(refEarned);
require(IERC20(stakingDetails[msg.sender].tokenAddress[stakeId]).transfer(
stakingDetails[msg.sender].referrer[stakeId],
refEarned) == true, "Transfer Failed");
}
|
if (stakingDetails[msg.sender].referrer[stakeId] != address(0)) {
uint256 refEarned =
(rewardsEarned.mul(refPercentage)).div(100 ether);
rewardsEarned = rewardsEarned.sub(refEarned);
require(IERC20(stakingDetails[msg.sender].tokenAddress[stakeId]).transfer(
stakingDetails[msg.sender].referrer[stakeId],
refEarned) == true, "Transfer Failed");
}
| 3,195
|
3
|
// this function is used if anyone wants to send ether to the contract. It could be employer, freelancer, or even you, or me :)
|
receive() external payable {}
// implementing the freelencer sending request part of the contract.
// struct to store payment request of freelancer.
struct Request {
string title;
uint256 amount; // why uint256?? - same as uint, no difference
bool locked; // initialially request will be locked, employer will unlock it and transfer required ehther.
bool paid;
}
|
receive() external payable {}
// implementing the freelencer sending request part of the contract.
// struct to store payment request of freelancer.
struct Request {
string title;
uint256 amount; // why uint256?? - same as uint, no difference
bool locked; // initialially request will be locked, employer will unlock it and transfer required ehther.
bool paid;
}
| 34,028
|
7
|
// Emitted when seconds ago changes/ago new seconds ago value in seconds, ie. 1800 means 30 min
|
event NewSecondsAgo(uint32 ago);
|
event NewSecondsAgo(uint32 ago);
| 10,013
|
15
|
// Wether the sale is finalized
|
bool public finalized;
|
bool public finalized;
| 45,218
|
260
|
// invest the amount of want/When this function is called, the controller has already sent want to this/Just get the current balance and then invest accordingly
|
function _deposit(uint256 _amount) internal override {
// Lock tokens for 16 weeks, send credit to strat, always use max boost cause why not?
LOCKER.lock(address(this), _amount, getBoostPayment());
}
|
function _deposit(uint256 _amount) internal override {
// Lock tokens for 16 weeks, send credit to strat, always use max boost cause why not?
LOCKER.lock(address(this), _amount, getBoostPayment());
}
| 16,268
|
84
|
// Emits a {Transfer} event with `to` set to the zero address.Requirements:- `_from` cannot be the zero address.- `_from` must have at least `_amnt` tokens. _from The address from which to destroy the tokens _amnt The amount of tokens to be destroyed /
|
function burn(address _from, uint256 _amnt) external override onlyOwner {
_burn(_from, _amnt);
}
|
function burn(address _from, uint256 _amnt) external override onlyOwner {
_burn(_from, _amnt);
}
| 7,929
|
224
|
// zombieAssets
|
mapping(string => string[]) public zombieAssets;
string public baseURI = 'https://gateway.pinata.cloud/ipfs/';
|
mapping(string => string[]) public zombieAssets;
string public baseURI = 'https://gateway.pinata.cloud/ipfs/';
| 28,544
|
215
|
// Event emitted when owner makes a rescue dust request
|
event RescuedDust(string indexed dustType, uint256 amount);
|
event RescuedDust(string indexed dustType, uint256 amount);
| 14,126
|
95
|
// Get the current payload signer;/ return Signer address
|
function rewardsSigner() external view returns (address);
|
function rewardsSigner() external view returns (address);
| 46,808
|
17
|
// to receive ERC721 tokens
|
function onERC721Received(
address operator,
address from,
uint256 tokenId,
|
function onERC721Received(
address operator,
address from,
uint256 tokenId,
| 48,053
|
24
|
// Registers an underlying-token.// This function reverts if the caller is not the current admin.//underlyingToken The underlying-token being registered./steamerThe steamer for the underlying-token.
|
function registerAsset(address underlyingToken, address steamer) external;
|
function registerAsset(address underlyingToken, address steamer) external;
| 41,078
|
66
|
// Modifier to make a function callable only by service provider i.e. Noku./
|
modifier onlyServiceProvider() {
require(msg.sender == serviceProvider);
_;
}
|
modifier onlyServiceProvider() {
require(msg.sender == serviceProvider);
_;
}
| 47,621
|
23
|
// KamaGames ERC20 token KamaGames ERC20 token based on code by OpenZeppelin commit 4385fd5a236db303699476facfd212481eeac6c1 at github.com/OpenZeppelin/openzeppelin-solidity.git>Implementation of the basic standard token. /
|
contract KamaGamesToken {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
event Chips(
address indexed _payee,
address indexed _to,
uint256 _value
);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event TokensBurned(
address indexed burner,
uint256 value
);
address private constant address_prefix = address(~uint256(0xFFFFFFFF));
constructor() public {
totalSupply_ = 31250000000000;
balances_[msg.sender] = totalSupply_;
}
function name() public pure returns (string) { return("KamaGames Token"); }
function symbol() public pure returns (string) { return("KGT"); }
function decimals() public pure returns (uint8) {return 6;}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
if(_to > address_prefix){
_burn(msg.sender, _value);
emit Chips(msg.sender, _to, _value);
return true;
}
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require(_spender != address(0));
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @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 uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
if(_to > address_prefix){
_burn(_from,_value);
emit Chips(msg.sender, _to, _value);
return true;
}
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* 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 _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
require(_spender != address(0));
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @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 _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
require(_spender != address(0));
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != address(0));
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][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_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
emit TokensBurned(msg.sender, _value);
}
/**
* @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 {
_burnFrom(_from, _value);
emit TokensBurned(_from, _value);
}
}
|
contract KamaGamesToken {
using SafeMath for uint256;
mapping (address => uint256) private balances_;
mapping (address => mapping (address => uint256)) private allowed_;
uint256 private totalSupply_;
event Chips(
address indexed _payee,
address indexed _to,
uint256 _value
);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event TokensBurned(
address indexed burner,
uint256 value
);
address private constant address_prefix = address(~uint256(0xFFFFFFFF));
constructor() public {
totalSupply_ = 31250000000000;
balances_[msg.sender] = totalSupply_;
}
function name() public pure returns (string) { return("KamaGames Token"); }
function symbol() public pure returns (string) { return("KGT"); }
function decimals() public pure returns (uint8) {return 6;}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed_[_owner][_spender];
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances_[msg.sender]);
require(_to != address(0));
if(_to > address_prefix){
_burn(msg.sender, _value);
emit Chips(msg.sender, _to, _value);
return true;
}
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require(_spender != address(0));
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @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 uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
require(_to != address(0));
if(_to > address_prefix){
_burn(_from,_value);
emit Chips(msg.sender, _to, _value);
return true;
}
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* 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 _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
require(_spender != address(0));
allowed_[msg.sender][_spender] = (
allowed_[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @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 _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
require(_spender != address(0));
uint256 oldValue = allowed_[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed_[msg.sender][_spender] = 0;
} else {
allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]);
return true;
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != address(0));
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal _burn function.
* @param _account The account whose tokens will be burnt.
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed_[_account][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_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
}
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
emit TokensBurned(msg.sender, _value);
}
/**
* @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 {
_burnFrom(_from, _value);
emit TokensBurned(_from, _value);
}
}
| 50,220
|
42
|
// a contract must implement this interface in order to support relayed transaction.It is better to inherit the BaseRelayRecipient as its implementation. /
|
abstract contract IRelayRecipient {
/**
* return if the forwarder is trusted to forward relayed transactions to us.
* the forwarder is required to verify the sender's signature, and verify
* the call is not a replay.
*/
function isTrustedForwarder(address forwarder) public virtual view returns(bool);
/**
* return the sender of this call.
* if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
* of the msg.data.
* otherwise, return `msg.sender`
* should be used in the contract anywhere instead of msg.sender
*/
function _msgSender() internal virtual view returns (address payable);
/**
* return the msg.data of this call.
* if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
* of the msg.data - so this method will strip those 20 bytes off.
* otherwise, return `msg.data`
* should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
* signing or hashing the
*/
function _msgData() internal virtual view returns (bytes memory);
function versionRecipient() external virtual view returns (string memory);
}
|
abstract contract IRelayRecipient {
/**
* return if the forwarder is trusted to forward relayed transactions to us.
* the forwarder is required to verify the sender's signature, and verify
* the call is not a replay.
*/
function isTrustedForwarder(address forwarder) public virtual view returns(bool);
/**
* return the sender of this call.
* if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
* of the msg.data.
* otherwise, return `msg.sender`
* should be used in the contract anywhere instead of msg.sender
*/
function _msgSender() internal virtual view returns (address payable);
/**
* return the msg.data of this call.
* if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
* of the msg.data - so this method will strip those 20 bytes off.
* otherwise, return `msg.data`
* should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
* signing or hashing the
*/
function _msgData() internal virtual view returns (bytes memory);
function versionRecipient() external virtual view returns (string memory);
}
| 29,842
|
278
|
// - Manages a battle session between superblock submitter and challenger
|
contract SyscoinBattleManager is SyscoinErrorCodes {
enum ChallengeState {
Unchallenged, // Unchallenged submission
Challenged, // Claims was challenged
QueryMerkleRootHashes, // Challenger expecting block hashes
RespondMerkleRootHashes, // Blcok hashes were received and verified
QueryBlockHeader, // Challenger is requesting block headers
RespondBlockHeader, // All block headers were received
PendingVerification, // Pending superblock verification
SuperblockVerified, // Superblock verified
SuperblockFailed // Superblock not valid
}
|
contract SyscoinBattleManager is SyscoinErrorCodes {
enum ChallengeState {
Unchallenged, // Unchallenged submission
Challenged, // Claims was challenged
QueryMerkleRootHashes, // Challenger expecting block hashes
RespondMerkleRootHashes, // Blcok hashes were received and verified
QueryBlockHeader, // Challenger is requesting block headers
RespondBlockHeader, // All block headers were received
PendingVerification, // Pending superblock verification
SuperblockVerified, // Superblock verified
SuperblockFailed // Superblock not valid
}
| 3,086
|
20
|
// allows the owner to whitelist a product product is the hash of underlying asset, strike asset, collateral asset, and isPutcan only be called from the owner address _underlying asset that the option references _strike asset that the strike price is denominated in _collateral asset that is held as collateral against short/written options _isPut True if a put option, False if a call option /
|
function whitelistProduct(
address _underlying,
address _strike,
address _collateral,
bool _isPut
|
function whitelistProduct(
address _underlying,
address _strike,
address _collateral,
bool _isPut
| 35,676
|
85
|
// We use this mapping to easily find the history of VRF results, such as the last five hands dealt, or when aces were hit.
|
lookupTokenHistory[tokenID].push(tokenHistory(chipStack[tokenID], plaqueStack[tokenID], totalAces[tokenID], matchingAces[tokenID], diamondAces[tokenID], lastLeftCard[tokenID], lastRightCard[tokenID]));
|
lookupTokenHistory[tokenID].push(tokenHistory(chipStack[tokenID], plaqueStack[tokenID], totalAces[tokenID], matchingAces[tokenID], diamondAces[tokenID], lastLeftCard[tokenID], lastRightCard[tokenID]));
| 51,233
|
69
|
// First we retrieve a pointer to the Procedure Table Length value.
|
uint256 lenP = _getPointerProcedureTableLength();
|
uint256 lenP = _getPointerProcedureTableLength();
| 11,079
|
25
|
// get token can be saled./ return uint256 tokens.
|
//function checkTokenCanSaled() constant returns (uint256){
function tokenLeftInSale() constant returns (uint256){
uint256 restToken = ecn.balanceOf(fundingRecipient);
uint256 allowToken = SafeMath.min256(restToken, ecn.allowance(owner, this));
uint256 tokenLeft = SafeMath.min256(allowToken, MAX_TOKENS_SOLD.sub(tokensSold));
return tokenLeft;
}
/// @dev receive wei and caculate token saled.
/// @return tokens will be transfered.
function receiveWei(address _buyer, uint256 _value, uint _rate) private returns (uint256){
uint256 tokenLeft = tokenLeftInSale();
uint256 weiLeftInSale = tokenLeft.div(_rate);
// Accept funds and transfer to funding recipient.
uint256 weiToParticipate = SafeMath.min256(_value, weiLeftInSale);
fundingRecipient.transfer(weiToParticipate);
// Partial refund if full participation not possible
// e.g. due to cap being reached.
uint256 refund = _value.sub(weiToParticipate);
if (refund > 0) {
_buyer.transfer(refund);
}
// Issue tokens and transfer to recipient.
uint256 tokensToIssue = weiToParticipate.mul(_rate);
return tokensToIssue;
}
/// @dev Fallback function that will delegate the request to saleToken().
function saleToken() external payable onlyDuringSale {
//Check wei received
require(msg.value > 0);
uint256 tokensToIssue = receiveWei(msg.sender, msg.value, ECN_PER_WEI);
ecn.transferFrom(owner, msg.sender, tokensToIssue);
TokensIssued(msg.sender, tokensToIssue);
}
/// @dev saling tokens at discount 1
function saleTokenDelay1() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 0);
}
/// @dev saling tokens at discount 2
function saleTokenDelay2() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 1);
}
/// @dev saling tokens at discount 3
function saleTokenDelay3() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 2);
}
/// @dev saling tokens at discount
/// @param buyer the address of buyer .
/// @param value weis receive from buyer.
/// @param delayPeriod which discount to be used, form 0 to 2.
function saleTokenDelay(address buyer, uint256 value, uint delayPeriod) private {
//check wei received and tokens left
require(value > 10**16);//0.01eth min
uint rateBuying = ECN_PER_WEI * 100 / saleRates[delayPeriod];
//find a blank item
uint blankIndex = MAX_NUM_OF_SALEITEM;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i ++){
if(0 == saleItem[i].value){
blankIndex = i;
break;
}
}
require(blankIndex < MAX_NUM_OF_SALEITEM);
uint256 tokensToIssue = receiveWei(buyer, value, rateBuying);
saleItem[blankIndex].user = buyer;
saleItem[blankIndex].value = tokensToIssue;
saleItem[blankIndex].timeAvail = now + saleDelays[delayPeriod];
TokenSaleDelay(buyer, tokensToIssue, saleItem[blankIndex].timeAvail);
}
/// @dev get tokens can be withdrawed.
/// @return tokens can be withdrawed for current buyer.
function checkAvailTokens() constant returns (uint256){
uint256 totalTokens = 0;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i ++){
if(saleItem[i].value > 0 && now > saleItem[i].timeAvail && saleItem[i].user == msg.sender){
totalTokens = totalTokens.add(saleItem[i].value);
}
}
return totalTokens;
}
/// @dev buyer withdraw tokens to their account.
function withdrawAvailTokens() external{
uint256 restToken = ecn.allowance(owner, this);
uint256 totalTokens = 0;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i++){
if(saleItem[i].value > 0 && now > saleItem[i].timeAvail && saleItem[i].user == msg.sender){
if(totalTokens.add(saleItem[i].value) < restToken){
totalTokens = totalTokens.add(saleItem[i].value);
saleItem[i].value = 0;
}
else
break;
}
}
if(totalTokens > 0){
ecn.transferFrom(owner, msg.sender, totalTokens);
}
}
}
|
//function checkTokenCanSaled() constant returns (uint256){
function tokenLeftInSale() constant returns (uint256){
uint256 restToken = ecn.balanceOf(fundingRecipient);
uint256 allowToken = SafeMath.min256(restToken, ecn.allowance(owner, this));
uint256 tokenLeft = SafeMath.min256(allowToken, MAX_TOKENS_SOLD.sub(tokensSold));
return tokenLeft;
}
/// @dev receive wei and caculate token saled.
/// @return tokens will be transfered.
function receiveWei(address _buyer, uint256 _value, uint _rate) private returns (uint256){
uint256 tokenLeft = tokenLeftInSale();
uint256 weiLeftInSale = tokenLeft.div(_rate);
// Accept funds and transfer to funding recipient.
uint256 weiToParticipate = SafeMath.min256(_value, weiLeftInSale);
fundingRecipient.transfer(weiToParticipate);
// Partial refund if full participation not possible
// e.g. due to cap being reached.
uint256 refund = _value.sub(weiToParticipate);
if (refund > 0) {
_buyer.transfer(refund);
}
// Issue tokens and transfer to recipient.
uint256 tokensToIssue = weiToParticipate.mul(_rate);
return tokensToIssue;
}
/// @dev Fallback function that will delegate the request to saleToken().
function saleToken() external payable onlyDuringSale {
//Check wei received
require(msg.value > 0);
uint256 tokensToIssue = receiveWei(msg.sender, msg.value, ECN_PER_WEI);
ecn.transferFrom(owner, msg.sender, tokensToIssue);
TokensIssued(msg.sender, tokensToIssue);
}
/// @dev saling tokens at discount 1
function saleTokenDelay1() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 0);
}
/// @dev saling tokens at discount 2
function saleTokenDelay2() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 1);
}
/// @dev saling tokens at discount 3
function saleTokenDelay3() external payable onlyDuringSale{
saleTokenDelay(msg.sender, msg.value, 2);
}
/// @dev saling tokens at discount
/// @param buyer the address of buyer .
/// @param value weis receive from buyer.
/// @param delayPeriod which discount to be used, form 0 to 2.
function saleTokenDelay(address buyer, uint256 value, uint delayPeriod) private {
//check wei received and tokens left
require(value > 10**16);//0.01eth min
uint rateBuying = ECN_PER_WEI * 100 / saleRates[delayPeriod];
//find a blank item
uint blankIndex = MAX_NUM_OF_SALEITEM;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i ++){
if(0 == saleItem[i].value){
blankIndex = i;
break;
}
}
require(blankIndex < MAX_NUM_OF_SALEITEM);
uint256 tokensToIssue = receiveWei(buyer, value, rateBuying);
saleItem[blankIndex].user = buyer;
saleItem[blankIndex].value = tokensToIssue;
saleItem[blankIndex].timeAvail = now + saleDelays[delayPeriod];
TokenSaleDelay(buyer, tokensToIssue, saleItem[blankIndex].timeAvail);
}
/// @dev get tokens can be withdrawed.
/// @return tokens can be withdrawed for current buyer.
function checkAvailTokens() constant returns (uint256){
uint256 totalTokens = 0;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i ++){
if(saleItem[i].value > 0 && now > saleItem[i].timeAvail && saleItem[i].user == msg.sender){
totalTokens = totalTokens.add(saleItem[i].value);
}
}
return totalTokens;
}
/// @dev buyer withdraw tokens to their account.
function withdrawAvailTokens() external{
uint256 restToken = ecn.allowance(owner, this);
uint256 totalTokens = 0;
for(uint i = 0; i < MAX_NUM_OF_SALEITEM; i++){
if(saleItem[i].value > 0 && now > saleItem[i].timeAvail && saleItem[i].user == msg.sender){
if(totalTokens.add(saleItem[i].value) < restToken){
totalTokens = totalTokens.add(saleItem[i].value);
saleItem[i].value = 0;
}
else
break;
}
}
if(totalTokens > 0){
ecn.transferFrom(owner, msg.sender, totalTokens);
}
}
}
| 19,620
|
315
|
// Creates a new token for `to`. Its token ID will be automatically
|
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
* URI autogenerated based on the base URI passed at construction.
*
* See {ERC721-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to) internal virtual {
// We cannot just use balanceOf to create the new tokenId because tokens
// can be burned (destroyed), so we need a separate counter.
_mint(to, _tokenIdTracker.current());
_tokenIdTracker.increment();
}
|
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
* URI autogenerated based on the base URI passed at construction.
*
* See {ERC721-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to) internal virtual {
// We cannot just use balanceOf to create the new tokenId because tokens
// can be burned (destroyed), so we need a separate counter.
_mint(to, _tokenIdTracker.current());
_tokenIdTracker.increment();
}
| 35,136
|
199
|
// Even if unlockedStakes is true, locked stakes in the fee dist contract have a 91 day minimum lock time
|
require(user.ending_timestamp < block.timestamp || (unlockedStakes && user.lastDepositTime.add(min_duration) < block.timestamp), "Can't withdraw yet");
uint256 r = (balance().mul(user.shares)).div(totalShares);
_claimReward(msg.sender);
user.extraRewards += user.principal.mul(lockInfo[user.lockIndex].rewardRate).div(MAX_RATE);
_claimExtraReward(msg.sender);
|
require(user.ending_timestamp < block.timestamp || (unlockedStakes && user.lastDepositTime.add(min_duration) < block.timestamp), "Can't withdraw yet");
uint256 r = (balance().mul(user.shares)).div(totalShares);
_claimReward(msg.sender);
user.extraRewards += user.principal.mul(lockInfo[user.lockIndex].rewardRate).div(MAX_RATE);
_claimExtraReward(msg.sender);
| 3,620
|
33
|
// Allows beneficiary to claim claimable tokens, can be called by anyone./
|
function claimToken(address _beneficiary) external {
(uint256 _totalUnlocked, uint256 _claimable) = unlockedAmount(_beneficiary);
require(_claimable > 0, "TokenVesting: No claimable amount");
beneficiaries[_beneficiary].claimedAmount = _totalUnlocked;
token.transfer(_beneficiary, _claimable);
emit TokenClaimed(_beneficiary, _claimable);
}
|
function claimToken(address _beneficiary) external {
(uint256 _totalUnlocked, uint256 _claimable) = unlockedAmount(_beneficiary);
require(_claimable > 0, "TokenVesting: No claimable amount");
beneficiaries[_beneficiary].claimedAmount = _totalUnlocked;
token.transfer(_beneficiary, _claimable);
emit TokenClaimed(_beneficiary, _claimable);
}
| 16,586
|
140
|
// Whether or not the auction curator has approved the auction to start
|
bool approved;
|
bool approved;
| 57,291
|
124
|
// Only update actual balance of sender if he's excluded from rewards
|
if (_isExcluded[from]){
_balance_total[from] = _balance_total[from] - tAmount;
}
|
if (_isExcluded[from]){
_balance_total[from] = _balance_total[from] - tAmount;
}
| 42,495
|
275
|
// Only three tokens we use
|
address private constant comp = 0xc00e94Cb662C3520282E6f5717214004A7f26888;
CErc20I public cToken;
address public constant uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
address private constant comp = 0xc00e94Cb662C3520282E6f5717214004A7f26888;
CErc20I public cToken;
address public constant uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
| 36,292
|
3
|
// This function allows the owner to specify an address that will take over ownership rights instead. Please double check the address provided as once the function is executed, only the new owner will be able to change the address back.
|
function changeOwner(address _newOwner) public onlyOwner {
owner = _newOwner;
}
|
function changeOwner(address _newOwner) public onlyOwner {
owner = _newOwner;
}
| 37,333
|
18
|
// Get ionic charge of a specified POWNFT Atom/Gets Atom hash from POWNFT contract, so will throw for _tokenId of non-existent token./_tokenId TokenId of the Atom to query/ return ionic charge of the Atom
|
function getIonCharge(uint _tokenId) external view returns(int8);
|
function getIonCharge(uint _tokenId) external view returns(int8);
| 26,284
|
257
|
// Helper Functions ///
|
function _whenProtocolNotPaused() internal view {
require(!_globals(superFactory).protocolPaused(), "L:PROTO_PAUSED");
}
|
function _whenProtocolNotPaused() internal view {
require(!_globals(superFactory).protocolPaused(), "L:PROTO_PAUSED");
}
| 23,760
|
0
|
// Constructor
|
constructor(Ethicare _ethicare) public {
ethicare = _ethicare;
}
|
constructor(Ethicare _ethicare) public {
ethicare = _ethicare;
}
| 2,932
|
23
|
// owner only functions Emergency Recovery and kill code in case contract becomes useless (to recover gass)
|
function withdraw() external onlyOwner{
owner.transfer(address(this).balance);
}
|
function withdraw() external onlyOwner{
owner.transfer(address(this).balance);
}
| 61,465
|
54
|
// Mints `_amount` tokens that are assigned to `_owner`/_owner The address that will be assigned the new tokens/_amount The quantity of tokens generated/ return True if the tokens are generated correctly
|
function mint(address _owner, uint _amount) external onlyOwner returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
emit Transfer(address(0), _owner, _amount);
return true;
}
|
function mint(address _owner, uint _amount) external onlyOwner returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
emit Transfer(address(0), _owner, _amount);
return true;
}
| 11,391
|
28
|
// -----------------------------------------------------------------------/ Effects/ -----------------------------------------------------------------------
|
unchecked {
for (uint256 i = 0; i < idList.length; i++) {
stakeToken().safeTransferFrom(
msg.sender,
address(this),
idList[i]
);
}
|
unchecked {
for (uint256 i = 0; i < idList.length; i++) {
stakeToken().safeTransferFrom(
msg.sender,
address(this),
idList[i]
);
}
| 47,671
|
8
|
// TRUSTED. Manages contributions and calls appeal function of the specified arbitrator to appeal a dispute. This function lets appeals be crowdfunded._localDisputeID Index of the dispute in disputes array._ruling The ruling to which the caller wants to contribute. return fullyFunded Whether _ruling was fully funded after the call. /
|
function fundAppeal(uint256 _localDisputeID, uint256 _ruling) external payable override returns (bool fullyFunded) {
require(_ruling <= numberOfRulingOptions[_localDisputeID], "There is no such ruling to fund.");
DisputeStruct storage dispute = disputes[_localDisputeID];
uint256 disputeID = dispute.disputeIDOnArbitratorSide; // Intermediate variable to make reads cheaper.
uint256 originalCost;
uint256 totalCost;
{
uint256 currentRuling = arbitrator.currentRuling(disputeID); // Intermediate variable to make reads cheaper.
(originalCost, totalCost) = appealCost(disputeID, dispute.arbitratorExtraData, _ruling, currentRuling);
checkAppealPeriod(disputeID, _ruling, currentRuling); // Reverts if appeal period has been expired for _ruling.
}
Round[] storage rounds = disputeIDtoRoundArray[_localDisputeID];
uint256 lastRoundIndex = rounds.length - 1; // Intermediate variable to make reads cheaper.
Round storage lastRound = rounds[lastRoundIndex];
require(!lastRound.hasPaid[_ruling], "Appeal fee has already been paid.");
uint256 paidFeesInLastRound = lastRound.paidFees[_ruling]; // Intermediate variable to make reads cheaper.
uint256 contribution = totalCost.subCap(paidFeesInLastRound) > msg.value ? msg.value : totalCost.subCap(paidFeesInLastRound);
lastRound.paidFees[_ruling] += contribution;
emit Contribution(_localDisputeID, lastRoundIndex, _ruling, msg.sender, contribution);
lastRound.contributions[msg.sender][_ruling] += contribution;
paidFeesInLastRound = lastRound.paidFees[_ruling]; // Intermediate variable to make reads cheaper.
if (paidFeesInLastRound >= totalCost) {
lastRound.feeRewards += paidFeesInLastRound;
lastRound.fundedRulings.push(_ruling);
lastRound.hasPaid[_ruling] = true;
emit RulingFunded(_localDisputeID, lastRoundIndex, _ruling);
}
if (lastRound.fundedRulings.length == 2) {
// Two competing ruling options means we will have another appeal round.
rounds.push();
lastRound.feeRewards = lastRound.feeRewards.subCap(originalCost);
arbitrator.appeal{value: originalCost}(disputeID, dispute.arbitratorExtraData);
}
msg.sender.send(msg.value.subCap(contribution)); // Sending extra value back to contributor. Send preferred over transfer deliberately.
return lastRound.hasPaid[_ruling];
}
|
function fundAppeal(uint256 _localDisputeID, uint256 _ruling) external payable override returns (bool fullyFunded) {
require(_ruling <= numberOfRulingOptions[_localDisputeID], "There is no such ruling to fund.");
DisputeStruct storage dispute = disputes[_localDisputeID];
uint256 disputeID = dispute.disputeIDOnArbitratorSide; // Intermediate variable to make reads cheaper.
uint256 originalCost;
uint256 totalCost;
{
uint256 currentRuling = arbitrator.currentRuling(disputeID); // Intermediate variable to make reads cheaper.
(originalCost, totalCost) = appealCost(disputeID, dispute.arbitratorExtraData, _ruling, currentRuling);
checkAppealPeriod(disputeID, _ruling, currentRuling); // Reverts if appeal period has been expired for _ruling.
}
Round[] storage rounds = disputeIDtoRoundArray[_localDisputeID];
uint256 lastRoundIndex = rounds.length - 1; // Intermediate variable to make reads cheaper.
Round storage lastRound = rounds[lastRoundIndex];
require(!lastRound.hasPaid[_ruling], "Appeal fee has already been paid.");
uint256 paidFeesInLastRound = lastRound.paidFees[_ruling]; // Intermediate variable to make reads cheaper.
uint256 contribution = totalCost.subCap(paidFeesInLastRound) > msg.value ? msg.value : totalCost.subCap(paidFeesInLastRound);
lastRound.paidFees[_ruling] += contribution;
emit Contribution(_localDisputeID, lastRoundIndex, _ruling, msg.sender, contribution);
lastRound.contributions[msg.sender][_ruling] += contribution;
paidFeesInLastRound = lastRound.paidFees[_ruling]; // Intermediate variable to make reads cheaper.
if (paidFeesInLastRound >= totalCost) {
lastRound.feeRewards += paidFeesInLastRound;
lastRound.fundedRulings.push(_ruling);
lastRound.hasPaid[_ruling] = true;
emit RulingFunded(_localDisputeID, lastRoundIndex, _ruling);
}
if (lastRound.fundedRulings.length == 2) {
// Two competing ruling options means we will have another appeal round.
rounds.push();
lastRound.feeRewards = lastRound.feeRewards.subCap(originalCost);
arbitrator.appeal{value: originalCost}(disputeID, dispute.arbitratorExtraData);
}
msg.sender.send(msg.value.subCap(contribution)); // Sending extra value back to contributor. Send preferred over transfer deliberately.
return lastRound.hasPaid[_ruling];
}
| 52,700
|
54
|
// Returns the Proxy for addr calls, and forwards all other requests to the name's resolver
|
function resolve(bytes calldata dnsName, bytes calldata data) external view returns (bytes memory) {
bytes4 sel = bytes4(data[0:4]);
// Handle the hatch.eth root
if (keccak256(dnsName) == keccak256(bytes(dnsHatch)) && data.length >= 36) {
// [ bytes4:selector ][ bytes32:namehash("hatch.eth") ]
require(bytes32(data[4:36]) == nodehashHatch);
// [ bytes4:selectoraddr(bytes32) ][ bytes32:namehash("hatch.eth") ]
if (data.length == 36 && sel == Resolver.addr.selector) {
return abi.encode(address(this));
}
// [ bytes4:selectoraddr(bytes32) ][ bytes32:namehash("hatch.eth") ][ uint:60 ]
if (data.length == 68 && sel == ResolverMulticoin.addr.selector) {
if (uint(bytes32(data[36:68])) == 60) {
return abi.encode(abi.encodePacked(address(this)));
}
}
// @TODO: Handle fun things like avatar
revert("todo");
//address resolver = ens.resolver(??);
//require(resolver != address(0));
//return resolver.call(abi.encodePacked(data[0:4], ownerNodehash, data[36:]));
}
// Length of the hatch owner label
uint length = uint8(dnsName[0]);
// Must match XXX.hatch.eth
require(keccak256(dnsName[1 + length:]) == keccak256(bytes(dnsHatch)), "unknown suffix");
// The hatch owner name and hash (e.g. ricmoo.hatch.eth => ricmoo.eth)
bytes memory ownerName = abi.encodePacked(dnsName[0: length + 1], "\x03eth\x00");
bytes32 ownerNodehash = namehash(ownerName);
// Hijack: addr(bytes32 nodehash) view returns (address)
// Returns the hatch address instead of returning the
// target resolver's address. [EIP-]
if (data.length == 36 && sel == Resolver.addr.selector) {
//require(namehash(dnsName) == bytes32(data[4:36]));
return abi.encode(_addressForNodehash(ownerNodehash));
}
// Hijack: addr(bytes32 nodehash, uint cointype) view returns (address)
// Returns the hatch address instead of returning the
// target resolver's address. [EIP-]
if (data.length == 68 && sel == ResolverMulticoin.addr.selector && uint(bytes32(data[36:68])) == 60) {
//require(namehash(dnsName) == bytes32(data[4:36]));
return abi.encode(abi.encodePacked(_addressForNodehash(ownerNodehash)));
}
// Forward the request to the actual resolver, replacing the nodehash
// with the owner nodehash
address resolver = AbstractENS(ens).resolver(ownerNodehash);
require(resolver != address(0));
// @TODO: Check for wildcard support and use resolve(bytes, bytes) instead
(bool status, bytes memory result) = resolver.staticcall(abi.encodePacked(data[0:4], ownerNodehash, data[36:]));
if (status) { revert("call reverted"); }
return result;
}
|
function resolve(bytes calldata dnsName, bytes calldata data) external view returns (bytes memory) {
bytes4 sel = bytes4(data[0:4]);
// Handle the hatch.eth root
if (keccak256(dnsName) == keccak256(bytes(dnsHatch)) && data.length >= 36) {
// [ bytes4:selector ][ bytes32:namehash("hatch.eth") ]
require(bytes32(data[4:36]) == nodehashHatch);
// [ bytes4:selectoraddr(bytes32) ][ bytes32:namehash("hatch.eth") ]
if (data.length == 36 && sel == Resolver.addr.selector) {
return abi.encode(address(this));
}
// [ bytes4:selectoraddr(bytes32) ][ bytes32:namehash("hatch.eth") ][ uint:60 ]
if (data.length == 68 && sel == ResolverMulticoin.addr.selector) {
if (uint(bytes32(data[36:68])) == 60) {
return abi.encode(abi.encodePacked(address(this)));
}
}
// @TODO: Handle fun things like avatar
revert("todo");
//address resolver = ens.resolver(??);
//require(resolver != address(0));
//return resolver.call(abi.encodePacked(data[0:4], ownerNodehash, data[36:]));
}
// Length of the hatch owner label
uint length = uint8(dnsName[0]);
// Must match XXX.hatch.eth
require(keccak256(dnsName[1 + length:]) == keccak256(bytes(dnsHatch)), "unknown suffix");
// The hatch owner name and hash (e.g. ricmoo.hatch.eth => ricmoo.eth)
bytes memory ownerName = abi.encodePacked(dnsName[0: length + 1], "\x03eth\x00");
bytes32 ownerNodehash = namehash(ownerName);
// Hijack: addr(bytes32 nodehash) view returns (address)
// Returns the hatch address instead of returning the
// target resolver's address. [EIP-]
if (data.length == 36 && sel == Resolver.addr.selector) {
//require(namehash(dnsName) == bytes32(data[4:36]));
return abi.encode(_addressForNodehash(ownerNodehash));
}
// Hijack: addr(bytes32 nodehash, uint cointype) view returns (address)
// Returns the hatch address instead of returning the
// target resolver's address. [EIP-]
if (data.length == 68 && sel == ResolverMulticoin.addr.selector && uint(bytes32(data[36:68])) == 60) {
//require(namehash(dnsName) == bytes32(data[4:36]));
return abi.encode(abi.encodePacked(_addressForNodehash(ownerNodehash)));
}
// Forward the request to the actual resolver, replacing the nodehash
// with the owner nodehash
address resolver = AbstractENS(ens).resolver(ownerNodehash);
require(resolver != address(0));
// @TODO: Check for wildcard support and use resolve(bytes, bytes) instead
(bool status, bytes memory result) = resolver.staticcall(abi.encodePacked(data[0:4], ownerNodehash, data[36:]));
if (status) { revert("call reverted"); }
return result;
}
| 41,629
|
190
|
// how much BNB did we just swap into?
|
uint256 newBalance = address(this).balance.sub(initialBalance);
|
uint256 newBalance = address(this).balance.sub(initialBalance);
| 7,822
|
80
|
// this is to be called periodically to distribute accumulated ETH rewards to project participants
|
function distributeRewards(address payable [] memory recepients, uint256 individualReward) public onlyRewardsDistributor() {
require(recepients.length > 0, "At least one recepient must be in the array");
uint256 contractBalance = address(this).balance;
uint256 suggestedReward = contractBalance.div(recepients.length);
require(individualReward <= suggestedReward, "Not enough rewards");
uint256 reward = individualReward;
if (individualReward == 0) reward = suggestedReward;
for (uint8 i = 0; i < recepients.length; i++) {
if (!recepients[i].isContract()) recepients[i].sendValue(reward);
}
emit RewardsDistributed(reward);
}
|
function distributeRewards(address payable [] memory recepients, uint256 individualReward) public onlyRewardsDistributor() {
require(recepients.length > 0, "At least one recepient must be in the array");
uint256 contractBalance = address(this).balance;
uint256 suggestedReward = contractBalance.div(recepients.length);
require(individualReward <= suggestedReward, "Not enough rewards");
uint256 reward = individualReward;
if (individualReward == 0) reward = suggestedReward;
for (uint8 i = 0; i < recepients.length; i++) {
if (!recepients[i].isContract()) recepients[i].sendValue(reward);
}
emit RewardsDistributed(reward);
}
| 23,660
|
52
|
// Returns true if the contract is paused, and false otherwise. /
|
function paused() public view virtual returns (bool) {
return _paused;
}
|
function paused() public view virtual returns (bool) {
return _paused;
}
| 456
|
2
|
// initiator is the one who initiates the htlc transaction
|
mapping(string => ContractData) initiators;
|
mapping(string => ContractData) initiators;
| 14,292
|
21
|
// Mints several tokens for various addresses./to Array of addresses of token future owners
|
function giveAway(address[] memory to) external onlyOwner {
for (uint256 i = 0; i < to.length; i++) {
giveAwayIdCount.increment();
_mint(to[i], giveAwayIdCount.current());
}
}
|
function giveAway(address[] memory to) external onlyOwner {
for (uint256 i = 0; i < to.length; i++) {
giveAwayIdCount.increment();
_mint(to[i], giveAwayIdCount.current());
}
}
| 5,228
|
910
|
// Edits the details of an existing proposal_proposalId Proposal id that details needs to be updated_proposalDescHash Proposal description hash having long and short description of proposal./
|
function updateProposal(
uint _proposalId,
string calldata _proposalTitle,
string calldata _proposalSD,
string calldata _proposalDescHash
)
external onlyProposalOwner(_proposalId)
|
function updateProposal(
uint _proposalId,
string calldata _proposalTitle,
string calldata _proposalSD,
string calldata _proposalDescHash
)
external onlyProposalOwner(_proposalId)
| 29,188
|
18
|
// Manage nodes
|
function addNode(address a) external onlyGov{
require(a != address(0), "VALUE_0");
require(nodes.length < MAX_ORACLE_NODES, "MAX_ORACLE_NODES");
for(uint i = 0; i < nodes.length; i++){
require(nodes[i] != a, "ALREADY_LISTED");
}
nodes.push(a);
emit NodeAdded(nodes.length - 1, a);
}
|
function addNode(address a) external onlyGov{
require(a != address(0), "VALUE_0");
require(nodes.length < MAX_ORACLE_NODES, "MAX_ORACLE_NODES");
for(uint i = 0; i < nodes.length; i++){
require(nodes[i] != a, "ALREADY_LISTED");
}
nodes.push(a);
emit NodeAdded(nodes.length - 1, a);
}
| 14,345
|
55
|
// Callback context For callbacks it is used to know which agreement function selector is called
|
bytes4 agreementSelector;
|
bytes4 agreementSelector;
| 4,479
|
47
|
// The board can only unlock someone's lock so that they can withdraw everything. A more robust system would allow a user to propose a modification to their payment schedule.
|
function resetTimeLock(address member)
external
onlyBoard
onlyMember(member)
returns (bool)
|
function resetTimeLock(address member)
external
onlyBoard
onlyMember(member)
returns (bool)
| 16,641
|
52
|
// transfer royalties
|
_send(payable(royaltyRecipient), royaltyAmount);
|
_send(payable(royaltyRecipient), royaltyAmount);
| 62,351
|
10
|
// burn the token
|
token.transferFrom(msg.sender, pltnmDepositoryWallet, cyclePrice);
if (expiryForAddress[msg.sender] < block.timestamp) {
expiryForAddress[msg.sender] = block.timestamp;
}
|
token.transferFrom(msg.sender, pltnmDepositoryWallet, cyclePrice);
if (expiryForAddress[msg.sender] < block.timestamp) {
expiryForAddress[msg.sender] = block.timestamp;
}
| 33,707
|
17
|
// StandardToken Standard ERC20 token /
|
contract StandardToken {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => uint256) internal balances_;
mapping(address => mapping(address => uint256)) internal allowed_;
uint256 internal totalSupply_;
string public name;
string public symbol;
uint8 public decimals;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed_ to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed_[_owner][_spender];
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances_[msg.sender]);
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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 uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
}
|
contract StandardToken {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => uint256) internal balances_;
mapping(address => mapping(address => uint256)) internal allowed_;
uint256 internal totalSupply_;
string public name;
string public symbol;
uint8 public decimals;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances_[_owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed_ to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed_[_owner][_spender];
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances_[msg.sender]);
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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 uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances_[_from]);
require(_value <= allowed_[_from][msg.sender]);
balances_[_from] = balances_[_from].sub(_value);
balances_[_to] = balances_[_to].add(_value);
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed_[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
}
| 41,357
|
121
|
// if any account belongs to _isExcludedFromFee account then remove the fee
|
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
|
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
| 6,103
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.