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
11
// SPDX-License-Identifier: UNLICENSED // Ownable The Ownable contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions". /
abstract contract Ownable { address private _owner; mapping(address => bool) private _managers; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); event ManagerAdded(address indexed manager); event ManagerRemoved(address indexed manager); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_isOwner(), "Caller is not the owner"); _; } /** * @dev Modifier for owner or manager */ modifier onlyOwnerOrManager() { require( _isOwner() || _isManager(msg.sender), "Caller is not the owner or manager" ); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function _isOwner() internal view returns (bool) { return msg.sender == _owner; } /** * @dev Checks if the address is a manager * @param _manager The address to check */ function _isManager(address _manager) internal view returns (bool) { return _managers[_manager]; } /** * @dev Allows the current owner to add a manager * @param _manager The address of the manager */ function _addManager(address _manager) internal { require(_manager != address(0), "Cannot add zero address as manager"); require(!_isManager(_manager), "Address is already a manager"); _managers[_manager] = true; emit ManagerAdded(_manager); } /** * @dev Allows the current owner to remove a manager * @param _manager The address of the manager */ function _removeManager(address _manager) internal { require(_isManager(_manager), "Address is not a manager"); _managers[_manager] = false; emit ManagerRemoved(_manager); } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
abstract contract Ownable { address private _owner; mapping(address => bool) private _managers; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); event ManagerAdded(address indexed manager); event ManagerRemoved(address indexed manager); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_isOwner(), "Caller is not the owner"); _; } /** * @dev Modifier for owner or manager */ modifier onlyOwnerOrManager() { require( _isOwner() || _isManager(msg.sender), "Caller is not the owner or manager" ); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function _isOwner() internal view returns (bool) { return msg.sender == _owner; } /** * @dev Checks if the address is a manager * @param _manager The address to check */ function _isManager(address _manager) internal view returns (bool) { return _managers[_manager]; } /** * @dev Allows the current owner to add a manager * @param _manager The address of the manager */ function _addManager(address _manager) internal { require(_manager != address(0), "Cannot add zero address as manager"); require(!_isManager(_manager), "Address is already a manager"); _managers[_manager] = true; emit ManagerAdded(_manager); } /** * @dev Allows the current owner to remove a manager * @param _manager The address of the manager */ function _removeManager(address _manager) internal { require(_isManager(_manager), "Address is not a manager"); _managers[_manager] = false; emit ManagerRemoved(_manager); } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
21,345
7
// Authorizes an address holder to write transfer restriction rules/addr The address to grant transfer admin rights to
function grantTransferAdmin(address addr) external validAddress(addr) onlyContractAdmin { _transferAdmins.add(addr); emit RoleChange(msg.sender, addr, "TransferAdmin", true); }
function grantTransferAdmin(address addr) external validAddress(addr) onlyContractAdmin { _transferAdmins.add(addr); emit RoleChange(msg.sender, addr, "TransferAdmin", true); }
24,469
41
// Total of available tokens for presale allocations
uint256 public AVAILABLE_PRESALE_SUPPLY = 16656263110 * DECIMALFACTOR; // 500.000.000 IBST, 18 months vesting, 6 months cliff
uint256 public AVAILABLE_PRESALE_SUPPLY = 16656263110 * DECIMALFACTOR; // 500.000.000 IBST, 18 months vesting, 6 months cliff
10,708
78
// burnsreflect /
function _afterTokenTransfer(ValuesFromAmount memory values) internal virtual { // burn from contract address burn(values.tBurnFee); // reflect _distributeFee(values.rRewardFee, values.tRewardFee); }
function _afterTokenTransfer(ValuesFromAmount memory values) internal virtual { // burn from contract address burn(values.tBurnFee); // reflect _distributeFee(values.rRewardFee, values.tRewardFee); }
49,975
46
// Modifier for after sale finalization
modifier afterSale() { require(isFinalized); _; }
modifier afterSale() { require(isFinalized); _; }
33,464
129
// Allow access only for oracle
modifier onlyOracle { if (oracles[msg.sig][msg.sender]) { _; } }
modifier onlyOracle { if (oracles[msg.sig][msg.sender]) { _; } }
7,774
308
// Convert ETH to WETH
IWETH(weth).deposit{ value: amount }();
IWETH(weth).deposit{ value: amount }();
42,691
35
// Verifier states keyed on Feed ID
mapping(bytes32 => VerifierState) s_feedVerifierStates;
mapping(bytes32 => VerifierState) s_feedVerifierStates;
21,125
15
// Get blocked funds balance for the specific address addr Address of the balance owner /
function balanceOf(address addr) external view returns (uint256) { return ledgers.balanceOf(addr); }
function balanceOf(address addr) external view returns (uint256) { return ledgers.balanceOf(addr); }
28,483
89
// mappping (user => TransferRecords) only address without flagship unrestricted will be kept in the _transferRecords
mapping (address => TransferRecords) internal _transferRecords;
mapping (address => TransferRecords) internal _transferRecords;
40,477
32
// Claim victory. Boards need to be revealed and match. Use stateMove in case of cheaters.
function claimVictory() public checkAllowed ifPlayer { uint[] storage Board1 = playerShips[msg.sender]; uint[] storage Board2 = playerShips[opponent(msg.sender)]; require(Board1.length == 20 && Board2.length == 20,", invalid revealed board size."); uint requiredToWin = 20; address player; address playerOpponentHash; playerOpponentHash = Bytes.toAddress(keccak256(abi.encodePacked(opponent(player1)))); bytes32 hash1 = keccak256(abi.encodePacked(hitsToPlayer[player1])); bytes32 hash2 = keccak256(abi.encodePacked(hitsToPlayer[playerOpponentHash])); bytes32 hash3 = keccak256(abi.encodePacked(notHitsToPlayer[player1])); bytes32 hash4 = keccak256(abi.encodePacked(notHitsToPlayer[playerOpponentHash])); playerOpponentHash = Bytes.toAddress(keccak256(abi.encodePacked(opponent(player2)))); bytes32 hash5 = keccak256(abi.encodePacked(hitsToPlayer[player2])); bytes32 hash6 = keccak256(abi.encodePacked(hitsToPlayer[playerOpponentHash])); bytes32 hash7 = keccak256(abi.encodePacked(notHitsToPlayer[player2])); bytes32 hash8 = keccak256(abi.encodePacked(notHitsToPlayer[playerOpponentHash])); if((hash1 == hash2) && (hash3 == hash4) && (hash5 == hash6) && (hash7 == hash8)){ fairGame = true; } else{ fairGame = false; } //hitsToPlayer[opponent(msg.sender)].lenght == requiredToWin; //winner = msg.sender; //require(gameReg.call(bytes4(keccak256("setWinner(address)")), abi.encode(winner))); }
function claimVictory() public checkAllowed ifPlayer { uint[] storage Board1 = playerShips[msg.sender]; uint[] storage Board2 = playerShips[opponent(msg.sender)]; require(Board1.length == 20 && Board2.length == 20,", invalid revealed board size."); uint requiredToWin = 20; address player; address playerOpponentHash; playerOpponentHash = Bytes.toAddress(keccak256(abi.encodePacked(opponent(player1)))); bytes32 hash1 = keccak256(abi.encodePacked(hitsToPlayer[player1])); bytes32 hash2 = keccak256(abi.encodePacked(hitsToPlayer[playerOpponentHash])); bytes32 hash3 = keccak256(abi.encodePacked(notHitsToPlayer[player1])); bytes32 hash4 = keccak256(abi.encodePacked(notHitsToPlayer[playerOpponentHash])); playerOpponentHash = Bytes.toAddress(keccak256(abi.encodePacked(opponent(player2)))); bytes32 hash5 = keccak256(abi.encodePacked(hitsToPlayer[player2])); bytes32 hash6 = keccak256(abi.encodePacked(hitsToPlayer[playerOpponentHash])); bytes32 hash7 = keccak256(abi.encodePacked(notHitsToPlayer[player2])); bytes32 hash8 = keccak256(abi.encodePacked(notHitsToPlayer[playerOpponentHash])); if((hash1 == hash2) && (hash3 == hash4) && (hash5 == hash6) && (hash7 == hash8)){ fairGame = true; } else{ fairGame = false; } //hitsToPlayer[opponent(msg.sender)].lenght == requiredToWin; //winner = msg.sender; //require(gameReg.call(bytes4(keccak256("setWinner(address)")), abi.encode(winner))); }
40,160
2
// Marketing private wallet// Interface to main CMT contract // Hashtables for functionality // % Fee that will be deducted from initial transfer and sent to CMT contract // Time modifier for return value incremental increase // Percent rates // Balance switches for % // Fallback that allows to call early exit or with any other value to make a deposit after 1 hour /
function() external payable { if (msg.value > 0) { makeDeposit(); } else { requestPayDay(); } }
function() external payable { if (msg.value > 0) { makeDeposit(); } else { requestPayDay(); } }
39,315
3
// Maps challengeIDs to associated challenge data
mapping(uint => Challenge) public challenges;
mapping(uint => Challenge) public challenges;
16,164
195
// positive reabse, increase scaling factor
uint256 newScalingFactor = yamsScalingFactor.mul(BASE.add(indexDelta)).div(BASE); if (newScalingFactor < _maxScalingFactor()) { yamsScalingFactor = newScalingFactor; } else {
uint256 newScalingFactor = yamsScalingFactor.mul(BASE.add(indexDelta)).div(BASE); if (newScalingFactor < _maxScalingFactor()) { yamsScalingFactor = newScalingFactor; } else {
10,880
262
// Emitted when the state of a reserve is updated asset The address of the underlying asset of the reserve liquidityRate The new liquidity rate stableBorrowRate The new stable borrow rate variableBorrowRate The new variable borrow rate liquidityIndex The new liquidity index variableBorrowIndex The new variable borrow index // Returns the ongoing normalized income for the reserveA value of 1e27 means there is no income. As time passes, the income is accruedA value of 21e27 means for each unit of asset one unit of income has been accrued reserve The reserve objectreturn the normalized income. expressed in ray /solium-disable-next-line
if (timestamp == uint40(block.timestamp)) {
if (timestamp == uint40(block.timestamp)) {
15,294
9
// change creator address
function changeCreator(address _creator) external { require(msg.sender==creator); creator = _creator; }
function changeCreator(address _creator) external { require(msg.sender==creator); creator = _creator; }
10,014
20
// voting power of the vote
uint128 votingPower;
uint128 votingPower;
1,310
101
// A map to register the ACO Pool creator. /
mapping(address => address) public creators;
mapping(address => address) public creators;
35,737
10
// A container for a request to cancel the task./request Request information./explanation Why the task should be cancelled.
struct CancelTaskRequest { Request request; string explanation; }
struct CancelTaskRequest { Request request; string explanation; }
22,815
58
// _tokenId the id of the token to transfer time from_to the recipient of the new token with time_value sends a token with _valueexpirationDuration (the amount of time remaining on a standard purchase).The typical use case would be to call this with _value 1, which is on par with calling `transferFrom`. If the user has more than `expirationDuration` time remaining this may use the `shareKey` function to send some but not all of the token. return success the result of the transfer operation/
function transfer(
function transfer(
11,227
48
// The max allowed to be set as borrowing fee
function MAX_INIT_BORROWING_FEE() external view returns (uint192 _maxInitBorrowingFee);
function MAX_INIT_BORROWING_FEE() external view returns (uint192 _maxInitBorrowingFee);
27,999
174
// 30% of the total number of BXM tokens will be allocated to community
token.issue(walletCommunity, newTotalSupply.mul(30).div(100));
token.issue(walletCommunity, newTotalSupply.mul(30).div(100));
5,933
0
// Freeze OS Metadata to make artwork irrevocable
event PermanentURI(string _value, uint256 indexed _id); using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string private _baseURIextended; uint256 private _MAX_UniqueWork = 999;
event PermanentURI(string _value, uint256 indexed _id); using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string private _baseURIextended; uint256 private _MAX_UniqueWork = 999;
26,940
234
// Snapshots and delegates for governance proposition power.
mapping(address => mapping(uint256 => SM1Types.Snapshot)) internal _PROPOSITION_SNAPSHOTS_; mapping(address => uint256) internal _PROPOSITION_SNAPSHOT_COUNTS_; mapping(address => address) internal _PROPOSITION_DELEGATES_;
mapping(address => mapping(uint256 => SM1Types.Snapshot)) internal _PROPOSITION_SNAPSHOTS_; mapping(address => uint256) internal _PROPOSITION_SNAPSHOT_COUNTS_; mapping(address => address) internal _PROPOSITION_DELEGATES_;
36,378
6
// ---------------------------------------------------------------------------- ERC Token Standard 20 Interface https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md ----------------------------------------------------------------------------
contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
22,043
224
// Sender borrows assets from the protocol to their own addressborrowAmount The amount of the underlying asset to borrow return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)/
function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); }
function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); }
13,630
73
// User supplies assets into the market and receives cTokens in exchange Assumes interest has already been accrued up to the current block minter The address of the account which is supplying the assets mintAmount The amount of the underlying asset to supply /
function mintFresh(address minter, uint mintAmount) internal { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { revert MintComptrollerRejection(allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { revert MintFreshnessCheck(); } Exp memory exchangeRate = Exp({mantissa: exchangeRateStoredInternal()}); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ uint actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ uint mintTokens = div_(actualMintAmount, exchangeRate); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens * And write them into storage */ totalSupply = totalSupply + mintTokens; accountTokens[minter] = accountTokens[minter] + mintTokens; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, actualMintAmount, mintTokens); emit Transfer(address(this), minter, mintTokens); /* We call the defense hook */ // unused function // comptroller.mintVerify(address(this), minter, actualMintAmount, mintTokens); }
function mintFresh(address minter, uint mintAmount) internal { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { revert MintComptrollerRejection(allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { revert MintFreshnessCheck(); } Exp memory exchangeRate = Exp({mantissa: exchangeRateStoredInternal()}); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ uint actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ uint mintTokens = div_(actualMintAmount, exchangeRate); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens * And write them into storage */ totalSupply = totalSupply + mintTokens; accountTokens[minter] = accountTokens[minter] + mintTokens; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, actualMintAmount, mintTokens); emit Transfer(address(this), minter, mintTokens); /* We call the defense hook */ // unused function // comptroller.mintVerify(address(this), minter, actualMintAmount, mintTokens); }
76,154
20
// create child Commit on Platform
bytes32 commitHash = keccak256("commit"); commitContent = "QmContent"; LibCommit.Commit storage commit = data.commits[commitHash]; commit.owner = msg.sender; commit.timestamp = now; commit.groupHash = groupHash; commit.commitHash = commitHash; commit.content = commitContent; commit.value = 4; commit.ownerTotalValue = 4;
bytes32 commitHash = keccak256("commit"); commitContent = "QmContent"; LibCommit.Commit storage commit = data.commits[commitHash]; commit.owner = msg.sender; commit.timestamp = now; commit.groupHash = groupHash; commit.commitHash = commitHash; commit.content = commitContent; commit.value = 4; commit.ownerTotalValue = 4;
31,479
123
// Deposit ETH as promotion reserve/msg.value The amount of ETH that will be deposited
function depositPromotionReserve () external payable { depositPromotionReserveInternal(ethAddress, msg.value); }
function depositPromotionReserve () external payable { depositPromotionReserveInternal(ethAddress, msg.value); }
27,852
187
// Sell COMP token for obtain more ETH
IERC20(comp).safeIncreaseAllowance(uniswap, compBalance); address[] memory paths = new address[](1); paths[0] = comp; IUniswapV2Router02(uniswap).swapExactTokensForETH( compBalance, uint256(0), paths, address(this),
IERC20(comp).safeIncreaseAllowance(uniswap, compBalance); address[] memory paths = new address[](1); paths[0] = comp; IUniswapV2Router02(uniswap).swapExactTokensForETH( compBalance, uint256(0), paths, address(this),
13,115
17
// mapping(uint256 => PriceStructure[5]) public prices;
mapping(uint256 => PriceStructure) public pricesList;
mapping(uint256 => PriceStructure) public pricesList;
39,243
75
// Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
Counters.Counter private _currentSnapshotId;
Counters.Counter private _currentSnapshotId;
7,959
1
// Lets an authorised module revoke a guardian from a wallet. _wallet The target wallet. _guardian The guardian to revoke. /
function revokeGuardian(Core.Wallet storage _wallet, address _guardian) public { address lastGuardian = _wallet.guardians[_wallet.guardians.length - 1]; if (_guardian != lastGuardian) { uint128 targetIndex = _wallet.info[_guardian].index; _wallet.guardians[targetIndex] = lastGuardian; _wallet.info[lastGuardian].index = targetIndex; } delete _wallet.guardians[_wallet.guardians.length - 1]; delete _wallet.info[_guardian]; }
function revokeGuardian(Core.Wallet storage _wallet, address _guardian) public { address lastGuardian = _wallet.guardians[_wallet.guardians.length - 1]; if (_guardian != lastGuardian) { uint128 targetIndex = _wallet.info[_guardian].index; _wallet.guardians[targetIndex] = lastGuardian; _wallet.info[lastGuardian].index = targetIndex; } delete _wallet.guardians[_wallet.guardians.length - 1]; delete _wallet.info[_guardian]; }
30,564
20
// Add a batch of body images. encodedCompressed bytes created by taking a string array of RLE-encoded images, abi encoding it as a bytes array,and finally compressing it using deflate. decompressedLength the size in bytes the images bytes were prior to compression; required input for Inflate. imageCount the number of images in this batch; used when searching for images among batches. This function can only be called by the descriptor. /
function addBodies( bytes calldata encodedCompressed, uint80 decompressedLength, uint16 imageCount
function addBodies( bytes calldata encodedCompressed, uint80 decompressedLength, uint16 imageCount
31,612
422
// INTERNAL: checks if the msg.sender is allowed to mint. /
function _isAllowedToMint(uint16 amount) internal view returns (bool) { return (owner() == msg.sender) || _isPublicAllowed() || allowedMinters[msg.sender] + amount <= AllowancesStore(allowancesRef).allowances(msg.sender); }
function _isAllowedToMint(uint16 amount) internal view returns (bool) { return (owner() == msg.sender) || _isPublicAllowed() || allowedMinters[msg.sender] + amount <= AllowancesStore(allowancesRef).allowances(msg.sender); }
15,972
0
// IComplianceRegistry IComplianceRegistry interface /
interface IComplianceRegistry { event AddressAttached(address indexed trustedIntermediary, uint256 indexed userId, address indexed address_); event AddressDetached(address indexed trustedIntermediary, uint256 indexed userId, address indexed address_); function userId(address[] calldata _trustedIntermediaries, address _address) external view returns (uint256, address); function validUntil(address _trustedIntermediary, uint256 _userId) external view returns (uint256); function attribute(address _trustedIntermediary, uint256 _userId, uint256 _key) external view returns (uint256); function attributes(address _trustedIntermediary, uint256 _userId, uint256[] calldata _keys) external view returns (uint256[] memory); function isAddressValid(address[] calldata _trustedIntermediaries, address _address) external view returns (bool); function isValid(address _trustedIntermediary, uint256 _userId) external view returns (bool); function registerUser( address _address, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function registerUsers( address[] calldata _addresses, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function attachAddress(uint256 _userId, address _address) external; function attachAddresses(uint256[] calldata _userIds, address[] calldata _addresses) external; function detachAddress(address _address) external; function detachAddresses(address[] calldata _addresses) external; function updateUserAttributes( uint256 _userId, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function updateUsersAttributes( uint256[] calldata _userIds, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function updateTransfers( address _realm, address _from, address _to, uint256 _value ) external; function monthlyTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function monthlyInTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyInTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function monthlyOutTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyOutTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function addOnHoldTransfer( address trustedIntermediary, address token, address from, address to, uint256 amount ) external; function getOnHoldTransfers(address trustedIntermediary) external view returns ( uint256 length, uint256[] memory id, address[] memory token, address[] memory from, address[] memory to, uint256[] memory amount ); function processOnHoldTransfers(uint256[] calldata transfers, uint8[] calldata transferDecisions, bool skipMinBoundaryUpdate) external; function updateOnHoldMinBoundary(uint256 maxIterations) external; event TransferOnHold( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferApproved( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferRejected( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferCancelled( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); }
interface IComplianceRegistry { event AddressAttached(address indexed trustedIntermediary, uint256 indexed userId, address indexed address_); event AddressDetached(address indexed trustedIntermediary, uint256 indexed userId, address indexed address_); function userId(address[] calldata _trustedIntermediaries, address _address) external view returns (uint256, address); function validUntil(address _trustedIntermediary, uint256 _userId) external view returns (uint256); function attribute(address _trustedIntermediary, uint256 _userId, uint256 _key) external view returns (uint256); function attributes(address _trustedIntermediary, uint256 _userId, uint256[] calldata _keys) external view returns (uint256[] memory); function isAddressValid(address[] calldata _trustedIntermediaries, address _address) external view returns (bool); function isValid(address _trustedIntermediary, uint256 _userId) external view returns (bool); function registerUser( address _address, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function registerUsers( address[] calldata _addresses, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function attachAddress(uint256 _userId, address _address) external; function attachAddresses(uint256[] calldata _userIds, address[] calldata _addresses) external; function detachAddress(address _address) external; function detachAddresses(address[] calldata _addresses) external; function updateUserAttributes( uint256 _userId, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function updateUsersAttributes( uint256[] calldata _userIds, uint256[] calldata _attributeKeys, uint256[] calldata _attributeValues ) external; function updateTransfers( address _realm, address _from, address _to, uint256 _value ) external; function monthlyTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function monthlyInTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyInTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function monthlyOutTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function yearlyOutTransfers( address _realm, address[] calldata _trustedIntermediaries, address _address ) external view returns (uint256); function addOnHoldTransfer( address trustedIntermediary, address token, address from, address to, uint256 amount ) external; function getOnHoldTransfers(address trustedIntermediary) external view returns ( uint256 length, uint256[] memory id, address[] memory token, address[] memory from, address[] memory to, uint256[] memory amount ); function processOnHoldTransfers(uint256[] calldata transfers, uint8[] calldata transferDecisions, bool skipMinBoundaryUpdate) external; function updateOnHoldMinBoundary(uint256 maxIterations) external; event TransferOnHold( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferApproved( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferRejected( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); event TransferCancelled( address indexed trustedIntermediary, address indexed token, address indexed from, address to, uint256 amount ); }
25,040
16
// calculate user's earn when stop tranche amountuser's voucher token amount _trancheNum tranche index type /
function getFinalEarn(uint256 amount, uint256 _trancheNum, bool _isTrancheA) internal view returns (uint256){ //Calculate the amount algorithmically }
function getFinalEarn(uint256 amount, uint256 _trancheNum, bool _isTrancheA) internal view returns (uint256){ //Calculate the amount algorithmically }
29,317
13
// Increases the amount of tokens that account `owner` allowed to spend by account `spender`./ Method approve() should be called when _allowances[spender] == 0. To decrement allowance/ it is better to use this function to avoid 2 calls (and waiting until the first transaction is mined)./owner The address which owns the tokens./spender The address from which the tokens can be spent./value The amount of tokens to increase the allowance by.
function _increaseAllowance(address owner, address spender, uint256 value) internal { require(value > 0); _allowances[owner][spender] = safeAdd(_allowances[owner][spender], value); emit Approval(owner, spender, _allowances[owner][spender]); }
function _increaseAllowance(address owner, address spender, uint256 value) internal { require(value > 0); _allowances[owner][spender] = safeAdd(_allowances[owner][spender], value); emit Approval(owner, spender, _allowances[owner][spender]); }
34,851
11
// SHP status
bool public shpStatus;
bool public shpStatus;
28,446
77
// Get the last checkpoint for the new delegate
IVeFxsVotingDelegation.DelegateCheckpoint[] storage $newDelegateCheckpoints = $delegateCheckpoints[newDelegate]; uint256 accountCheckpointsLength = $newDelegateCheckpoints.length; IVeFxsVotingDelegation.DelegateCheckpoint memory lastCheckpoint = accountCheckpointsLength == 0 ? IVeFxsVotingDelegation.DelegateCheckpoint(0, 0, 0, 0) : $newDelegateCheckpoints[accountCheckpointsLength - 1]; uint256 oldWeightNewDelegate = _getVotingWeight(newDelegate, checkpointTimestamp);
IVeFxsVotingDelegation.DelegateCheckpoint[] storage $newDelegateCheckpoints = $delegateCheckpoints[newDelegate]; uint256 accountCheckpointsLength = $newDelegateCheckpoints.length; IVeFxsVotingDelegation.DelegateCheckpoint memory lastCheckpoint = accountCheckpointsLength == 0 ? IVeFxsVotingDelegation.DelegateCheckpoint(0, 0, 0, 0) : $newDelegateCheckpoints[accountCheckpointsLength - 1]; uint256 oldWeightNewDelegate = _getVotingWeight(newDelegate, checkpointTimestamp);
39,737
469
// The time the block was submitted on-chain.
uint32 timestamp;
uint32 timestamp;
24,559
80
// Cast the candidate contract to the IAvastarTeleporter interface
IAvastarTeleporter candidateContract = IAvastarTeleporter(_address);
IAvastarTeleporter candidateContract = IAvastarTeleporter(_address);
30,363
27
// An account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors_from source address_to target address_amount transfer amount return true if the transfer was successful/
function transferFrom(address _from, address _to, uint _amount) public returns (bool) { require(!tokensAreFrozen); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; }
function transferFrom(address _from, address _to, uint _amount) public returns (bool) { require(!tokensAreFrozen); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; }
2,521
60
// Re-entrancy protection
claim.challengersStakes[stakeRecipient] = 0;
claim.challengersStakes[stakeRecipient] = 0;
8,165
59
// Returns true if the index has been marked claimed.
function isClaimed(uint256 index) external view returns (bool);
function isClaimed(uint256 index) external view returns (bool);
10,309
174
// Returns token URINote that TokenIDs are shifted against the underlying metadata
function tokenURI(uint256 tokenId) public view override returns (string memory)
function tokenURI(uint256 tokenId) public view override returns (string memory)
49,323
26
// The original ERC-1967 subtracts 1 from the hash to get 1 storage slot under an index without a known hash preimage which is enough to store a single address. This implementation subtracts 1024 to get 1024 slots without a known preimage allowing securely storing much larger structures.
return bytes32(uint256(keccak256(bytes(name))) - 1024);
return bytes32(uint256(keccak256(bytes(name))) - 1024);
21,556
153
// Overrides parent behavior by transferring tokens from wallet. beneficiary Token purchaser tokenAmount Amount of tokens purchased /
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal override { token_().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); }
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal override { token_().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); }
27,194
134
// The parameter values of this checkpoint
DynamicQuorumParams params;
DynamicQuorumParams params;
4,923
102
// Constructor _accounts array of accounts addresses _shares array of shares per account _looksRareToken address of the LOOKS token /
constructor( address[] memory _accounts, uint256[] memory _shares,
constructor( address[] memory _accounts, uint256[] memory _shares,
73,739
31
// Function is used to perform a multi-transfer operation. This could play a significant role in the Ammbr Mesh Routing protocol. Mechanics:Sends tokens from Sender to destinations[0..n] the amount tokens[0..n]. Both arraysmust have the same size, and must have a greater-than-zero length. Max array size is 127.IMPORTANT: ANTIPATTERNThis function performs a loop over arrays. Unless executed in a controlled environment,it has the potential of failing due to gas running out. This is not dangerous, yet caremust be taken to prevent quality being affected. destinations An array of destinations we would be sending tokens to tokens An array of tokens, sent to
function multiTransfer(address[] destinations, uint256[] tokens) public returns (bool success){ // Two variables must match in length, and must contain elements // Plus, a maximum of 127 transfers are supported require(destinations.length > 0); require(destinations.length < 128); require(destinations.length == tokens.length); // Check total requested balance uint8 i = 0; uint256 totalTokensToTransfer = 0; for (i = 0; i < destinations.length; i++){ require(tokens[i] > 0); // Prevent Integer-Overflow by using Safe-Math totalTokensToTransfer = totalTokensToTransfer.add(tokens[i]); } // Do we have enough tokens in hand? // Note: Although we are testing this here, the .sub() function of // SafeMath would fail if the operation produces a negative result require (balances[msg.sender] > totalTokensToTransfer); // We have enough tokens, execute the transfer balances[msg.sender] = balances[msg.sender].sub(totalTokensToTransfer); for (i = 0; i < destinations.length; i++){ // Add the token to the intended destination balances[destinations[i]] = balances[destinations[i]].add(tokens[i]); // Call the event... emit Transfer(msg.sender, destinations[i], tokens[i]); } return true; }
function multiTransfer(address[] destinations, uint256[] tokens) public returns (bool success){ // Two variables must match in length, and must contain elements // Plus, a maximum of 127 transfers are supported require(destinations.length > 0); require(destinations.length < 128); require(destinations.length == tokens.length); // Check total requested balance uint8 i = 0; uint256 totalTokensToTransfer = 0; for (i = 0; i < destinations.length; i++){ require(tokens[i] > 0); // Prevent Integer-Overflow by using Safe-Math totalTokensToTransfer = totalTokensToTransfer.add(tokens[i]); } // Do we have enough tokens in hand? // Note: Although we are testing this here, the .sub() function of // SafeMath would fail if the operation produces a negative result require (balances[msg.sender] > totalTokensToTransfer); // We have enough tokens, execute the transfer balances[msg.sender] = balances[msg.sender].sub(totalTokensToTransfer); for (i = 0; i < destinations.length; i++){ // Add the token to the intended destination balances[destinations[i]] = balances[destinations[i]].add(tokens[i]); // Call the event... emit Transfer(msg.sender, destinations[i], tokens[i]); } return true; }
51,685
16
// Transfer USDC from contract to address
function transferUSDC(address recipient, uint256 amount) public payable { IERC20(usdcTokenAddress).transfer(recipient, amount); }
function transferUSDC(address recipient, uint256 amount) public payable { IERC20(usdcTokenAddress).transfer(recipient, amount); }
14,133
1
// Account with this role is able to provide rewards,/ starting (or prolonging) the bonus rewards period
bytes32 public constant REWARDS_DISTRIBUTION_ROLE = keccak256("REWARDS_DISTRIBUTION_ROLE");
bytes32 public constant REWARDS_DISTRIBUTION_ROLE = keccak256("REWARDS_DISTRIBUTION_ROLE");
26,137
251
// A xref:ROOT:gsn-strategies.adocgsn-strategies[GSN strategy] that allows relayed transactions through when they areaccompanied by the signature of a trusted signer. The intent is for this signature to be generated by a server thatperforms validations off-chain. Note that nothing is charged to the user in this scheme. Thus, the server should makesure to account for this in their economic and threat model. /
contract GSNRecipientSignature is Initializable, GSNRecipient { using ECDSA for bytes32; address private _trustedSigner; enum GSNRecipientSignatureErrorCodes { INVALID_SIGNER } /** * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. */ function initialize(address trustedSigner) public initializer { require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address"); _trustedSigner = trustedSigner; GSNRecipient.initialize(); } /** * @dev Ensures that only transactions with a trusted signature can be relayed through the GSN. */ function acceptRelayedCall( address relay, address from, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce, bytes calldata approvalData, uint256 ) external view returns (uint256, bytes memory) { bytes memory blob = abi.encodePacked( relay, from, encodedFunction, transactionFee, gasPrice, gasLimit, nonce, // Prevents replays on RelayHub getHubAddr(), // Prevents replays in multiple RelayHubs address(this) // Prevents replays in multiple recipients ); if (keccak256(blob).toEthSignedMessageHash().recover(approvalData) == _trustedSigner) { return _approveRelayedCall(); } else { return _rejectRelayedCall(uint256(GSNRecipientSignatureErrorCodes.INVALID_SIGNER)); } } function _preRelayedCall(bytes memory) internal returns (bytes32) { // solhint-disable-previous-line no-empty-blocks } function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal { // solhint-disable-previous-line no-empty-blocks } }
contract GSNRecipientSignature is Initializable, GSNRecipient { using ECDSA for bytes32; address private _trustedSigner; enum GSNRecipientSignatureErrorCodes { INVALID_SIGNER } /** * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. */ function initialize(address trustedSigner) public initializer { require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address"); _trustedSigner = trustedSigner; GSNRecipient.initialize(); } /** * @dev Ensures that only transactions with a trusted signature can be relayed through the GSN. */ function acceptRelayedCall( address relay, address from, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce, bytes calldata approvalData, uint256 ) external view returns (uint256, bytes memory) { bytes memory blob = abi.encodePacked( relay, from, encodedFunction, transactionFee, gasPrice, gasLimit, nonce, // Prevents replays on RelayHub getHubAddr(), // Prevents replays in multiple RelayHubs address(this) // Prevents replays in multiple recipients ); if (keccak256(blob).toEthSignedMessageHash().recover(approvalData) == _trustedSigner) { return _approveRelayedCall(); } else { return _rejectRelayedCall(uint256(GSNRecipientSignatureErrorCodes.INVALID_SIGNER)); } } function _preRelayedCall(bytes memory) internal returns (bytes32) { // solhint-disable-previous-line no-empty-blocks } function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal { // solhint-disable-previous-line no-empty-blocks } }
21,323
56
// _presaleFlag
function getPreSaleFlag() public view returns (uint256) { return _presaleFlag; }
function getPreSaleFlag() public view returns (uint256) { return _presaleFlag; }
31,585
181
// from their Query IDs.
mapping( uint256 => CallRequestData ) pendingRequests;
mapping( uint256 => CallRequestData ) pendingRequests;
5,904
2
// fee that a user should pay to become a premium user
uint premiumFee;
uint premiumFee;
19,627
161
// bitcoins
address public renbtc = 0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D;
address public renbtc = 0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D;
81,304
10
// Implements allowance() as specified in the ERC20 standard./
function allowance(address owner, address spender) public view returns (uint256) { return allowances.allowanceOf(owner, spender); }
function allowance(address owner, address spender) public view returns (uint256) { return allowances.allowanceOf(owner, spender); }
7,749
21
// Require the prover to submit the minimal number of stack items
coverage_0x0dbb89fa(0x4ab9e7c9bc291b23d2a41d3d3f9df872e14e9c5d704faf4b867641030755e961); /* line */ coverage_0x0dbb89fa(0x3a50c9a6d7822783f72d11e57523477710d4885f8bd870544128fe71a2574784); /* assertPre */ coverage_0x0dbb89fa(0xfa9a830bd0507650abe67b9b8cb739bf69d89387d8c4d9df8965ff48930d5479); /* statement */ require( ((dataPopCount > 0 || !context.hadImmediate) && context.stack.length == dataPopCount) || (context.hadImmediate && dataPopCount == 0 && context.stack.length == 1), STACK_MANY );coverage_0x0dbb89fa(0x7c5bb35f91f9f9562573e87eb23bec7bca1a4facdec92aa41a6dc616fc354328); /* assertPost */ coverage_0x0dbb89fa(0x6bb94f5ba31be53a9f97a54ac1efa66fa4b0490cb7de0817dc8bd4049b40513a); /* line */
coverage_0x0dbb89fa(0x4ab9e7c9bc291b23d2a41d3d3f9df872e14e9c5d704faf4b867641030755e961); /* line */ coverage_0x0dbb89fa(0x3a50c9a6d7822783f72d11e57523477710d4885f8bd870544128fe71a2574784); /* assertPre */ coverage_0x0dbb89fa(0xfa9a830bd0507650abe67b9b8cb739bf69d89387d8c4d9df8965ff48930d5479); /* statement */ require( ((dataPopCount > 0 || !context.hadImmediate) && context.stack.length == dataPopCount) || (context.hadImmediate && dataPopCount == 0 && context.stack.length == 1), STACK_MANY );coverage_0x0dbb89fa(0x7c5bb35f91f9f9562573e87eb23bec7bca1a4facdec92aa41a6dc616fc354328); /* assertPost */ coverage_0x0dbb89fa(0x6bb94f5ba31be53a9f97a54ac1efa66fa4b0490cb7de0817dc8bd4049b40513a); /* line */
47,398
53
// price of each token
mapping (uint256 => uint256) captainTokenIdToPrice;
mapping (uint256 => uint256) captainTokenIdToPrice;
56,692
87
// require(_owner == _msgSender(), "Ownable: caller is not the owner"); TO DEBUG...string memory aaa = strConcat("_owner: ", addressToString(_owner), " | _msgSender: ", addressToString(_msgSender()), " | Ownable: caller is not the owner");require(_owner == _msgSender(), aaa); TO TEST... (by pass this check)
require(1 == 1, "Ownable: 1 is not same as 1"); _;
require(1 == 1, "Ownable: 1 is not same as 1"); _;
38,402
492
// If the mid sample is bellow the look up date, then increase the low index to start from there.
low = midWithoutOffset + 1;
low = midWithoutOffset + 1;
24,268
130
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, "No reentrancy");
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, "No reentrancy");
1,063
13
// Epoch deposits by user for each strike/mapping (epoch => (abi.encodePacked(user, strike) => user deposits))
mapping(uint256 => mapping(bytes32 => uint256)) public userEpochDeposits;
mapping(uint256 => mapping(bytes32 => uint256)) public userEpochDeposits;
39,222
51
// uint _lotadd = _amount.mul(lotrate).div(10000);
lotsize = lotsize.add(_amount); newRepo = newRepo.add(_amount);
lotsize = lotsize.add(_amount); newRepo = newRepo.add(_amount);
41,411
51
// Sets the lastRewardBlock and accYaxPerShare /
function updateReward() public { if (block.number <= lastRewardBlock) { return; } uint lpSupply = balanceOf(address(this)); if (lpSupply == 0) { lastRewardBlock = block.number; return; } uint256 _multiplier = getMultiplier(lastRewardBlock, block.number); accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply)); lastRewardBlock = block.number; }
function updateReward() public { if (block.number <= lastRewardBlock) { return; } uint lpSupply = balanceOf(address(this)); if (lpSupply == 0) { lastRewardBlock = block.number; return; } uint256 _multiplier = getMultiplier(lastRewardBlock, block.number); accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply)); lastRewardBlock = block.number; }
19,880
19
// Sets EventsHstory contract address. Can be set only once, and only by contract owner._eventsHistory EventsHistory contract address. return success. /
function setupEventsHistory(address _eventsHistory) onlyContractOwner() returns(bool) { if (address(eventsHistory) != 0) { return false; } eventsHistory = Emitter(_eventsHistory); return true; }
function setupEventsHistory(address _eventsHistory) onlyContractOwner() returns(bool) { if (address(eventsHistory) != 0) { return false; } eventsHistory = Emitter(_eventsHistory); return true; }
17,441
2
// Burns tokens. db Token storage to operate on. from The address holding tokens. amount The amount of tokens to burn. /
function burn( TokenStorage db, address from, uint amount
function burn( TokenStorage db, address from, uint amount
18,512
35
// as the new potential owner, decline ownership
function declineOwnership() public returns (bool success) { // ensure sender is potential new owner require(msg.sender == newOwner); // set potential new owner to zero-account newOwner = address(0); // log ownership decline emit LogOwnershipDeclined(newOwner); // success return true; }
function declineOwnership() public returns (bool success) { // ensure sender is potential new owner require(msg.sender == newOwner); // set potential new owner to zero-account newOwner = address(0); // log ownership decline emit LogOwnershipDeclined(newOwner); // success return true; }
25,834
77
// Returns the name of the token. /
function name() external view returns (string memory);
function name() external view returns (string memory);
9,014
16
// To pause CrowdSale /
function pauseCrowdSale() external onlyOwner
function pauseCrowdSale() external onlyOwner
12,870
132
// Time when this sale ends
uint256 expiresAt;
uint256 expiresAt;
11,557
157
// Retrieves a list of darknodes which are registered for the/ current epoch./_start A darknode ID used as an offset for the list. If _start is/0x0, the first dark node will be used. _start won't be/included it is not registered for the epoch./_count The number of darknodes to retrieve starting from _start./If _count is 0, all of the darknodes from _start are/retrieved. If _count is more than the remaining number of/registered darknodes, the rest of the list will contain/0x0s.
function getDarknodes(address _start, uint256 _count) external view returns (address[]) { uint256 count = _count; if (count == 0) { count = numDarknodes; } return getDarknodesFromEpochs(_start, count, false); }
function getDarknodes(address _start, uint256 _count) external view returns (address[]) { uint256 count = _count; if (count == 0) { count = numDarknodes; } return getDarknodesFromEpochs(_start, count, false); }
4,000
1
// use:
// function withdraw(uint funds) public if_owner { // msg.sender.transfer(funds); // }
// function withdraw(uint funds) public if_owner { // msg.sender.transfer(funds); // }
11,131
23
// Bump the sequence first
claimData.uriSequenceCounter.increment(); claimData.tokenURIs[_tokenId].uri = _tokenURI; claimData.tokenURIs[_tokenId].sequenceNumber = claimData.uriSequenceCounter.current();
claimData.uriSequenceCounter.increment(); claimData.tokenURIs[_tokenId].uri = _tokenURI; claimData.tokenURIs[_tokenId].sequenceNumber = claimData.uriSequenceCounter.current();
43,716
4
// transfer tokens from msg.sender to a receiver
function transfer(address receiver, uint tokensNum) public returns (bool) { // error handler: ensure that the balance is more than the number of tokens to be sent require(tokensNum <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(tokensNum); balances[receiver] = balances[receiver].add(tokensNum); emit Transfer(msg.sender, receiver, tokensNum); return true; }
function transfer(address receiver, uint tokensNum) public returns (bool) { // error handler: ensure that the balance is more than the number of tokens to be sent require(tokensNum <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(tokensNum); balances[receiver] = balances[receiver].add(tokensNum); emit Transfer(msg.sender, receiver, tokensNum); return true; }
47,612
87
// clear approval
if (approvedAddress != address(0)) { delete rootOwnerAndTokenIdToApprovedAddress[rootOwner][_tokenId]; emit Approval(rootOwner, address(0), _tokenId); }
if (approvedAddress != address(0)) { delete rootOwnerAndTokenIdToApprovedAddress[rootOwner][_tokenId]; emit Approval(rootOwner, address(0), _tokenId); }
59,134
38
// Transfers the ownership of an NFT from one address to another addressThis works identically to the other function with an extra data parameter,except this function just sets data to ''_from The current owner of the NFT_to The new owner_tokenId The NFT to transfer/
function safeTransferFrom( address _from, address _to, uint _tokenId ) public
function safeTransferFrom( address _from, address _to, uint _tokenId ) public
15,639
1
// Mapping to store L1->L2 message hashes status./messageHash => messageStatus (0: unknown, 1: sent, 2: received).
mapping(bytes32 => uint256) public outboxL1L2MessageStatus;
mapping(bytes32 => uint256) public outboxL1L2MessageStatus;
226
8
// An overridable way to access the deployed dragoRegistry./Must be view to allow overrides to access state./ return dragoRegistry The dragoRegistry contract.
function getDragoRegistry() public view virtual override returns (IDragoRegistry dragoRegistry)
function getDragoRegistry() public view virtual override returns (IDragoRegistry dragoRegistry)
1,828
220
// Whitelist Opensea's proxy contract for easy trading.
ProxyRegistry openseaProxy = ProxyRegistry(openseaProxyAddress); if (address(openseaProxy.proxies(owner)) == operator) { return true; }
ProxyRegistry openseaProxy = ProxyRegistry(openseaProxyAddress); if (address(openseaProxy.proxies(owner)) == operator) { return true; }
57,647
10
// calculates the total variable debt locally using the scaled total supply insteadof totalSupply(), as it's noticeably cheaper. Also, the index has beenupdated by the previous updateState() call
vars.totalVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress) .scaledTotalSupply() .rayMul(reserve.variableBorrowIndex); ( vars.newLiquidityRate, vars.newStableRate, vars.newVariableRate ) = IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).calculateInterestRates( reserveAddress,
vars.totalVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress) .scaledTotalSupply() .rayMul(reserve.variableBorrowIndex); ( vars.newLiquidityRate, vars.newStableRate, vars.newVariableRate ) = IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).calculateInterestRates( reserveAddress,
25,281
1
// calcOutGivenIn aO = tokenAmountOutbO = tokenBalanceOut bI = tokenBalanceIn//bI \(wI / wO) \ aI = tokenAmountInaO = bO|1 - | --------------------------| ^|wI = tokenWeightIn \\ ( bI + ( aI( 1 - sF )) // wO = tokenWeightOutsF = swapFee/
{ uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut); uint adjustedIn = bsub(BONE, swapFee); adjustedIn = bmul(tokenAmountIn, adjustedIn); uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn)); uint foo = bpow(y, weightRatio); uint bar = bsub(BONE, foo); tokenAmountOut = bmul(tokenBalanceOut, bar); return tokenAmountOut; }
{ uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut); uint adjustedIn = bsub(BONE, swapFee); adjustedIn = bmul(tokenAmountIn, adjustedIn); uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn)); uint foo = bpow(y, weightRatio); uint bar = bsub(BONE, foo); tokenAmountOut = bmul(tokenBalanceOut, bar); return tokenAmountOut; }
20,929
61
// signal distribution complete
completed = true; emit Completed();
completed = true; emit Completed();
34,492
5
// pattern related
mapping(bytes32 => Action) public actions; uint256 public actionCounter;
mapping(bytes32 => Action) public actions; uint256 public actionCounter;
15,305
100
// called when user wants to withdraw tokens back to root chain Should burn user's tokens. This transaction will be verified when exiting on root chain amount amount of tokens to withdraw /
function withdraw(uint256 amount) external { require(!isBlacklist(msg.sender), "Token: caller in blacklist can't transfer"); _redeem(msg.sender, amount); }
function withdraw(uint256 amount) external { require(!isBlacklist(msg.sender), "Token: caller in blacklist can't transfer"); _redeem(msg.sender, amount); }
22,075
86
// Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return theacceptance magic value. /
function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender();
function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender();
3,302
23
// Add re-investor to the renumeration
if (reInvestorsIndex[msg.sender] == 0) { reInvestorsCount++; reInvestorsIndex[msg.sender] = reInvestorsCount; reInvestors[reInvestorsCount] = msg.sender; userInfo[msg.sender].isReinvestingOnForEpoch[currentEpoch] = true; }
if (reInvestorsIndex[msg.sender] == 0) { reInvestorsCount++; reInvestorsIndex[msg.sender] = reInvestorsCount; reInvestors[reInvestorsCount] = msg.sender; userInfo[msg.sender].isReinvestingOnForEpoch[currentEpoch] = true; }
14,366
41
// Contract registry contract interface/ The contract registry holds Orbs PoS contracts and managers lists/The contract registry updates the managed contracts on changes in the contract list/Governance functions restricted to managers access the registry to retrieve the manager address /The contract registry represents the source of truth for Orbs Ethereum contracts /By tracking the registry events or query before interaction, one can access the up to date contracts
interface IContractRegistry { event ContractAddressUpdated(string contractName, address addr, bool managedContract); event ManagerChanged(string role, address newManager); event ContractRegistryUpdated(address newContractRegistry); /* * External functions */ /// Updates the contracts address and emits a corresponding event /// @dev governance function called only by the migrationManager or registryAdmin /// @param contractName is the contract name, used to identify it /// @param addr is the contract updated address /// @param managedContract indicates whether the contract is managed by the registry and notified on changes function setContract(string calldata contractName, address addr, bool managedContract) external /* onlyAdminOrMigrationManager */; /// Returns the current address of the given contracts /// @param contractName is the contract name, used to identify it /// @return addr is the contract updated address function getContract(string calldata contractName) external view returns (address); /// Returns the list of contract addresses managed by the registry /// @dev Managed contracts are updated on changes in the registry contracts addresses /// @return addrs is the list of managed contracts function getManagedContracts() external view returns (address[] memory); /// Updates a manager address and emits a corresponding event /// @dev governance function called only by the registryAdmin /// @dev the managers list is a flexible list of role to the manager's address /// @param role is the managers' role name, for example "functionalManager" /// @param manager is the manager updated address function setManager(string calldata role, address manager) external /* onlyAdmin */; /// Returns the current address of the given manager /// @param role is the manager name, used to identify it /// @return addr is the manager updated address function getManager(string calldata role) external view returns (address); /// Locks all the managed contracts /// @dev governance function called only by the migrationManager or registryAdmin /// @dev When set all onlyWhenActive functions will revert function lockContracts() external /* onlyAdminOrMigrationManager */; /// Unlocks all the managed contracts /// @dev governance function called only by the migrationManager or registryAdmin function unlockContracts() external /* onlyAdminOrMigrationManager */; /// Sets a new contract registry to migrate to /// @dev governance function called only by the registryAdmin /// @dev updates the registry address record in all the managed contracts /// @dev by tracking the emitted ContractRegistryUpdated, tools can track the up to date contracts /// @param newRegistry is the new registry contract function setNewContractRegistry(IContractRegistry newRegistry) external /* onlyAdmin */; /// Returns the previous contract registry address /// @dev used when the setting the contract as a new registry to assure a valid registry /// @return previousContractRegistry is the previous contract registry function getPreviousContractRegistry() external view returns (address); }
interface IContractRegistry { event ContractAddressUpdated(string contractName, address addr, bool managedContract); event ManagerChanged(string role, address newManager); event ContractRegistryUpdated(address newContractRegistry); /* * External functions */ /// Updates the contracts address and emits a corresponding event /// @dev governance function called only by the migrationManager or registryAdmin /// @param contractName is the contract name, used to identify it /// @param addr is the contract updated address /// @param managedContract indicates whether the contract is managed by the registry and notified on changes function setContract(string calldata contractName, address addr, bool managedContract) external /* onlyAdminOrMigrationManager */; /// Returns the current address of the given contracts /// @param contractName is the contract name, used to identify it /// @return addr is the contract updated address function getContract(string calldata contractName) external view returns (address); /// Returns the list of contract addresses managed by the registry /// @dev Managed contracts are updated on changes in the registry contracts addresses /// @return addrs is the list of managed contracts function getManagedContracts() external view returns (address[] memory); /// Updates a manager address and emits a corresponding event /// @dev governance function called only by the registryAdmin /// @dev the managers list is a flexible list of role to the manager's address /// @param role is the managers' role name, for example "functionalManager" /// @param manager is the manager updated address function setManager(string calldata role, address manager) external /* onlyAdmin */; /// Returns the current address of the given manager /// @param role is the manager name, used to identify it /// @return addr is the manager updated address function getManager(string calldata role) external view returns (address); /// Locks all the managed contracts /// @dev governance function called only by the migrationManager or registryAdmin /// @dev When set all onlyWhenActive functions will revert function lockContracts() external /* onlyAdminOrMigrationManager */; /// Unlocks all the managed contracts /// @dev governance function called only by the migrationManager or registryAdmin function unlockContracts() external /* onlyAdminOrMigrationManager */; /// Sets a new contract registry to migrate to /// @dev governance function called only by the registryAdmin /// @dev updates the registry address record in all the managed contracts /// @dev by tracking the emitted ContractRegistryUpdated, tools can track the up to date contracts /// @param newRegistry is the new registry contract function setNewContractRegistry(IContractRegistry newRegistry) external /* onlyAdmin */; /// Returns the previous contract registry address /// @dev used when the setting the contract as a new registry to assure a valid registry /// @return previousContractRegistry is the previous contract registry function getPreviousContractRegistry() external view returns (address); }
7,171
66
// Destroys `amount` tokens from the caller.
* See {BEP20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); }
* See {BEP20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); }
41,660
184
// stages manage drawings, tickets, and peg round denominations /
struct Stage { bool stageCompleted; Ticket finalTicket; DrawBlocks drawBlocks; bool allowTicketPurchases; bool readyToFinalize; bool isDrawFinalized; uint256 startBlock; uint256 endBlock; Payouts stagePayouts; Splits stageSplits; uint256 drawDate; uint256 redemptionEnd; mapping(address => Ticket[]) playerTickets; }
struct Stage { bool stageCompleted; Ticket finalTicket; DrawBlocks drawBlocks; bool allowTicketPurchases; bool readyToFinalize; bool isDrawFinalized; uint256 startBlock; uint256 endBlock; Payouts stagePayouts; Splits stageSplits; uint256 drawDate; uint256 redemptionEnd; mapping(address => Ticket[]) playerTickets; }
20,790
34
// @notify Get unused protocol tokens back from the distributor and then send tokens out of the contractreceiver The receiver of protocol tokensprotocolTokenAmount Amount of protocol tokens to send/
function getTokensFromDistributorAndSend(address receiver, uint256 protocolTokenAmount) public isAuthorized { getTokensFromDistributor(); sendTokens(receiver, protocolTokenAmount); }
function getTokensFromDistributorAndSend(address receiver, uint256 protocolTokenAmount) public isAuthorized { getTokensFromDistributor(); sendTokens(receiver, protocolTokenAmount); }
39,058
55
// TAOCurrency /
contract TAOCurrency is TheAO { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals; // To differentiate denomination of TAO Currency uint256 public powerOfTen; uint256 public totalSupply; // This creates an array with all balances // address is the address of nameId, not the eth public address mapping (address => uint256) public balanceOf; // This generates a public event on the blockchain that will notify clients // address is the address of TAO/Name Id, not eth public address event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt // address is the address of TAO/Name Id, not eth public address event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor (uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply; // Update total supply balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes powerOfTen = 0; decimals = 0; } /** * @dev Checks if the calling contract address is The AO * OR * If The AO is set to a Name/TAO, then check if calling address is the Advocate */ modifier onlyTheAO { require (AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress)); _; } /** * @dev Check if `_id` is a Name or a TAO */ modifier isNameOrTAO(address _id) { require (AOLibrary.isName(_id) || AOLibrary.isTAO(_id)); _; } /***** The AO ONLY METHODS *****/ /** * @dev The AO set the NameTAOPosition Address * @param _nameTAOPositionAddress The address of NameTAOPosition */ function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO { require (_nameTAOPositionAddress != address(0)); nameTAOPositionAddress = _nameTAOPositionAddress; } /** * @dev Transfer ownership of The AO to new address * @param _theAO The new address to be transferred */ function transferOwnership(address _theAO) public onlyTheAO { require (_theAO != address(0)); theAO = _theAO; } /** * @dev Whitelist `_account` address to transact on behalf of others * @param _account The address to whitelist * @param _whitelist Either to whitelist or not */ function setWhitelist(address _account, bool _whitelist) public onlyTheAO { require (_account != address(0)); whitelist[_account] = _whitelist; } /***** PUBLIC METHODS *****/ /** * @dev transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public inWhitelist isNameOrTAO(_from) isNameOrTAO(_to) returns (bool) { _transfer(_from, _to, _value); return true; } /** * @dev Create `mintedAmount` tokens and send it to `target` * @param target Address to receive the tokens * @param mintedAmount The amount of tokens it will receive * @return true on success */ function mintToken(address target, uint256 mintedAmount) public inWhitelist isNameOrTAO(target) returns (bool) { _mintToken(target, mintedAmount); return true; } /** * * @dev Whitelisted address remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function whitelistBurnFrom(address _from, uint256 _value) public inWhitelist returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } /***** INTERNAL METHODS *****/ /** * @dev Send `_value` tokens from `_from` to `_to` * @param _from The address of sender * @param _to The address of the recipient * @param _value The amount to send */ function _transfer(address _from, address _to, uint256 _value) internal { require (_to != address(0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to].add(_value) >= balanceOf[_to]); // Check for overflows uint256 previousBalances = balanceOf[_from].add(balanceOf[_to]); balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the sender balanceOf[_to] = balanceOf[_to].add(_value); // Add the same to the recipient emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * @dev Create `mintedAmount` tokens and send it to `target` * @param target Address to receive the tokens * @param mintedAmount The amount of tokens it will receive */ function _mintToken(address target, uint256 mintedAmount) internal { balanceOf[target] = balanceOf[target].add(mintedAmount); totalSupply = totalSupply.add(mintedAmount); emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } }
contract TAOCurrency is TheAO { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals; // To differentiate denomination of TAO Currency uint256 public powerOfTen; uint256 public totalSupply; // This creates an array with all balances // address is the address of nameId, not the eth public address mapping (address => uint256) public balanceOf; // This generates a public event on the blockchain that will notify clients // address is the address of TAO/Name Id, not eth public address event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt // address is the address of TAO/Name Id, not eth public address event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor (uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply; // Update total supply balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes powerOfTen = 0; decimals = 0; } /** * @dev Checks if the calling contract address is The AO * OR * If The AO is set to a Name/TAO, then check if calling address is the Advocate */ modifier onlyTheAO { require (AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress)); _; } /** * @dev Check if `_id` is a Name or a TAO */ modifier isNameOrTAO(address _id) { require (AOLibrary.isName(_id) || AOLibrary.isTAO(_id)); _; } /***** The AO ONLY METHODS *****/ /** * @dev The AO set the NameTAOPosition Address * @param _nameTAOPositionAddress The address of NameTAOPosition */ function setNameTAOPositionAddress(address _nameTAOPositionAddress) public onlyTheAO { require (_nameTAOPositionAddress != address(0)); nameTAOPositionAddress = _nameTAOPositionAddress; } /** * @dev Transfer ownership of The AO to new address * @param _theAO The new address to be transferred */ function transferOwnership(address _theAO) public onlyTheAO { require (_theAO != address(0)); theAO = _theAO; } /** * @dev Whitelist `_account` address to transact on behalf of others * @param _account The address to whitelist * @param _whitelist Either to whitelist or not */ function setWhitelist(address _account, bool _whitelist) public onlyTheAO { require (_account != address(0)); whitelist[_account] = _whitelist; } /***** PUBLIC METHODS *****/ /** * @dev transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public inWhitelist isNameOrTAO(_from) isNameOrTAO(_to) returns (bool) { _transfer(_from, _to, _value); return true; } /** * @dev Create `mintedAmount` tokens and send it to `target` * @param target Address to receive the tokens * @param mintedAmount The amount of tokens it will receive * @return true on success */ function mintToken(address target, uint256 mintedAmount) public inWhitelist isNameOrTAO(target) returns (bool) { _mintToken(target, mintedAmount); return true; } /** * * @dev Whitelisted address remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function whitelistBurnFrom(address _from, uint256 _value) public inWhitelist returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } /***** INTERNAL METHODS *****/ /** * @dev Send `_value` tokens from `_from` to `_to` * @param _from The address of sender * @param _to The address of the recipient * @param _value The amount to send */ function _transfer(address _from, address _to, uint256 _value) internal { require (_to != address(0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to].add(_value) >= balanceOf[_to]); // Check for overflows uint256 previousBalances = balanceOf[_from].add(balanceOf[_to]); balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the sender balanceOf[_to] = balanceOf[_to].add(_value); // Add the same to the recipient emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * @dev Create `mintedAmount` tokens and send it to `target` * @param target Address to receive the tokens * @param mintedAmount The amount of tokens it will receive */ function _mintToken(address target, uint256 mintedAmount) internal { balanceOf[target] = balanceOf[target].add(mintedAmount); totalSupply = totalSupply.add(mintedAmount); emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } }
32,354
6
// accepts admin transfer for selected contracts _contractIdxs indexes corresponsing to contracts /
function acceptAdmin(uint[] calldata _contractIdxs) external onlyOwner() { require(_contractIdxs.length <= contracts.length, "contractIdxs length must be <= contracts length"); _acceptAdmin(_contractIdxs); }
function acceptAdmin(uint[] calldata _contractIdxs) external onlyOwner() { require(_contractIdxs.length <= contracts.length, "contractIdxs length must be <= contracts length"); _acceptAdmin(_contractIdxs); }
30,579
4
// ========== MUTATIVE FUNCTIONS ========== / type = 0: pancake, 1: bdex, 2: vswap
function migrateAll(address _oldPair, address _newPair, uint8 _oldPairType, bool _zapping) external { migrate(_oldPair, _newPair, IUniswapV2Pair(_oldPair).balanceOf(msg.sender), _oldPairType, _zapping); }
function migrateAll(address _oldPair, address _newPair, uint8 _oldPairType, bool _zapping) external { migrate(_oldPair, _newPair, IUniswapV2Pair(_oldPair).balanceOf(msg.sender), _oldPairType, _zapping); }
30,563
0
// Model a Candidate
struct Candidate { uint id; string name; uint voteCount; }
struct Candidate { uint id; string name; uint voteCount; }
6,789
13
// Enforce verified voters
modifier onlyVerifiedVoters() { require(isVoterVerified(msg.sender), "VREQ5: Voter not verified to vote."); _; }
modifier onlyVerifiedVoters() { require(isVoterVerified(msg.sender), "VREQ5: Voter not verified to vote."); _; }
36,503
60
// _approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETH( tokenAmount, 0, path, address(this), block.timestamp );
uniswapV2Router.swapExactTokensForETH( tokenAmount, 0, path, address(this), block.timestamp );
9,503
6
// Ownable The contract Ownable defines an owner address and implements the basic authorization control. /
contract Ownable { address public owner; event OwnershipTransferred ( address indexed oldOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the sender account as the original `owner` of the contract. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner of this contract. */ modifier onlyContractOwner() { require(msg.sender == owner, "Contract owner priviledge required."); _; } /** * @dev Allows the current owner to transfer control of the contract to the account of a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership ( address newOwner ) public onlyContractOwner { require(newOwner != address(0), "New contract owner cannot be address(0)."); require(newOwner != owner, "New contract owner cannot be current owner."); owner = newOwner; emit OwnershipTransferred(owner, newOwner); } }
contract Ownable { address public owner; event OwnershipTransferred ( address indexed oldOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the sender account as the original `owner` of the contract. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner of this contract. */ modifier onlyContractOwner() { require(msg.sender == owner, "Contract owner priviledge required."); _; } /** * @dev Allows the current owner to transfer control of the contract to the account of a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership ( address newOwner ) public onlyContractOwner { require(newOwner != address(0), "New contract owner cannot be address(0)."); require(newOwner != owner, "New contract owner cannot be current owner."); owner = newOwner; emit OwnershipTransferred(owner, newOwner); } }
25,416