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
66
// See {IERC20-transfer}. Requirements: - `to` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; }
function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; }
31,407
3
// address _cToken,
address _yDAI
address _yDAI
9,009
0
// standard ERC20 stuff
string public symbol; string public name; uint8 public decimals; uint public _totalSupply; bool public mintable;
string public symbol; string public name; uint8 public decimals; uint public _totalSupply; bool public mintable;
40,832
5
// Constructor The deploying account becomes contractOwner /
constructor(address airlineAddress) public { contractOwner = msg.sender; registeredAirlines[airlineAddress] = Airline(true, false, 0); // initialise and register first airline ++totalRegisteredAirlines; }
constructor(address airlineAddress) public { contractOwner = msg.sender; registeredAirlines[airlineAddress] = Airline(true, false, 0); // initialise and register first airline ++totalRegisteredAirlines; }
16,733
33
// Returns an array of 7 date units if isWeek is true.Returns an array of 6 hour units if isWeek is false.E.g. isWeek is true, returns [28, 29, 30, 31, 1, 2, 3] isWeek is false, returns [6, 7, 8, 9, 10, 11] /
function getTimeUnits(bool isWeek) internal view returns (uint16[7] memory units)
function getTimeUnits(bool isWeek) internal view returns (uint16[7] memory units)
34,585
46
// Mapping from owner address to mapping of operator addresses. /
mapping (address => mapping (address => bool)) internal ownerToOperators;
mapping (address => mapping (address => bool)) internal ownerToOperators;
12,886
462
// expmods_and_points.points[53] = -(g^196z).
mstore(add(expmodsAndPoints, 0xa60), point)
mstore(add(expmodsAndPoints, 0xa60), point)
77,659
97
// function to get Staking Total Days by Id
function getTokenStakingTotalDaysById(uint256 id) public view returns(uint256){ require(id <= _tokenStakingCount,"Unable to reterive data on specified id, Please try again!!"); return _tokenTotalDays[id]; }
function getTokenStakingTotalDaysById(uint256 id) public view returns(uint256){ require(id <= _tokenStakingCount,"Unable to reterive data on specified id, Please try again!!"); return _tokenTotalDays[id]; }
22,924
222
// MinimumStakeSchedule defines the minimum stake parametrization and/ schedule. It starts with a minimum stake of 100k KEEP. Over the following/ 2 years, the minimum stake is lowered periodically using a uniform stepwise/ function, eventually ending at 10k.
library MinimumStakeSchedule { using SafeMath for uint256; // 2 years in seconds (seconds per day * days in a year * years) uint256 public constant schedule = 86400 * 365 * 2; uint256 public constant steps = 10; uint256 public constant base = 10000 * 1e18; /// @notice Returns the current value of the minimum stake. The minimum /// stake is lowered periodically over the course of 2 years since the time /// of the shedule start and eventually ends at 10k KEEP. function current(uint256 scheduleStart) internal view returns (uint256) { if (now < scheduleStart.add(schedule)) { uint256 currentStep = steps.mul(now.sub(scheduleStart)).div(schedule); return base.mul(steps.sub(currentStep)); } return base; } }
library MinimumStakeSchedule { using SafeMath for uint256; // 2 years in seconds (seconds per day * days in a year * years) uint256 public constant schedule = 86400 * 365 * 2; uint256 public constant steps = 10; uint256 public constant base = 10000 * 1e18; /// @notice Returns the current value of the minimum stake. The minimum /// stake is lowered periodically over the course of 2 years since the time /// of the shedule start and eventually ends at 10k KEEP. function current(uint256 scheduleStart) internal view returns (uint256) { if (now < scheduleStart.add(schedule)) { uint256 currentStep = steps.mul(now.sub(scheduleStart)).div(schedule); return base.mul(steps.sub(currentStep)); } return base; } }
6,905
19
// zaTokens store their underlying asset address in the contract
underlyingAsset = zaToken(_address).underlyingAsset();
underlyingAsset = zaToken(_address).underlyingAsset();
16,086
11
// Internal function to delete bitmask associated with `_tokenId`/
function _clearBitMask(uint256 _tokenId) internal { delete _bitmasks[_tokenId]; emit BitMaskUpdated(_tokenId, 0); }
function _clearBitMask(uint256 _tokenId) internal { delete _bitmasks[_tokenId]; emit BitMaskUpdated(_tokenId, 0); }
8,445
1
// Accrued token per share
uint256[] public accTokenPerShare; uint256 public stakers; uint256 public startBlock; uint256 public endBlock; uint256 public bonusStartBlock; uint256 public bonusEndBlock; uint256[] public rewardPerBlock; uint256[] public rewardTokenAmounts; uint256 public stakedTokenSupply;
uint256[] public accTokenPerShare; uint256 public stakers; uint256 public startBlock; uint256 public endBlock; uint256 public bonusStartBlock; uint256 public bonusEndBlock; uint256[] public rewardPerBlock; uint256[] public rewardTokenAmounts; uint256 public stakedTokenSupply;
12,258
55
// minimum vesting 3 months
require(_lockMonths >= minVestLockMonths);
require(_lockMonths >= minVestLockMonths);
43,883
76
// to emit Trove's debt update event, to be called from trove/ _token address of token/ _newAmount new trove's debt value/ _newCollateralization new trove's collateralization value
function emitTroveDebtUpdate( address _token, uint256 _newAmount, uint256 _newCollateralization, uint256 _feePaid
function emitTroveDebtUpdate( address _token, uint256 _newAmount, uint256 _newCollateralization, uint256 _feePaid
23,393
81
// 得到当前币种的统计总数,只能遍历,所以这个 bridgepair 数量不能太大!否则会超过gas限制的! 不处理 eth 或 bnb ,只处理 ERC20
function getTokenCountAmount(address _token) public view returns (uint) { uint result = 0; //1, 计算当前各个UniPair中能够取出来的金额 uint i = 0; address bp = IndexBridgePairOf[i]; while(bp != address(0)) { address UniPair = UniswapV2Library.pairFor(factory, BridgePair(bp).Token0(), BridgePair(bp).Token1()); if (IUniswapV2Pair(UniPair).token0() == _token || IUniswapV2Pair(UniPair).token1() == _token) { result = result + IERC20(_token).balanceOf(UniPair) * IUniswapV2Pair(UniPair).balanceOf(bp) / IUniswapV2Pair(UniPair).totalSupply(); } i++; bp = IndexBridgePairOf[i]; } //2, 本身的存量资金要加上 result = result + IERC20(_token).balanceOf(address(this)); return result; }
function getTokenCountAmount(address _token) public view returns (uint) { uint result = 0; //1, 计算当前各个UniPair中能够取出来的金额 uint i = 0; address bp = IndexBridgePairOf[i]; while(bp != address(0)) { address UniPair = UniswapV2Library.pairFor(factory, BridgePair(bp).Token0(), BridgePair(bp).Token1()); if (IUniswapV2Pair(UniPair).token0() == _token || IUniswapV2Pair(UniPair).token1() == _token) { result = result + IERC20(_token).balanceOf(UniPair) * IUniswapV2Pair(UniPair).balanceOf(bp) / IUniswapV2Pair(UniPair).totalSupply(); } i++; bp = IndexBridgePairOf[i]; } //2, 本身的存量资金要加上 result = result + IERC20(_token).balanceOf(address(this)); return result; }
33,883
6
// Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted}event. Requirements: - the caller must have ``role``'s admin role. /
function grantRole(bytes32 role, address account) external;
function grantRole(bytes32 role, address account) external;
57,497
14
// Initialize the controller. /
function _initialize(address _controller) internal { _setController(_controller); }
function _initialize(address _controller) internal { _setController(_controller); }
1,675
61
// Helper function to extract a useful revert message from a failed call./ If the returned data is malformed or not correctly abi encoded then this call can fail itself.
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_returnData.length < 68) return "Transaction reverted silently"; assembly { // Slice the sighash. _returnData := add(_returnData, 0x04) } return abi.decode(_returnData, (string)); // All that remains is the revert string }
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_returnData.length < 68) return "Transaction reverted silently"; assembly { // Slice the sighash. _returnData := add(_returnData, 0x04) } return abi.decode(_returnData, (string)); // All that remains is the revert string }
17,975
4
// ERC20 token used for staking
address public immutable stakingToken;
address public immutable stakingToken;
66,619
0
// keyhash or scripthash for syscoinWitnessProgram
function freezeBurnERC20( uint value, uint32 assetGUID, address erc20ContractAddress, uint8 precision, bytes memory ) public minimumValue(erc20ContractAddress, value) returns (bool)
function freezeBurnERC20( uint value, uint32 assetGUID, address erc20ContractAddress, uint8 precision, bytes memory ) public minimumValue(erc20ContractAddress, value) returns (bool)
24,622
15
// =============================================================================
}
}
468
116
// set validator/_validator address to add or remove from validator list/value add/remove option
function setValidator(address _validator, bool value) external;
function setValidator(address _validator, bool value) external;
18,510
124
// Functions -----------------------------------------------------------------------------------------------------------------/Register the given beneficiary/beneficiary Address of beneficiary to be registered
function registerBeneficiary(address beneficiary) public onlyDeployer notNullAddress(beneficiary) returns (bool)
function registerBeneficiary(address beneficiary) public onlyDeployer notNullAddress(beneficiary) returns (bool)
16,709
56
// uint newBalTi = poolRatio^(1/weightTi)balTi;
uint256 boo = bdiv(BONE, normalizedWeight); uint256 tokenInRatio = bpow(poolRatio, boo); uint256 newTokenBalanceIn = bmul(tokenInRatio, tokenBalanceIn); uint256 tokenAmountInAfterFee = bsub(newTokenBalanceIn, tokenBalanceIn);
uint256 boo = bdiv(BONE, normalizedWeight); uint256 tokenInRatio = bpow(poolRatio, boo); uint256 newTokenBalanceIn = bmul(tokenInRatio, tokenBalanceIn); uint256 tokenAmountInAfterFee = bsub(newTokenBalanceIn, tokenBalanceIn);
51,153
2
// solium-disable-next-line security/no-call-value
(bool success, bytes memory returnData) = target.call{value : value}(callData);
(bool success, bytes memory returnData) = target.call{value : value}(callData);
943
9
// Helpful function to simplify the mento relayer implementation /
function updatePriceValuesAndCleanOldReports( uint256 proposedTimestamp, LocationInSortedLinkedList[] calldata locationsInSortedLinkedLists
function updatePriceValuesAndCleanOldReports( uint256 proposedTimestamp, LocationInSortedLinkedList[] calldata locationsInSortedLinkedLists
9,389
65
// Add token TokenJackpotBouns
emit TokenJackpotBouns(bet.gambler,totalJackpotWin); totalAmount = totalAmount.add(totalJackpotWin); tokenJackpotSize = uint128(tokenJackpotSize.sub(totalJackpotWin));
emit TokenJackpotBouns(bet.gambler,totalJackpotWin); totalAmount = totalAmount.add(totalJackpotWin); tokenJackpotSize = uint128(tokenJackpotSize.sub(totalJackpotWin));
16,214
5
// ETH:WSqueeth uniswap pool
address public immutable ethWSqueethPool;
address public immutable ethWSqueethPool;
3,734
3
// external unseal & mint function in batch /
function unsealMintBatch(address[] calldata idolContracts, uint256[] calldata tokenIds) external payable;
function unsealMintBatch(address[] calldata idolContracts, uint256[] calldata tokenIds) external payable;
13,326
8
// 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:_spender The address which will spend the funds._value The amount of tokens to be spent./
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
43,099
101
// Interface to be implemented by all Transfer Manager modules /
contract ITransferManager is IModule, Pausable { //If verifyTransfer returns: // FORCE_VALID, the transaction will always be valid, regardless of other TM results // INVALID, then the transfer should not be allowed regardless of other TM results // VALID, then the transfer is valid for this TM // NA, then the result from this TM is ignored enum Result {INVALID, NA, VALID, FORCE_VALID} function verifyTransfer(address _from, address _to, uint256 _amount, bool _isTransfer) public returns(Result); function unpause() onlyOwner public { super._unpause(); } function pause() onlyOwner public { super._pause(); } }
contract ITransferManager is IModule, Pausable { //If verifyTransfer returns: // FORCE_VALID, the transaction will always be valid, regardless of other TM results // INVALID, then the transfer should not be allowed regardless of other TM results // VALID, then the transfer is valid for this TM // NA, then the result from this TM is ignored enum Result {INVALID, NA, VALID, FORCE_VALID} function verifyTransfer(address _from, address _to, uint256 _amount, bool _isTransfer) public returns(Result); function unpause() onlyOwner public { super._unpause(); } function pause() onlyOwner public { super._pause(); } }
49,604
79
// See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address. /
function balanceOf(address account, uint256 id) public view override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
function balanceOf(address account, uint256 id) public view override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
2,358
2
// Estimate the amount of `assetIn` required for `swap()`.assetIn address of the ERC-20 token to swap from assetOut address of the ERC-20 token to swap to amountOut expected amount of `assetOut` after the swap /
function getAmountIn(
function getAmountIn(
14,250
263
// Pay any necessary fees to mint a furball/Delegated logic from Furballs;
function purchaseMint( address from, uint8 permissions, address to, IFurballEdition edition
function purchaseMint( address from, uint8 permissions, address to, IFurballEdition edition
69,747
16
// WhitelistedRole Whitelisted accounts have been approved by a WhitelistAdmin to perform certain actions (e.g. participate in acrowdsale). This role is special in that the only accounts that can add it are WhitelistAdmins (who can also removeit), and not Whitelisteds themselves. /
contract WhitelistedRole is Context, WhitelistAdminRole { using Roles for Roles.Role; event WhitelistedAdded(address indexed account); event WhitelistedRemoved(address indexed account); Roles.Role private _whitelisteds; modifier onlyWhitelisted() { require( isWhitelisted(_msgSender()), "WhitelistedRole: caller does not have the Whitelisted role" ); _; } function isWhitelisted(address account) public view returns (bool) { return _whitelisteds.has(account); } function addWhitelisted(address account) public onlyWhitelistAdmin { _addWhitelisted(account); } function removeWhitelisted(address account) public onlyWhitelistAdmin { _removeWhitelisted(account); } function renounceWhitelisted() public { _removeWhitelisted(_msgSender()); } function _addWhitelisted(address account) internal { _whitelisteds.add(account); emit WhitelistedAdded(account); } function _removeWhitelisted(address account) internal { _whitelisteds.remove(account); emit WhitelistedRemoved(account); } }
contract WhitelistedRole is Context, WhitelistAdminRole { using Roles for Roles.Role; event WhitelistedAdded(address indexed account); event WhitelistedRemoved(address indexed account); Roles.Role private _whitelisteds; modifier onlyWhitelisted() { require( isWhitelisted(_msgSender()), "WhitelistedRole: caller does not have the Whitelisted role" ); _; } function isWhitelisted(address account) public view returns (bool) { return _whitelisteds.has(account); } function addWhitelisted(address account) public onlyWhitelistAdmin { _addWhitelisted(account); } function removeWhitelisted(address account) public onlyWhitelistAdmin { _removeWhitelisted(account); } function renounceWhitelisted() public { _removeWhitelisted(_msgSender()); } function _addWhitelisted(address account) internal { _whitelisteds.add(account); emit WhitelistedAdded(account); } function _removeWhitelisted(address account) internal { _whitelisteds.remove(account); emit WhitelistedRemoved(account); } }
11,825
12
// Emitted when STRK rate is changed
event NewStrikeRate(uint oldStrikeRate, uint newStrikeRate);
event NewStrikeRate(uint oldStrikeRate, uint newStrikeRate);
27,475
73
// (,HT数量) = 移除流动性支持Token收转帐税(token地址,流动性数量,Token最小数量,HT最小数量,to地址,最后期限)
amountHT = removeLiquidityHTSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountHTMin, to, deadline );
amountHT = removeLiquidityHTSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountHTMin, to, deadline );
15,669
110
// Ricardo Guilherme Schmidt (Status Research & Development GmbH)Registers usernames as ENS subnodes of the domain `ensNode` /
contract UsernameRegistrar is Controlled, ApproveAndCallFallBack { ERC20Token public token; ENS public ensRegistry; PublicResolver public resolver; address public parentRegistry; uint256 public constant releaseDelay = 365 days; mapping (bytes32 => Account) public accounts; mapping (bytes32 => SlashReserve) reservedSlashers; //Slashing conditions uint256 public usernameMinLength; bytes32 public reservedUsernamesMerkleRoot; event RegistryState(RegistrarState state); event RegistryPrice(uint256 price); event RegistryMoved(address newRegistry); event UsernameOwner(bytes32 indexed nameHash, address owner); enum RegistrarState { Inactive, Active, Moved } bytes32 public ensNode; uint256 public price; RegistrarState public state; uint256 public reserveAmount; struct Account { uint256 balance; uint256 creationTime; address owner; } struct SlashReserve { address reserver; uint256 blockNumber; } /** * @notice Callable only by `parentRegistry()` to continue migration of ENSSubdomainRegistry. */ modifier onlyParentRegistry { require(msg.sender == parentRegistry, "Migration only."); _; } /** * @notice Initializes UsernameRegistrar contract. * The only parameter from this list that can be changed later is `_resolver`. * Other updates require a new contract and migration of domain. * @param _token ERC20 token with optional `approveAndCall(address,uint256,bytes)` for locking fee. * @param _ensRegistry Ethereum Name Service root contract address. * @param _resolver Public Resolver for resolving usernames. * @param _ensNode ENS node (domain) being used for usernames subnodes (subdomain) * @param _usernameMinLength Minimum length of usernames * @param _reservedUsernamesMerkleRoot Merkle root of reserved usernames * @param _parentRegistry Address of old registry (if any) for optional account migration. */ constructor( ERC20Token _token, ENS _ensRegistry, PublicResolver _resolver, bytes32 _ensNode, uint256 _usernameMinLength, bytes32 _reservedUsernamesMerkleRoot, address _parentRegistry ) public { require(address(_token) != address(0), "No ERC20Token address defined."); require(address(_ensRegistry) != address(0), "No ENS address defined."); require(address(_resolver) != address(0), "No Resolver address defined."); require(_ensNode != bytes32(0), "No ENS node defined."); token = _token; ensRegistry = _ensRegistry; resolver = _resolver; ensNode = _ensNode; usernameMinLength = _usernameMinLength; reservedUsernamesMerkleRoot = _reservedUsernamesMerkleRoot; parentRegistry = _parentRegistry; setState(RegistrarState.Inactive); } /** * @notice Registers `_label` username to `ensNode` setting msg.sender as owner. * Terms of name registration: * - SNT is deposited, not spent; the amount is locked up for 1 year. * - After 1 year, the user can release the name and receive their deposit back (at any time). * - User deposits are completely protected. The contract controller cannot access them. * - User&#39;s address(es) will be publicly associated with the ENS name. * - User must authorise the contract to transfer `price` `token.name()` on their behalf. * - Usernames registered with less then `usernameMinLength` characters can be slashed. * - Usernames contained in the merkle tree of root `reservedUsernamesMerkleRoot` can be slashed. * - Usernames starting with `0x` and bigger then 12 characters can be slashed. * - If terms of the contract change—e.g. Status makes contract upgrades—the user has the right to release the username and get their deposit back. * @param _label Choosen unowned username hash. * @param _account Optional address to set at public resolver. * @param _pubkeyA Optional pubkey part A to set at public resolver. * @param _pubkeyB Optional pubkey part B to set at public resolver. */ function register( bytes32 _label, address _account, bytes32 _pubkeyA, bytes32 _pubkeyB ) external returns(bytes32 namehash) { return registerUser(msg.sender, _label, _account, _pubkeyA, _pubkeyB); } /** * @notice Release username and retrieve locked fee, needs to be called * after `releasePeriod` from creation time by ENS registry owner of domain * or anytime by account owner when domain migrated to a new registry. * @param _label Username hash. */ function release( bytes32 _label ) external { bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); Account memory account = accounts[_label]; require(account.creationTime > 0, "Username not registered."); if (state == RegistrarState.Active) { require(msg.sender == ensRegistry.owner(namehash), "Not owner of ENS node."); require(block.timestamp > account.creationTime + releaseDelay, "Release period not reached."); } else { require(msg.sender == account.owner, "Not the former account owner."); } delete accounts[_label]; if (account.balance > 0) { reserveAmount -= account.balance; require(token.transfer(msg.sender, account.balance), "Transfer failed"); } if (state == RegistrarState.Active) { ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); } else { address newOwner = ensRegistry.owner(ensNode); //Low level call, case dropUsername not implemented or failing, proceed release. //Invert (!) to supress warning, return of this call have no use. !newOwner.call.gas(80000)( abi.encodeWithSignature( "dropUsername(bytes32)", _label ) ); } emit UsernameOwner(namehash, address(0)); } /** * @notice update account owner, should be called by new ens node owner * to update this contract registry, otherwise former owner can release * if domain is moved to a new registry. * @param _label Username hash. **/ function updateAccountOwner( bytes32 _label ) external { bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); require(msg.sender == ensRegistry.owner(namehash), "Caller not owner of ENS node."); require(accounts[_label].creationTime > 0, "Username not registered."); require(ensRegistry.owner(ensNode) == address(this), "Registry not owner of registry."); accounts[_label].owner = msg.sender; emit UsernameOwner(namehash, msg.sender); } /** * @notice secretly reserve the slashing reward to `msg.sender` * @param _secret keccak256(abi.encodePacked(namehash, creationTime, reserveSecret)) */ function reserveSlash(bytes32 _secret) external { require(reservedSlashers[_secret].blockNumber == 0, "Already Reserved"); reservedSlashers[_secret] = SlashReserve(msg.sender, block.number); } /** * @notice Slash username smaller then `usernameMinLength`. * @param _username Raw value of offending username. */ function slashSmallUsername( string _username, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length < usernameMinLength, "Not a small username."); slashUsername(username, _reserveSecret); } /** * @notice Slash username starting with "0x" and with length greater than 12. * @param _username Raw value of offending username. */ function slashAddressLikeUsername( string _username, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length > 12, "Too small to look like an address."); require(username[0] == byte("0"), "First character need to be 0"); require(username[1] == byte("x"), "Second character need to be x"); for(uint i = 2; i < 7; i++){ byte b = username[i]; require((b >= 48 && b <= 57) || (b >= 97 && b <= 102), "Does not look like an address"); } slashUsername(username, _reserveSecret); } /** * @notice Slash username that is exactly a reserved name. * @param _username Raw value of offending username. * @param _proof Merkle proof that name is listed on merkle tree. */ function slashReservedUsername( string _username, bytes32[] _proof, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require( MerkleProof.verifyProof( _proof, reservedUsernamesMerkleRoot, keccak256(username) ), "Invalid Proof." ); slashUsername(username, _reserveSecret); } /** * @notice Slash username that contains a non alphanumeric character. * @param _username Raw value of offending username. * @param _offendingPos Position of non alphanumeric character. */ function slashInvalidUsername( string _username, uint256 _offendingPos, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length > _offendingPos, "Invalid position."); byte b = username[_offendingPos]; require(!((b >= 48 && b <= 57) || (b >= 97 && b <= 122)), "Not invalid character."); slashUsername(username, _reserveSecret); } /** * @notice Clear resolver and ownership of unowned subdomians. * @param _labels Sequence to erase. */ function eraseNode( bytes32[] _labels ) external { uint len = _labels.length; require(len != 0, "Nothing to erase"); bytes32 label = _labels[len - 1]; bytes32 subnode = keccak256(abi.encodePacked(ensNode, label)); require(ensRegistry.owner(subnode) == address(0), "First slash/release top level subdomain"); ensRegistry.setSubnodeOwner(ensNode, label, address(this)); if(len > 1) { eraseNodeHierarchy(len - 2, _labels, subnode); } ensRegistry.setResolver(subnode, 0); ensRegistry.setOwner(subnode, 0); } /** * @notice Migrate account to new registry, opt-in to new contract. * @param _label Username hash. **/ function moveAccount( bytes32 _label, UsernameRegistrar _newRegistry ) external { require(state == RegistrarState.Moved, "Wrong contract state"); require(msg.sender == accounts[_label].owner, "Callable only by account owner."); require(ensRegistry.owner(ensNode) == address(_newRegistry), "Wrong update"); Account memory account = accounts[_label]; delete accounts[_label]; token.approve(_newRegistry, account.balance); _newRegistry.migrateUsername( _label, account.balance, account.creationTime, account.owner ); } /** * @notice Activate registration. * @param _price The price of registration. */ function activate( uint256 _price ) external onlyController { require(state == RegistrarState.Inactive, "Registry state is not Inactive"); require(ensRegistry.owner(ensNode) == address(this), "Registry does not own registry"); price = _price; setState(RegistrarState.Active); emit RegistryPrice(_price); } /** * @notice Updates Public Resolver for resolving users. * @param _resolver New PublicResolver. */ function setResolver( address _resolver ) external onlyController { resolver = PublicResolver(_resolver); } /** * @notice Updates registration price. * @param _price New registration price. */ function updateRegistryPrice( uint256 _price ) external onlyController { require(state == RegistrarState.Active, "Registry not owned"); price = _price; emit RegistryPrice(_price); } /** * @notice Transfer ownership of ensNode to `_newRegistry`. * Usernames registered are not affected, but they would be able to instantly release. * @param _newRegistry New UsernameRegistrar for hodling `ensNode` node. */ function moveRegistry( UsernameRegistrar _newRegistry ) external onlyController { require(_newRegistry != this, "Cannot move to self."); require(ensRegistry.owner(ensNode) == address(this), "Registry not owned anymore."); setState(RegistrarState.Moved); ensRegistry.setOwner(ensNode, _newRegistry); _newRegistry.migrateRegistry(price); emit RegistryMoved(_newRegistry); } /** * @notice Opt-out migration of username from `parentRegistry()`. * Clear ENS resolver and subnode owner. * @param _label Username hash. */ function dropUsername( bytes32 _label ) external onlyParentRegistry { require(accounts[_label].creationTime == 0, "Already migrated"); bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); } /** * @notice Withdraw not reserved tokens * @param _token Address of ERC20 withdrawing excess, or address(0) if want ETH. * @param _beneficiary Address to send the funds. **/ function withdrawExcessBalance( address _token, address _beneficiary ) external onlyController { require(_beneficiary != address(0), "Cannot burn token"); if (_token == address(0)) { _beneficiary.transfer(address(this).balance); } else { ERC20Token excessToken = ERC20Token(_token); uint256 amount = excessToken.balanceOf(address(this)); if(_token == address(token)){ require(amount > reserveAmount, "Is not excess"); amount -= reserveAmount; } else { require(amount > 0, "No balance"); } excessToken.transfer(_beneficiary, amount); } } /** * @notice Withdraw ens nodes not belonging to this contract. * @param _domainHash Ens node namehash. * @param _beneficiary New owner of ens node. **/ function withdrawWrongNode( bytes32 _domainHash, address _beneficiary ) external onlyController { require(_beneficiary != address(0), "Cannot burn node"); require(_domainHash != ensNode, "Cannot withdraw main node"); require(ensRegistry.owner(_domainHash) == address(this), "Not owner of this node"); ensRegistry.setOwner(_domainHash, _beneficiary); } /** * @notice Gets registration price. * @return Registration price. **/ function getPrice() external view returns(uint256 registryPrice) { return price; } /** * @notice reads amount tokens locked in username * @param _label Username hash. * @return Locked username balance. **/ function getAccountBalance(bytes32 _label) external view returns(uint256 accountBalance) { accountBalance = accounts[_label].balance; } /** * @notice reads username account owner at this contract, * which can release or migrate in case of upgrade. * @param _label Username hash. * @return Username account owner. **/ function getAccountOwner(bytes32 _label) external view returns(address owner) { owner = accounts[_label].owner; } /** * @notice reads when the account was registered * @param _label Username hash. * @return Registration time. **/ function getCreationTime(bytes32 _label) external view returns(uint256 creationTime) { creationTime = accounts[_label].creationTime; } /** * @notice calculate time where username can be released * @param _label Username hash. * @return Exact time when username can be released. **/ function getExpirationTime(bytes32 _label) external view returns(uint256 releaseTime) { uint256 creationTime = accounts[_label].creationTime; if (creationTime > 0){ releaseTime = creationTime + releaseDelay; } } /** * @notice calculate reward part an account could payout on slash * @param _label Username hash. * @return Part of reward **/ function getSlashRewardPart(bytes32 _label) external view returns(uint256 partReward) { uint256 balance = accounts[_label].balance; if (balance > 0) { partReward = balance / 3; } } /** * @notice Support for "approveAndCall". Callable only by `token()`. * @param _from Who approved. * @param _amount Amount being approved, need to be equal `getPrice()`. * @param _token Token being approved, need to be equal `token()`. * @param _data Abi encoded data with selector of `register(bytes32,address,bytes32,bytes32)`. */ function receiveApproval( address _from, uint256 _amount, address _token, bytes _data ) public { require(_amount == price, "Wrong value"); require(_token == address(token), "Wrong token"); require(_token == address(msg.sender), "Wrong call"); require(_data.length <= 132, "Wrong data length"); bytes4 sig; bytes32 label; address account; bytes32 pubkeyA; bytes32 pubkeyB; (sig, label, account, pubkeyA, pubkeyB) = abiDecodeRegister(_data); require( sig == bytes4(0xb82fedbb), //bytes4(keccak256("register(bytes32,address,bytes32,bytes32)")) "Wrong method selector" ); registerUser(_from, label, account, pubkeyA, pubkeyB); } /** * @notice Continues migration of username to new registry. * @param _label Username hash. * @param _tokenBalance Amount being transfered from `parentRegistry()`. * @param _creationTime Time user registrated in `parentRegistry()` is preserved. * @param _accountOwner Account owner which migrated the account. **/ function migrateUsername( bytes32 _label, uint256 _tokenBalance, uint256 _creationTime, address _accountOwner ) external onlyParentRegistry { if (_tokenBalance > 0) { require( token.transferFrom( parentRegistry, address(this), _tokenBalance ), "Error moving funds from old registar." ); reserveAmount += _tokenBalance; } accounts[_label] = Account(_tokenBalance, _creationTime, _accountOwner); } /** * @dev callable only by parent registry to continue migration * of registry and activate registration. * @param _price The price of registration. **/ function migrateRegistry( uint256 _price ) external onlyParentRegistry { require(state == RegistrarState.Inactive, "Not Inactive"); require(ensRegistry.owner(ensNode) == address(this), "ENS registry owner not transfered."); price = _price; setState(RegistrarState.Active); emit RegistryPrice(_price); } /** * @notice Registers `_label` username to `ensNode` setting msg.sender as owner. * @param _owner Address registering the user and paying registry price. * @param _label Choosen unowned username hash. * @param _account Optional address to set at public resolver. * @param _pubkeyA Optional pubkey part A to set at public resolver. * @param _pubkeyB Optional pubkey part B to set at public resolver. */ function registerUser( address _owner, bytes32 _label, address _account, bytes32 _pubkeyA, bytes32 _pubkeyB ) internal returns(bytes32 namehash) { require(state == RegistrarState.Active, "Registry unavailable."); namehash = keccak256(abi.encodePacked(ensNode, _label)); require(ensRegistry.owner(namehash) == address(0), "ENS node already owned."); require(accounts[_label].creationTime == 0, "Username already registered."); accounts[_label] = Account(price, block.timestamp, _owner); if(price > 0) { require(token.allowance(_owner, address(this)) >= price, "Unallowed to spend."); require( token.transferFrom( _owner, address(this), price ), "Transfer failed" ); reserveAmount += price; } bool resolvePubkey = _pubkeyA != 0 || _pubkeyB != 0; bool resolveAccount = _account != address(0); if (resolvePubkey || resolveAccount) { //set to self the ownership to setup initial resolver ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, resolver); //default resolver if (resolveAccount) { resolver.setAddr(namehash, _account); } if (resolvePubkey) { resolver.setPubkey(namehash, _pubkeyA, _pubkeyB); } ensRegistry.setOwner(namehash, _owner); } else { //transfer ownership of subdone directly to registrant ensRegistry.setSubnodeOwner(ensNode, _label, _owner); } emit UsernameOwner(namehash, _owner); } /** * @dev Removes account hash of `_username` and send account.balance to msg.sender. * @param _username Username being slashed. */ function slashUsername( bytes _username, uint256 _reserveSecret ) internal { bytes32 label = keccak256(_username); bytes32 namehash = keccak256(abi.encodePacked(ensNode, label)); uint256 amountToTransfer = 0; uint256 creationTime = accounts[label].creationTime; address owner = ensRegistry.owner(namehash); if(creationTime == 0) { require( owner != address(0) || ensRegistry.resolver(namehash) != address(0), "Nothing to slash." ); } else { assert(creationTime != block.timestamp); amountToTransfer = accounts[label].balance; delete accounts[label]; } ensRegistry.setSubnodeOwner(ensNode, label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); if (amountToTransfer > 0) { reserveAmount -= amountToTransfer; uint256 partialDeposit = amountToTransfer / 3; amountToTransfer = partialDeposit * 2; // reserve 1/3 to network (controller) bytes32 secret = keccak256(abi.encodePacked(namehash, creationTime, _reserveSecret)); SlashReserve memory reserve = reservedSlashers[secret]; require(reserve.reserver != address(0), "Not reserved."); require(reserve.blockNumber < block.number, "Cannot reveal in same block"); delete reservedSlashers[secret]; require(token.transfer(reserve.reserver, amountToTransfer), "Error in transfer."); } emit UsernameOwner(namehash, address(0)); } function setState(RegistrarState _state) private { state = _state; emit RegistryState(_state); } /** * @notice recursively erase all _labels in _subnode * @param _idx recursive position of _labels to erase * @param _labels list of subnode labes * @param _subnode subnode being erased */ function eraseNodeHierarchy( uint _idx, bytes32[] _labels, bytes32 _subnode ) private { // Take ownership of the node ensRegistry.setSubnodeOwner(_subnode, _labels[_idx], address(this)); bytes32 subnode = keccak256(abi.encodePacked(_subnode, _labels[_idx])); // Recurse if there are more labels if (_idx > 0) { eraseNodeHierarchy(_idx - 1, _labels, subnode); } // Erase the resolver and owner records ensRegistry.setResolver(subnode, 0); ensRegistry.setOwner(subnode, 0); } /** * @dev Decodes abi encoded data with selector for "register(bytes32,address,bytes32,bytes32)". * @param _data Abi encoded data. * @return Decoded registry call. */ function abiDecodeRegister( bytes _data ) private pure returns( bytes4 sig, bytes32 label, address account, bytes32 pubkeyA, bytes32 pubkeyB ) { assembly { sig := mload(add(_data, add(0x20, 0))) label := mload(add(_data, 36)) account := mload(add(_data, 68)) pubkeyA := mload(add(_data, 100)) pubkeyB := mload(add(_data, 132)) } } }
contract UsernameRegistrar is Controlled, ApproveAndCallFallBack { ERC20Token public token; ENS public ensRegistry; PublicResolver public resolver; address public parentRegistry; uint256 public constant releaseDelay = 365 days; mapping (bytes32 => Account) public accounts; mapping (bytes32 => SlashReserve) reservedSlashers; //Slashing conditions uint256 public usernameMinLength; bytes32 public reservedUsernamesMerkleRoot; event RegistryState(RegistrarState state); event RegistryPrice(uint256 price); event RegistryMoved(address newRegistry); event UsernameOwner(bytes32 indexed nameHash, address owner); enum RegistrarState { Inactive, Active, Moved } bytes32 public ensNode; uint256 public price; RegistrarState public state; uint256 public reserveAmount; struct Account { uint256 balance; uint256 creationTime; address owner; } struct SlashReserve { address reserver; uint256 blockNumber; } /** * @notice Callable only by `parentRegistry()` to continue migration of ENSSubdomainRegistry. */ modifier onlyParentRegistry { require(msg.sender == parentRegistry, "Migration only."); _; } /** * @notice Initializes UsernameRegistrar contract. * The only parameter from this list that can be changed later is `_resolver`. * Other updates require a new contract and migration of domain. * @param _token ERC20 token with optional `approveAndCall(address,uint256,bytes)` for locking fee. * @param _ensRegistry Ethereum Name Service root contract address. * @param _resolver Public Resolver for resolving usernames. * @param _ensNode ENS node (domain) being used for usernames subnodes (subdomain) * @param _usernameMinLength Minimum length of usernames * @param _reservedUsernamesMerkleRoot Merkle root of reserved usernames * @param _parentRegistry Address of old registry (if any) for optional account migration. */ constructor( ERC20Token _token, ENS _ensRegistry, PublicResolver _resolver, bytes32 _ensNode, uint256 _usernameMinLength, bytes32 _reservedUsernamesMerkleRoot, address _parentRegistry ) public { require(address(_token) != address(0), "No ERC20Token address defined."); require(address(_ensRegistry) != address(0), "No ENS address defined."); require(address(_resolver) != address(0), "No Resolver address defined."); require(_ensNode != bytes32(0), "No ENS node defined."); token = _token; ensRegistry = _ensRegistry; resolver = _resolver; ensNode = _ensNode; usernameMinLength = _usernameMinLength; reservedUsernamesMerkleRoot = _reservedUsernamesMerkleRoot; parentRegistry = _parentRegistry; setState(RegistrarState.Inactive); } /** * @notice Registers `_label` username to `ensNode` setting msg.sender as owner. * Terms of name registration: * - SNT is deposited, not spent; the amount is locked up for 1 year. * - After 1 year, the user can release the name and receive their deposit back (at any time). * - User deposits are completely protected. The contract controller cannot access them. * - User&#39;s address(es) will be publicly associated with the ENS name. * - User must authorise the contract to transfer `price` `token.name()` on their behalf. * - Usernames registered with less then `usernameMinLength` characters can be slashed. * - Usernames contained in the merkle tree of root `reservedUsernamesMerkleRoot` can be slashed. * - Usernames starting with `0x` and bigger then 12 characters can be slashed. * - If terms of the contract change—e.g. Status makes contract upgrades—the user has the right to release the username and get their deposit back. * @param _label Choosen unowned username hash. * @param _account Optional address to set at public resolver. * @param _pubkeyA Optional pubkey part A to set at public resolver. * @param _pubkeyB Optional pubkey part B to set at public resolver. */ function register( bytes32 _label, address _account, bytes32 _pubkeyA, bytes32 _pubkeyB ) external returns(bytes32 namehash) { return registerUser(msg.sender, _label, _account, _pubkeyA, _pubkeyB); } /** * @notice Release username and retrieve locked fee, needs to be called * after `releasePeriod` from creation time by ENS registry owner of domain * or anytime by account owner when domain migrated to a new registry. * @param _label Username hash. */ function release( bytes32 _label ) external { bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); Account memory account = accounts[_label]; require(account.creationTime > 0, "Username not registered."); if (state == RegistrarState.Active) { require(msg.sender == ensRegistry.owner(namehash), "Not owner of ENS node."); require(block.timestamp > account.creationTime + releaseDelay, "Release period not reached."); } else { require(msg.sender == account.owner, "Not the former account owner."); } delete accounts[_label]; if (account.balance > 0) { reserveAmount -= account.balance; require(token.transfer(msg.sender, account.balance), "Transfer failed"); } if (state == RegistrarState.Active) { ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); } else { address newOwner = ensRegistry.owner(ensNode); //Low level call, case dropUsername not implemented or failing, proceed release. //Invert (!) to supress warning, return of this call have no use. !newOwner.call.gas(80000)( abi.encodeWithSignature( "dropUsername(bytes32)", _label ) ); } emit UsernameOwner(namehash, address(0)); } /** * @notice update account owner, should be called by new ens node owner * to update this contract registry, otherwise former owner can release * if domain is moved to a new registry. * @param _label Username hash. **/ function updateAccountOwner( bytes32 _label ) external { bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); require(msg.sender == ensRegistry.owner(namehash), "Caller not owner of ENS node."); require(accounts[_label].creationTime > 0, "Username not registered."); require(ensRegistry.owner(ensNode) == address(this), "Registry not owner of registry."); accounts[_label].owner = msg.sender; emit UsernameOwner(namehash, msg.sender); } /** * @notice secretly reserve the slashing reward to `msg.sender` * @param _secret keccak256(abi.encodePacked(namehash, creationTime, reserveSecret)) */ function reserveSlash(bytes32 _secret) external { require(reservedSlashers[_secret].blockNumber == 0, "Already Reserved"); reservedSlashers[_secret] = SlashReserve(msg.sender, block.number); } /** * @notice Slash username smaller then `usernameMinLength`. * @param _username Raw value of offending username. */ function slashSmallUsername( string _username, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length < usernameMinLength, "Not a small username."); slashUsername(username, _reserveSecret); } /** * @notice Slash username starting with "0x" and with length greater than 12. * @param _username Raw value of offending username. */ function slashAddressLikeUsername( string _username, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length > 12, "Too small to look like an address."); require(username[0] == byte("0"), "First character need to be 0"); require(username[1] == byte("x"), "Second character need to be x"); for(uint i = 2; i < 7; i++){ byte b = username[i]; require((b >= 48 && b <= 57) || (b >= 97 && b <= 102), "Does not look like an address"); } slashUsername(username, _reserveSecret); } /** * @notice Slash username that is exactly a reserved name. * @param _username Raw value of offending username. * @param _proof Merkle proof that name is listed on merkle tree. */ function slashReservedUsername( string _username, bytes32[] _proof, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require( MerkleProof.verifyProof( _proof, reservedUsernamesMerkleRoot, keccak256(username) ), "Invalid Proof." ); slashUsername(username, _reserveSecret); } /** * @notice Slash username that contains a non alphanumeric character. * @param _username Raw value of offending username. * @param _offendingPos Position of non alphanumeric character. */ function slashInvalidUsername( string _username, uint256 _offendingPos, uint256 _reserveSecret ) external { bytes memory username = bytes(_username); require(username.length > _offendingPos, "Invalid position."); byte b = username[_offendingPos]; require(!((b >= 48 && b <= 57) || (b >= 97 && b <= 122)), "Not invalid character."); slashUsername(username, _reserveSecret); } /** * @notice Clear resolver and ownership of unowned subdomians. * @param _labels Sequence to erase. */ function eraseNode( bytes32[] _labels ) external { uint len = _labels.length; require(len != 0, "Nothing to erase"); bytes32 label = _labels[len - 1]; bytes32 subnode = keccak256(abi.encodePacked(ensNode, label)); require(ensRegistry.owner(subnode) == address(0), "First slash/release top level subdomain"); ensRegistry.setSubnodeOwner(ensNode, label, address(this)); if(len > 1) { eraseNodeHierarchy(len - 2, _labels, subnode); } ensRegistry.setResolver(subnode, 0); ensRegistry.setOwner(subnode, 0); } /** * @notice Migrate account to new registry, opt-in to new contract. * @param _label Username hash. **/ function moveAccount( bytes32 _label, UsernameRegistrar _newRegistry ) external { require(state == RegistrarState.Moved, "Wrong contract state"); require(msg.sender == accounts[_label].owner, "Callable only by account owner."); require(ensRegistry.owner(ensNode) == address(_newRegistry), "Wrong update"); Account memory account = accounts[_label]; delete accounts[_label]; token.approve(_newRegistry, account.balance); _newRegistry.migrateUsername( _label, account.balance, account.creationTime, account.owner ); } /** * @notice Activate registration. * @param _price The price of registration. */ function activate( uint256 _price ) external onlyController { require(state == RegistrarState.Inactive, "Registry state is not Inactive"); require(ensRegistry.owner(ensNode) == address(this), "Registry does not own registry"); price = _price; setState(RegistrarState.Active); emit RegistryPrice(_price); } /** * @notice Updates Public Resolver for resolving users. * @param _resolver New PublicResolver. */ function setResolver( address _resolver ) external onlyController { resolver = PublicResolver(_resolver); } /** * @notice Updates registration price. * @param _price New registration price. */ function updateRegistryPrice( uint256 _price ) external onlyController { require(state == RegistrarState.Active, "Registry not owned"); price = _price; emit RegistryPrice(_price); } /** * @notice Transfer ownership of ensNode to `_newRegistry`. * Usernames registered are not affected, but they would be able to instantly release. * @param _newRegistry New UsernameRegistrar for hodling `ensNode` node. */ function moveRegistry( UsernameRegistrar _newRegistry ) external onlyController { require(_newRegistry != this, "Cannot move to self."); require(ensRegistry.owner(ensNode) == address(this), "Registry not owned anymore."); setState(RegistrarState.Moved); ensRegistry.setOwner(ensNode, _newRegistry); _newRegistry.migrateRegistry(price); emit RegistryMoved(_newRegistry); } /** * @notice Opt-out migration of username from `parentRegistry()`. * Clear ENS resolver and subnode owner. * @param _label Username hash. */ function dropUsername( bytes32 _label ) external onlyParentRegistry { require(accounts[_label].creationTime == 0, "Already migrated"); bytes32 namehash = keccak256(abi.encodePacked(ensNode, _label)); ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); } /** * @notice Withdraw not reserved tokens * @param _token Address of ERC20 withdrawing excess, or address(0) if want ETH. * @param _beneficiary Address to send the funds. **/ function withdrawExcessBalance( address _token, address _beneficiary ) external onlyController { require(_beneficiary != address(0), "Cannot burn token"); if (_token == address(0)) { _beneficiary.transfer(address(this).balance); } else { ERC20Token excessToken = ERC20Token(_token); uint256 amount = excessToken.balanceOf(address(this)); if(_token == address(token)){ require(amount > reserveAmount, "Is not excess"); amount -= reserveAmount; } else { require(amount > 0, "No balance"); } excessToken.transfer(_beneficiary, amount); } } /** * @notice Withdraw ens nodes not belonging to this contract. * @param _domainHash Ens node namehash. * @param _beneficiary New owner of ens node. **/ function withdrawWrongNode( bytes32 _domainHash, address _beneficiary ) external onlyController { require(_beneficiary != address(0), "Cannot burn node"); require(_domainHash != ensNode, "Cannot withdraw main node"); require(ensRegistry.owner(_domainHash) == address(this), "Not owner of this node"); ensRegistry.setOwner(_domainHash, _beneficiary); } /** * @notice Gets registration price. * @return Registration price. **/ function getPrice() external view returns(uint256 registryPrice) { return price; } /** * @notice reads amount tokens locked in username * @param _label Username hash. * @return Locked username balance. **/ function getAccountBalance(bytes32 _label) external view returns(uint256 accountBalance) { accountBalance = accounts[_label].balance; } /** * @notice reads username account owner at this contract, * which can release or migrate in case of upgrade. * @param _label Username hash. * @return Username account owner. **/ function getAccountOwner(bytes32 _label) external view returns(address owner) { owner = accounts[_label].owner; } /** * @notice reads when the account was registered * @param _label Username hash. * @return Registration time. **/ function getCreationTime(bytes32 _label) external view returns(uint256 creationTime) { creationTime = accounts[_label].creationTime; } /** * @notice calculate time where username can be released * @param _label Username hash. * @return Exact time when username can be released. **/ function getExpirationTime(bytes32 _label) external view returns(uint256 releaseTime) { uint256 creationTime = accounts[_label].creationTime; if (creationTime > 0){ releaseTime = creationTime + releaseDelay; } } /** * @notice calculate reward part an account could payout on slash * @param _label Username hash. * @return Part of reward **/ function getSlashRewardPart(bytes32 _label) external view returns(uint256 partReward) { uint256 balance = accounts[_label].balance; if (balance > 0) { partReward = balance / 3; } } /** * @notice Support for "approveAndCall". Callable only by `token()`. * @param _from Who approved. * @param _amount Amount being approved, need to be equal `getPrice()`. * @param _token Token being approved, need to be equal `token()`. * @param _data Abi encoded data with selector of `register(bytes32,address,bytes32,bytes32)`. */ function receiveApproval( address _from, uint256 _amount, address _token, bytes _data ) public { require(_amount == price, "Wrong value"); require(_token == address(token), "Wrong token"); require(_token == address(msg.sender), "Wrong call"); require(_data.length <= 132, "Wrong data length"); bytes4 sig; bytes32 label; address account; bytes32 pubkeyA; bytes32 pubkeyB; (sig, label, account, pubkeyA, pubkeyB) = abiDecodeRegister(_data); require( sig == bytes4(0xb82fedbb), //bytes4(keccak256("register(bytes32,address,bytes32,bytes32)")) "Wrong method selector" ); registerUser(_from, label, account, pubkeyA, pubkeyB); } /** * @notice Continues migration of username to new registry. * @param _label Username hash. * @param _tokenBalance Amount being transfered from `parentRegistry()`. * @param _creationTime Time user registrated in `parentRegistry()` is preserved. * @param _accountOwner Account owner which migrated the account. **/ function migrateUsername( bytes32 _label, uint256 _tokenBalance, uint256 _creationTime, address _accountOwner ) external onlyParentRegistry { if (_tokenBalance > 0) { require( token.transferFrom( parentRegistry, address(this), _tokenBalance ), "Error moving funds from old registar." ); reserveAmount += _tokenBalance; } accounts[_label] = Account(_tokenBalance, _creationTime, _accountOwner); } /** * @dev callable only by parent registry to continue migration * of registry and activate registration. * @param _price The price of registration. **/ function migrateRegistry( uint256 _price ) external onlyParentRegistry { require(state == RegistrarState.Inactive, "Not Inactive"); require(ensRegistry.owner(ensNode) == address(this), "ENS registry owner not transfered."); price = _price; setState(RegistrarState.Active); emit RegistryPrice(_price); } /** * @notice Registers `_label` username to `ensNode` setting msg.sender as owner. * @param _owner Address registering the user and paying registry price. * @param _label Choosen unowned username hash. * @param _account Optional address to set at public resolver. * @param _pubkeyA Optional pubkey part A to set at public resolver. * @param _pubkeyB Optional pubkey part B to set at public resolver. */ function registerUser( address _owner, bytes32 _label, address _account, bytes32 _pubkeyA, bytes32 _pubkeyB ) internal returns(bytes32 namehash) { require(state == RegistrarState.Active, "Registry unavailable."); namehash = keccak256(abi.encodePacked(ensNode, _label)); require(ensRegistry.owner(namehash) == address(0), "ENS node already owned."); require(accounts[_label].creationTime == 0, "Username already registered."); accounts[_label] = Account(price, block.timestamp, _owner); if(price > 0) { require(token.allowance(_owner, address(this)) >= price, "Unallowed to spend."); require( token.transferFrom( _owner, address(this), price ), "Transfer failed" ); reserveAmount += price; } bool resolvePubkey = _pubkeyA != 0 || _pubkeyB != 0; bool resolveAccount = _account != address(0); if (resolvePubkey || resolveAccount) { //set to self the ownership to setup initial resolver ensRegistry.setSubnodeOwner(ensNode, _label, address(this)); ensRegistry.setResolver(namehash, resolver); //default resolver if (resolveAccount) { resolver.setAddr(namehash, _account); } if (resolvePubkey) { resolver.setPubkey(namehash, _pubkeyA, _pubkeyB); } ensRegistry.setOwner(namehash, _owner); } else { //transfer ownership of subdone directly to registrant ensRegistry.setSubnodeOwner(ensNode, _label, _owner); } emit UsernameOwner(namehash, _owner); } /** * @dev Removes account hash of `_username` and send account.balance to msg.sender. * @param _username Username being slashed. */ function slashUsername( bytes _username, uint256 _reserveSecret ) internal { bytes32 label = keccak256(_username); bytes32 namehash = keccak256(abi.encodePacked(ensNode, label)); uint256 amountToTransfer = 0; uint256 creationTime = accounts[label].creationTime; address owner = ensRegistry.owner(namehash); if(creationTime == 0) { require( owner != address(0) || ensRegistry.resolver(namehash) != address(0), "Nothing to slash." ); } else { assert(creationTime != block.timestamp); amountToTransfer = accounts[label].balance; delete accounts[label]; } ensRegistry.setSubnodeOwner(ensNode, label, address(this)); ensRegistry.setResolver(namehash, address(0)); ensRegistry.setOwner(namehash, address(0)); if (amountToTransfer > 0) { reserveAmount -= amountToTransfer; uint256 partialDeposit = amountToTransfer / 3; amountToTransfer = partialDeposit * 2; // reserve 1/3 to network (controller) bytes32 secret = keccak256(abi.encodePacked(namehash, creationTime, _reserveSecret)); SlashReserve memory reserve = reservedSlashers[secret]; require(reserve.reserver != address(0), "Not reserved."); require(reserve.blockNumber < block.number, "Cannot reveal in same block"); delete reservedSlashers[secret]; require(token.transfer(reserve.reserver, amountToTransfer), "Error in transfer."); } emit UsernameOwner(namehash, address(0)); } function setState(RegistrarState _state) private { state = _state; emit RegistryState(_state); } /** * @notice recursively erase all _labels in _subnode * @param _idx recursive position of _labels to erase * @param _labels list of subnode labes * @param _subnode subnode being erased */ function eraseNodeHierarchy( uint _idx, bytes32[] _labels, bytes32 _subnode ) private { // Take ownership of the node ensRegistry.setSubnodeOwner(_subnode, _labels[_idx], address(this)); bytes32 subnode = keccak256(abi.encodePacked(_subnode, _labels[_idx])); // Recurse if there are more labels if (_idx > 0) { eraseNodeHierarchy(_idx - 1, _labels, subnode); } // Erase the resolver and owner records ensRegistry.setResolver(subnode, 0); ensRegistry.setOwner(subnode, 0); } /** * @dev Decodes abi encoded data with selector for "register(bytes32,address,bytes32,bytes32)". * @param _data Abi encoded data. * @return Decoded registry call. */ function abiDecodeRegister( bytes _data ) private pure returns( bytes4 sig, bytes32 label, address account, bytes32 pubkeyA, bytes32 pubkeyB ) { assembly { sig := mload(add(_data, add(0x20, 0))) label := mload(add(_data, 36)) account := mload(add(_data, 68)) pubkeyA := mload(add(_data, 100)) pubkeyB := mload(add(_data, 132)) } } }
51,153
292
// HBT tokens created per block.
uint256 public hbtPerBlock;
uint256 public hbtPerBlock;
12,078
459
// Get the epoch at the current block timestamp.Reverts if epoch zero has not started. return The current epoch number. /
function getCurrentEpoch() external view returns (uint256)
function getCurrentEpoch() external view returns (uint256)
77,558
140
// RmaxP2 = TAD - RmaxP1 Now it is safe to subtract without underflow
participant2_amount = total_available_deposit - participant1_amount;
participant2_amount = total_available_deposit - participant1_amount;
7,482
28
// Replays a cross domain message to the target messenger.@inheritdoc IL1CrossDomainMessenger / slither-disable-next-line external-function
function replayMessage( address _target, address _sender, bytes memory _message, uint256 _queueIndex, uint32 _oldGasLimit, uint32 _newGasLimit
function replayMessage( address _target, address _sender, bytes memory _message, uint256 _queueIndex, uint32 _oldGasLimit, uint32 _newGasLimit
28,687
369
// ===== Internal Core Implementations =====
function _onlyNotProtectedTokens(address _asset) internal override { require(address(want) != _asset, "want"); require(address(crv) != _asset, "crv"); require(address(cvx) != _asset, "cvx"); require(address(cvxCrv) != _asset, "cvxCrv"); }
function _onlyNotProtectedTokens(address _asset) internal override { require(address(want) != _asset, "want"); require(address(crv) != _asset, "crv"); require(address(cvx) != _asset, "cvx"); require(address(cvxCrv) != _asset, "cvxCrv"); }
8,290
34
// Transfer money to previous owner (fisher)
_owner.transfer(items[_upc].productPrice);
_owner.transfer(items[_upc].productPrice);
13,950
33
// Token Redemption
function redeem(uint256 value, bytes calldata data) external; function redeemFrom(address tokenHolder, uint256 value, bytes calldata data) external; function redeemByPartition(bytes32 partition, uint256 value, bytes calldata data) external; function operatorRedeemByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata operatorData) external;
function redeem(uint256 value, bytes calldata data) external; function redeemFrom(address tokenHolder, uint256 value, bytes calldata data) external; function redeemByPartition(bytes32 partition, uint256 value, bytes calldata data) external; function operatorRedeemByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata operatorData) external;
40,810
32
// Fired if investment for `amount` of tokens performed by `to` address
event ICOTokensInvested(address indexed to, uint amount);
event ICOTokensInvested(address indexed to, uint amount);
50,212
23
// Owner: Destroy the contract and withdraw any balance to the owner. WARNING: This is an unrecoverable operation! /
function kill() public onlyOwner { selfdestruct(_owner); }
function kill() public onlyOwner { selfdestruct(_owner); }
13,979
36
// Stack too deep
bool isCorrectFee = ((flags & kCorrectMatcherFeeByOrderAmount) != 0); if (isCorrectFee) {
bool isCorrectFee = ((flags & kCorrectMatcherFeeByOrderAmount) != 0); if (isCorrectFee) {
55,311
191
// Will be used to reactivate the sale. /
function activateSale() public onlyOwner { saleIsActive = true; }
function activateSale() public onlyOwner { saleIsActive = true; }
24,312
7
// called by the owner to pause, triggers stopped state/
function pause() onlyOwner whenNotPaused public { paused = true; Pause(); }
function pause() onlyOwner whenNotPaused public { paused = true; Pause(); }
18,580
50
// emit Offered event
emit Offered( itemCount, address(_nft), _tokenId, _price, msg.sender );
emit Offered( itemCount, address(_nft), _tokenId, _price, msg.sender );
26,962
163
// Deploy New GenericCompound First
{ address[] memory governorList = new address[](1); governorList[0] = address(_governor); address[] memory keeperList = new address[](2); keeperList[0] = 0xcC617C6f9725eACC993ac626C7efC6B96476916E; keeperList[1] = 0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185; newLender = address( new TransparentUpgradeableProxy(
{ address[] memory governorList = new address[](1); governorList[0] = address(_governor); address[] memory keeperList = new address[](2); keeperList[0] = 0xcC617C6f9725eACC993ac626C7efC6B96476916E; keeperList[1] = 0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185; newLender = address( new TransparentUpgradeableProxy(
45,161
16
// Allows for contract ownership along with multi-address authorization /
abstract contract Auth { address internal owner; constructor(address _owner) { owner = _owner; } /** * Function modifier to require caller to be contract deployer */ modifier onlyOwner() { require(isOwner(msg.sender), "!Owner"); _; } /** * Check if address is owner */ function isOwner(address account) public view returns (bool) { return account == owner; } /** * Transfer ownership to new address. Caller must be deployer. Leaves old deployer authorized */ function transferOwnership(address payable adr) public onlyOwner { owner = adr; emit OwnershipTransferred(adr); } event OwnershipTransferred(address owner); }
abstract contract Auth { address internal owner; constructor(address _owner) { owner = _owner; } /** * Function modifier to require caller to be contract deployer */ modifier onlyOwner() { require(isOwner(msg.sender), "!Owner"); _; } /** * Check if address is owner */ function isOwner(address account) public view returns (bool) { return account == owner; } /** * Transfer ownership to new address. Caller must be deployer. Leaves old deployer authorized */ function transferOwnership(address payable adr) public onlyOwner { owner = adr; emit OwnershipTransferred(adr); } event OwnershipTransferred(address owner); }
1,249
71
// Updates the maximum rank a player can reach. maxRankMaximum rank a player can reach. /
function setMaxRank(uint256 maxRank) public onlyRole(MANAGER_ROLE) { _maxRank = maxRank; }
function setMaxRank(uint256 maxRank) public onlyRole(MANAGER_ROLE) { _maxRank = maxRank; }
27,241
20
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; }
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; }
589
182
// Updates the decay multipliers and amounts for the total staked and challenged pools/This function is called in most other functions as well to keep the/ decay amounts and pools accurate
function updateDecay() external;
function updateDecay() external;
73,641
13
// Emitted when a tier is deleted
event TierDeleted(uint256 indexed tierId, address indexed clubOwner, Tier[] tiers);
event TierDeleted(uint256 indexed tierId, address indexed clubOwner, Tier[] tiers);
26,618
30
// Set governance for this token
governance = msg.sender; DOMAINSEPARATOR = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), _getChainId(), address(this)));
governance = msg.sender; DOMAINSEPARATOR = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), _getChainId(), address(this)));
23,085
13
// returns the tokenURI of tokenID
function tokenURI(uint256 tokenId) public view virtual override returns (string memory)
function tokenURI(uint256 tokenId) public view virtual override returns (string memory)
2,550
33
// payment for first segment
_transferDaiToContract();
_transferDaiToContract();
29,606
1,052
// Cannot trade past max maturity
if (maturity > maxMaturity) return false;
if (maturity > maxMaturity) return false;
4,071
126
// Check whether address belongs to a EOAaddr The address of user. return bool/
function _isEOA(address addr) internal view
function _isEOA(address addr) internal view
23,911
114
// Transfer USDT Token to Contract
getTokenFormUser_USDT(USDTToken, msg.sender, money);
getTokenFormUser_USDT(USDTToken, msg.sender, money);
38,361
2
// product id => covered token (ex. 0xc7ed.....1 -> yDAI)
mapping(address => address) public coveredToken;
mapping(address => address) public coveredToken;
49,501
20
// Alias of Fiefdoms contract owner
function overlord() external view returns (address) { return owner(); }
function overlord() external view returns (address) { return owner(); }
33,451
12
// contribute function
function() public payable { // allow to contribute only whitelisted KYC addresses assert(isWhitelisted[msg.sender]); // save contributor for further use contributors.push(Contributor({ addr: msg.sender, amount: msg.value, timestamp: block.timestamp, rejected: false })); }
function() public payable { // allow to contribute only whitelisted KYC addresses assert(isWhitelisted[msg.sender]); // save contributor for further use contributors.push(Contributor({ addr: msg.sender, amount: msg.value, timestamp: block.timestamp, rejected: false })); }
48,010
94
// Transfer tokens to contract address
transfer(address(this), _value);
transfer(address(this), _value);
79,120
25
// Did everything go to plan?
if(success) {
if(success) {
25,961
0
// Run before every test function
function beforeEach() public { bytes32 keyhash = 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4; uint fee = 1000000000000000000; address link = 0xa36085F69e2889c224210F603D836748e7dC0088; address KOVAN_VRF_COORDINATOR = 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9; diceRoller = new DiceRoller( KOVAN_VRF_COORDINATOR, link, keyhash, fee ); }
function beforeEach() public { bytes32 keyhash = 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4; uint fee = 1000000000000000000; address link = 0xa36085F69e2889c224210F603D836748e7dC0088; address KOVAN_VRF_COORDINATOR = 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9; diceRoller = new DiceRoller( KOVAN_VRF_COORDINATOR, link, keyhash, fee ); }
53,156
19
// Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts with custom message when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. /
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
44,596
95
// Transfer the tokens (only accessable from the contract).
function transferTokens(address _from, address _to) onlyFromNoundles whenNotPaused external { // Refactor this. if(_from != address(0)){ rewards[_from] += getPendingReward(_from); lastUpdate[_from] = block.timestamp; } if(_to != address(0)){ rewards[_to] += getPendingReward(_to); lastUpdate[_to] = block.timestamp; } }
function transferTokens(address _from, address _to) onlyFromNoundles whenNotPaused external { // Refactor this. if(_from != address(0)){ rewards[_from] += getPendingReward(_from); lastUpdate[_from] = block.timestamp; } if(_to != address(0)){ rewards[_to] += getPendingReward(_to); lastUpdate[_to] = block.timestamp; } }
6,581
21
// 설문지 구매
function buySurvey(address _buyer, uint _value) public { require(!isBoughtUser[_buyer]); uint value = calcSurveyPrice(); require(_value == value); isBoughtUser[_buyer] = true; // 컨트롤러의 사용자별 구매 설문 리스트에 추가 controller.addBoughtSurvey(_buyer, this); emit BuySurvey(this, _buyer, _value); }
function buySurvey(address _buyer, uint _value) public { require(!isBoughtUser[_buyer]); uint value = calcSurveyPrice(); require(_value == value); isBoughtUser[_buyer] = true; // 컨트롤러의 사용자별 구매 설문 리스트에 추가 controller.addBoughtSurvey(_buyer, this); emit BuySurvey(this, _buyer, _value); }
49,439
13
// Clear reasons for denial, entered by validators, if the application was approved.
reasonForDenial = "N/A";
reasonForDenial = "N/A";
46,324
16
// Returns the greater of two values. a the first value b the second valuereturn result the greater of the two values /
function max( uint256 a, uint256 b
function max( uint256 a, uint256 b
10,724
311
// if there isn't any redirection, nothing to be done
if(redirectionAddress == address(0)){ return; }
if(redirectionAddress == address(0)){ return; }
55,947
33
// Initializes the erc20 contract/name_ the value 'name' will be set to/symbol_ the value 'symbol' will be set to/decimals default to 18 and must be reset by an inheriting contract for/non standard decimal values
constructor(string memory name_, string memory symbol_) { // Set the state variables name = name_; symbol = symbol_; decimals = 18; // By setting these addresses to 0 attempting to execute a transfer to // either of them will revert. This is a gas efficient way to prevent // a common user mistake where they transfer to the token address. // These values are not considered 'real' tokens and so are not included // in 'total supply' which only contains minted tokens. balanceOf[address(0)] = type(uint256).max; balanceOf[address(this)] = type(uint256).max; // Optional extra state manipulation _extraConstruction(); // Computes the EIP 712 domain separator which prevents user signed messages for // this contract to be replayed in other contracts. // https://eips.ethereum.org/EIPS/eip-712 DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), block.chainid, address(this) ) ); }
constructor(string memory name_, string memory symbol_) { // Set the state variables name = name_; symbol = symbol_; decimals = 18; // By setting these addresses to 0 attempting to execute a transfer to // either of them will revert. This is a gas efficient way to prevent // a common user mistake where they transfer to the token address. // These values are not considered 'real' tokens and so are not included // in 'total supply' which only contains minted tokens. balanceOf[address(0)] = type(uint256).max; balanceOf[address(this)] = type(uint256).max; // Optional extra state manipulation _extraConstruction(); // Computes the EIP 712 domain separator which prevents user signed messages for // this contract to be replayed in other contracts. // https://eips.ethereum.org/EIPS/eip-712 DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), block.chainid, address(this) ) ); }
3,857
134
// event for token purchase logging purchaser who paid for the tokens beneficiary who got the tokens value weis paid for purchase amount amount of tokens purchased /
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
44,127
5
// File: node_modules\witnet-solidity-bridge\contracts\interfaces\IWitnetRequestBoardReporter.sol/The Witnet Request Board Reporter interface./The Witnet Foundation.
interface IWitnetRequestBoardReporter { /// Reports the Witnet-provided result to a previously posted request. /// @dev Will assume `block.timestamp` as the timestamp at which the request was solved. /// @dev Fails if: /// @dev - the `_queryId` is not in 'Posted' status. /// @dev - provided `_drTxHash` is zero; /// @dev - length of provided `_result` is zero. /// @param _queryId The unique identifier of the data request. /// @param _drTxHash The hash of the solving tally transaction in Witnet. /// @param _result The result itself as bytes. function reportResult(uint256 _queryId, bytes32 _drTxHash, bytes calldata _result) external; /// Reports the Witnet-provided result to a previously posted request. /// @dev Fails if: /// @dev - called from unauthorized address; /// @dev - the `_queryId` is not in 'Posted' status. /// @dev - provided `_drTxHash` is zero; /// @dev - length of provided `_result` is zero. /// @param _queryId The unique query identifier /// @param _timestamp The timestamp of the solving tally transaction in Witnet. /// @param _drTxHash The hash of the solving tally transaction in Witnet. /// @param _result The result itself as bytes. function reportResult(uint256 _queryId, uint256 _timestamp, bytes32 _drTxHash, bytes calldata _result) external; }
interface IWitnetRequestBoardReporter { /// Reports the Witnet-provided result to a previously posted request. /// @dev Will assume `block.timestamp` as the timestamp at which the request was solved. /// @dev Fails if: /// @dev - the `_queryId` is not in 'Posted' status. /// @dev - provided `_drTxHash` is zero; /// @dev - length of provided `_result` is zero. /// @param _queryId The unique identifier of the data request. /// @param _drTxHash The hash of the solving tally transaction in Witnet. /// @param _result The result itself as bytes. function reportResult(uint256 _queryId, bytes32 _drTxHash, bytes calldata _result) external; /// Reports the Witnet-provided result to a previously posted request. /// @dev Fails if: /// @dev - called from unauthorized address; /// @dev - the `_queryId` is not in 'Posted' status. /// @dev - provided `_drTxHash` is zero; /// @dev - length of provided `_result` is zero. /// @param _queryId The unique query identifier /// @param _timestamp The timestamp of the solving tally transaction in Witnet. /// @param _drTxHash The hash of the solving tally transaction in Witnet. /// @param _result The result itself as bytes. function reportResult(uint256 _queryId, uint256 _timestamp, bytes32 _drTxHash, bytes calldata _result) external; }
38,009
19
// Hit the 7 day pot
hitPotProcess('7', send7Pot, pickTime);
hitPotProcess('7', send7Pot, pickTime);
69,297
18
// VARS /
function init() public onlyAdmin { require(!initDone); initDone = true; whaleCard = 544244940971561611450182022165966101192029151941515963475380724124; companiesMap[0] = 865561039198320994090019029559199471223345461753643689577969591538; companiesMap[1] = 865561039198320993054179444739682765137514550166591154999543755547; companiesMap[2] = 554846819998923714678602910082262521292860787724376787491777411291; companiesMap[3] = 355671038460848535541135615183955125321318851275538745891777411291; companiesMap[4] = 146150163733090292102777780770905740002982644405466239152731821942; companiesMap[5] = 355671038460848535508878910989526070534946658842850550567444902178; companiesMap[6] = 146150163733090292102777780770905740002982644405466239152731821942; companiesMap[7] = 146150163733090292102777780770905740002982644405466239152731821942; companyCount = 8; makesMap[0] = 4605053916465184876084057218227438981618782007393731932205532781978; makesMap[1] = 2914591086370370174599913075554161534533507828594490006968556374688; makesMap[2] = 1844677902766057073279966936236223278229324254247807717511561402428; makesMap[3] = 1844677902766057073279966936236223278229324254247807717511561402428; makesMap[4] = 4605053916465184876911990996766451400782681524689254663484418928006; makesMap[5] = 4605053916465184878081670562508085129910431352928816695390378405668; makesMap[6] = 1167517659978517137984061586248765661373868143008706876811221867930; makesMap[7] = 738935227834504519292893252751116942230691621264798552983426488380; makesMap[8] = 1167517659978517139445563223579668579577552975724989896467154410906; makesMap[9] = 738935227834504520754394890082019860434376453981081572639359031356; makesMap[10] = 738935227834504523289617387884832456129379376897516570443342499703; makesMap[11] = 1167517659978517142247011557709217019077442283260142618443342499703; makesMap[12] = 467680523945888942876598267953905513549396800157884357088327079798; makeCount = 13; carsMap[0] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x5C035Bb4Cb7dacbfeE076A5e61AA39a10da2E956, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[1] = Car({locked: false, owners:[0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[2] = Car({locked: false, owners:[0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[3] = Car({locked: false, owners:[0x65A05c896d9A6f428B3936ac5db8df28752Ccd44, 0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[4] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 5 }); // solhint-disable-line max-line-length carsMap[5] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 1 }); // solhint-disable-line max-line-length carsMap[6] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[7] = Car({locked: false, owners:[0x62D5Be95C330b512b35922E347319afD708dA981, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 16200000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[8] = Car({locked: false, owners:[0x3130259deEdb3052E24FAD9d5E1f490CB8CCcaa0, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 16200000000000000, makeId: 6 }); // solhint-disable-line max-line-length carsMap[9] = Car({locked: false, owners:[0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x7396176Ac6C1ef05d57180e7733b9188B3571d9A], price: 22051440000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[10] = Car({locked: false, owners:[0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x5e4b61220039823aeF8a54EfBe47773194494f77], price: 37046419200000000, makeId: 11}); // solhint-disable-line max-line-length carsMap[11] = Car({locked: false, owners:[0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[12] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 7 }); // solhint-disable-line max-line-length carsMap[13] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[14] = Car({locked: false, owners:[0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 11}); // solhint-disable-line max-line-length carsMap[15] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 8 }); // solhint-disable-line max-line-length carsMap[16] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 9 }); // solhint-disable-line max-line-length carsMap[17] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 2 }); // solhint-disable-line max-line-length carsMap[18] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 3 }); // solhint-disable-line max-line-length carsMap[19] = Car({locked: false, owners:[0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 6 }); // solhint-disable-line max-line-length carsMap[20] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0xE9cfDadEa5FA5475861B62aA7d5dAA493C377122, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[21] = Car({locked: false, owners:[0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[22] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 12}); // solhint-disable-line max-line-length carsMap[23] = Car({locked: false, owners:[0xac2b4B94eCA37Cb7c9cF7062fEfB2792c5792731, 0x263b604509D6a825719859Ee458b2D91fb7d330D, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000], price: 13284000000000000, makeId: 12}); //solhint-disable-line max-line-length carsMap[24] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 2 }); // solhint-disable-line max-line-length carsMap[25] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 12}); // solhint-disable-line max-line-length carsMap[26] = Car({locked: false, owners:[0x9bD750685bF5bfCe24d1B8DE03a1ff3D2631ef5a, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 11}); // solhint-disable-line max-line-length carCount = 27; }
function init() public onlyAdmin { require(!initDone); initDone = true; whaleCard = 544244940971561611450182022165966101192029151941515963475380724124; companiesMap[0] = 865561039198320994090019029559199471223345461753643689577969591538; companiesMap[1] = 865561039198320993054179444739682765137514550166591154999543755547; companiesMap[2] = 554846819998923714678602910082262521292860787724376787491777411291; companiesMap[3] = 355671038460848535541135615183955125321318851275538745891777411291; companiesMap[4] = 146150163733090292102777780770905740002982644405466239152731821942; companiesMap[5] = 355671038460848535508878910989526070534946658842850550567444902178; companiesMap[6] = 146150163733090292102777780770905740002982644405466239152731821942; companiesMap[7] = 146150163733090292102777780770905740002982644405466239152731821942; companyCount = 8; makesMap[0] = 4605053916465184876084057218227438981618782007393731932205532781978; makesMap[1] = 2914591086370370174599913075554161534533507828594490006968556374688; makesMap[2] = 1844677902766057073279966936236223278229324254247807717511561402428; makesMap[3] = 1844677902766057073279966936236223278229324254247807717511561402428; makesMap[4] = 4605053916465184876911990996766451400782681524689254663484418928006; makesMap[5] = 4605053916465184878081670562508085129910431352928816695390378405668; makesMap[6] = 1167517659978517137984061586248765661373868143008706876811221867930; makesMap[7] = 738935227834504519292893252751116942230691621264798552983426488380; makesMap[8] = 1167517659978517139445563223579668579577552975724989896467154410906; makesMap[9] = 738935227834504520754394890082019860434376453981081572639359031356; makesMap[10] = 738935227834504523289617387884832456129379376897516570443342499703; makesMap[11] = 1167517659978517142247011557709217019077442283260142618443342499703; makesMap[12] = 467680523945888942876598267953905513549396800157884357088327079798; makeCount = 13; carsMap[0] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x5C035Bb4Cb7dacbfeE076A5e61AA39a10da2E956, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[1] = Car({locked: false, owners:[0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[2] = Car({locked: false, owners:[0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[3] = Car({locked: false, owners:[0x65A05c896d9A6f428B3936ac5db8df28752Ccd44, 0x71f35825a3B1528859dFa1A64b24242BC0d12990, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 13122000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[4] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 5 }); // solhint-disable-line max-line-length carsMap[5] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 1 }); // solhint-disable-line max-line-length carsMap[6] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 10000000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[7] = Car({locked: false, owners:[0x62D5Be95C330b512b35922E347319afD708dA981, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 16200000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[8] = Car({locked: false, owners:[0x3130259deEdb3052E24FAD9d5E1f490CB8CCcaa0, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 16200000000000000, makeId: 6 }); // solhint-disable-line max-line-length carsMap[9] = Car({locked: false, owners:[0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x7396176Ac6C1ef05d57180e7733b9188B3571d9A], price: 22051440000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[10] = Car({locked: false, owners:[0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x5e4b61220039823aeF8a54EfBe47773194494f77], price: 37046419200000000, makeId: 11}); // solhint-disable-line max-line-length carsMap[11] = Car({locked: false, owners:[0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 4 }); // solhint-disable-line max-line-length carsMap[12] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x7396176Ac6C1ef05d57180e7733b9188B3571d9A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 7 }); // solhint-disable-line max-line-length carsMap[13] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[14] = Car({locked: false, owners:[0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 11}); // solhint-disable-line max-line-length carsMap[15] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x5e4b61220039823aeF8a54EfBe47773194494f77, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 8 }); // solhint-disable-line max-line-length carsMap[16] = Car({locked: false, owners:[0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 9 }); // solhint-disable-line max-line-length carsMap[17] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x558F42Baf1A9352A955D301Fa644AD0F619B97d9, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 2 }); // solhint-disable-line max-line-length carsMap[18] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 3 }); // solhint-disable-line max-line-length carsMap[19] = Car({locked: false, owners:[0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x19fC7935fd9D0BC335b4D0df3bE86eD51aD2E62A, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 6 }); // solhint-disable-line max-line-length carsMap[20] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0xE9cfDadEa5FA5475861B62aA7d5dAA493C377122, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 10}); // solhint-disable-line max-line-length carsMap[21] = Car({locked: false, owners:[0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 0 }); // solhint-disable-line max-line-length carsMap[22] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 12}); // solhint-disable-line max-line-length carsMap[23] = Car({locked: false, owners:[0xac2b4B94eCA37Cb7c9cF7062fEfB2792c5792731, 0x263b604509D6a825719859Ee458b2D91fb7d330D, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000], price: 13284000000000000, makeId: 12}); //solhint-disable-line max-line-length carsMap[24] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x308e9C99Ac194101C971FFcAca897AC943843dE8, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 2 }); // solhint-disable-line max-line-length carsMap[25] = Car({locked: false, owners:[0x5632CA98e5788edDB2397757Aa82d1Ed6171e5aD, 0x504Af27f1Cef15772370b7C04b5D9d593Ee729f5, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 12}); // solhint-disable-line max-line-length carsMap[26] = Car({locked: false, owners:[0x9bD750685bF5bfCe24d1B8DE03a1ff3D2631ef5a, 0x3177Abbe93422c9525652b5d4e1101a248A99776, 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000], price: 8100000000000000, makeId: 11}); // solhint-disable-line max-line-length carCount = 27; }
11,750
0
// _ctsiAddress address of token instance being used/_stakingAddress address of StakingInterface/_workerAuthAddress address of worker manager contract/_difficultyAdjustmentParameter how quickly the difficulty gets updated/_targetInterval how often we want to elect a block producer/_rewardValue reward that reward manager contract pays/_rewardDelay number of blocks confirmation before a reward can be claimed/_version protocol version of PoS
function createNewChain( address _ctsiAddress, address _stakingAddress, address _workerAuthAddress,
function createNewChain( address _ctsiAddress, address _stakingAddress, address _workerAuthAddress,
6,880
128
// YairNieto Yair Nieto /
contract YairNieto is ERC1155, ERC1155Supply, ERC1155Burnable, Ownable { string public name; string public symbol; mapping(uint => string) private tokenURI; constructor() ERC1155( "" ) { name = "Yair Nieto"; symbol = "YN"; } function mint( address _account, uint256 _id, uint256 _amount, bytes memory _data ) public onlyOwner { _mint(_account, _id, _amount, _data); } function mintBatch( address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data ) public onlyOwner { _mintBatch(_to, _ids, _amounts, _data); } function setURI( uint256 _id, string memory _uri ) external onlyOwner { require(exists(_id)); tokenURI[_id] = _uri; emit URI(_uri, _id); } function getURI( uint256 _id ) external view onlyOwner returns (string memory) { require(exists(_id)); return tokenURI[_id]; } // The following functions are overrides required by Solidity. function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override(ERC1155, ERC1155Supply) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } }
contract YairNieto is ERC1155, ERC1155Supply, ERC1155Burnable, Ownable { string public name; string public symbol; mapping(uint => string) private tokenURI; constructor() ERC1155( "" ) { name = "Yair Nieto"; symbol = "YN"; } function mint( address _account, uint256 _id, uint256 _amount, bytes memory _data ) public onlyOwner { _mint(_account, _id, _amount, _data); } function mintBatch( address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data ) public onlyOwner { _mintBatch(_to, _ids, _amounts, _data); } function setURI( uint256 _id, string memory _uri ) external onlyOwner { require(exists(_id)); tokenURI[_id] = _uri; emit URI(_uri, _id); } function getURI( uint256 _id ) external view onlyOwner returns (string memory) { require(exists(_id)); return tokenURI[_id]; } // The following functions are overrides required by Solidity. function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override(ERC1155, ERC1155Supply) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } }
28,660
4
// Set the job id _jobId This is the jobid from the list of jobs available in our case it is a HTTP GET request /
function setJobId(bytes32 _jobId) external onlyOwner { jobId = _jobId; }
function setJobId(bytes32 _jobId) external onlyOwner { jobId = _jobId; }
20,570
172
// Private function to remove a token from this extension's token tracking data structures. This has O(1) time complexity, but alters the order of the _allTokens array.tokenId uint256 ID of the token to be removed from the tokens list/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); }
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); }
76,364
2
// Check is created
require(!uniquePairs[pairKey], "You've already followed this address."); _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(tx.origin, newItemId);
require(!uniquePairs[pairKey], "You've already followed this address."); _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(tx.origin, newItemId);
28,221
1
// Symbol or Ticker
string public symbol = "DEV";
string public symbol = "DEV";
9,739
160
// We calculate bonus based on percent left. Eg 100% of the time remaining, means a 30% bonus. 50% of the time remaining, means a 15% bonus. MAX_TIME_BONUS_PERCENT is a constant set to 30 (double-check on review) Max example with 1 ETH contribute: 301001eth / 10000 = 0.3eth Low end (towards the end of LSW) > 0 example MAX_TIME_BONUS_PERCENT == 7; 3071eth / 10000 = 0.021 eth Min example MAX_TIME_BONUS_PERCENT == 0; returns 0/ 100 % bonus/ 301001e18/10000 == 0.31e18/ Dust numbers/ 301001/10000 == 0
uint256 bonus = MAX_TIME_BONUS_PERCENT.mul(percentLeft).mul(depositValue).div(10000); require(depositValue.mul(31).div(100) > bonus , "Sanity check failure bonus"); return bonus;
uint256 bonus = MAX_TIME_BONUS_PERCENT.mul(percentLeft).mul(depositValue).div(10000); require(depositValue.mul(31).div(100) > bonus , "Sanity check failure bonus"); return bonus;
79,255
50
// transfer all pud to owner account.
pud.transfer(msg.sender, pudBalance);
pud.transfer(msg.sender, pudBalance);
39,611
138
// swap on Smoothy
swapOnSmoothyV1( fromToken, toToken, fromAmount.mul(route[i].percent).div(10000), route[i].targetExchange, route[i].payload );
swapOnSmoothyV1( fromToken, toToken, fromAmount.mul(route[i].percent).div(10000), route[i].targetExchange, route[i].payload );
36,251
55
// - Steps the Queue be replacing the first element with the next valid credit line's ID - Only works if the first element in the queue is null /
function stepQ() external { ids.stepQ(); }
function stepQ() external { ids.stepQ(); }
3,804
277
// Approvals: Staking Pool
cvxToken.approve(address(cvxRewardsPool), MAX_UINT_256);
cvxToken.approve(address(cvxRewardsPool), MAX_UINT_256);
61,927
91
// 返回当前参与到投注的彩民人数
function getPlayersNum() public view returns(uint){ uint _sum = 0; for(uint i=0; i<12; i++){ _sum += lotteryPlayers[i].length; } return _sum; }
function getPlayersNum() public view returns(uint){ uint _sum = 0; for(uint i=0; i<12; i++){ _sum += lotteryPlayers[i].length; } return _sum; }
2,719
1
// someValue = 321;
Dummy dummyInstance = new Dummy(); dummyInstance.initialize(); emit Debug(address(dummyInstance));
Dummy dummyInstance = new Dummy(); dummyInstance.initialize(); emit Debug(address(dummyInstance));
2,742
242
// The yield reawrd token
address public token;
address public token;
70,333
217
// masterchef rewards pool ID
function _setPoolId(uint256 _value) internal { setUint256(_POOLID_SLOT, _value); }
function _setPoolId(uint256 _value) internal { setUint256(_POOLID_SLOT, _value); }
37,263
25
// Ico constants
uint public icoStart = 1521867660; //24.03.2018 uint public icoFinish = 1524632340; //24.04.2018 uint icoMinCap = 100000000*pow(10,decimals); uint icoMaxCap = 550000000*pow(10,decimals);
uint public icoStart = 1521867660; //24.03.2018 uint public icoFinish = 1524632340; //24.04.2018 uint icoMinCap = 100000000*pow(10,decimals); uint icoMaxCap = 550000000*pow(10,decimals);
36,843
25
// Set the AddressManager in the ProxyAdmin.
config.globalConfig.proxyAdmin.setAddressManager(config.globalConfig.addressManager);
config.globalConfig.proxyAdmin.setAddressManager(config.globalConfig.addressManager);
23,816
174
// Get the current valid order for the asset or fail
Order memory order = _getValidOrder( _nftAddress, _orderId ); IERC20 acceptedToken = IERC20(order.payTokenAddress);
Order memory order = _getValidOrder( _nftAddress, _orderId ); IERC20 acceptedToken = IERC20(order.payTokenAddress);
21,837
6
// This contract is a helper that will create new Proposal (i.e. voting) if the action is not allowed directly
contract AutoDaoBaseActionCaller is GenericCaller { function AutoDaoBaseActionCaller(IDaoBase _mc)public GenericCaller(_mc) { } function addGroupMemberAuto(string _group, address _a) public returns(address proposalOut){ // TODO: implement assert(false); /* bytes32[] memory params = new bytes32[](2); params[0] = bytes32(_group); params[1] = bytes32(_a); return doAction("manageGroups", mc, msg.sender,"addGroupMemberGeneric(bytes32[])",params); */ } function issueTokensAuto(address _to, uint _amount) public returns(address proposalOut){ bytes32[] memory params = new bytes32[](2); params[0] = bytes32(_to); params[1] = bytes32(_amount); return doAction("issueTokens", mc, msg.sender,"issueTokensGeneric(bytes32[])",params); } function upgradeDaoContractAuto(address _newMc) public returns(address proposalOut){ bytes32[] memory params = new bytes32[](1); params[0] = bytes32(_newMc); return doAction("upgradeDaoContract", mc, msg.sender,"upgradeDaoContractGeneric(bytes32[])",params); } }
contract AutoDaoBaseActionCaller is GenericCaller { function AutoDaoBaseActionCaller(IDaoBase _mc)public GenericCaller(_mc) { } function addGroupMemberAuto(string _group, address _a) public returns(address proposalOut){ // TODO: implement assert(false); /* bytes32[] memory params = new bytes32[](2); params[0] = bytes32(_group); params[1] = bytes32(_a); return doAction("manageGroups", mc, msg.sender,"addGroupMemberGeneric(bytes32[])",params); */ } function issueTokensAuto(address _to, uint _amount) public returns(address proposalOut){ bytes32[] memory params = new bytes32[](2); params[0] = bytes32(_to); params[1] = bytes32(_amount); return doAction("issueTokens", mc, msg.sender,"issueTokensGeneric(bytes32[])",params); } function upgradeDaoContractAuto(address _newMc) public returns(address proposalOut){ bytes32[] memory params = new bytes32[](1); params[0] = bytes32(_newMc); return doAction("upgradeDaoContract", mc, msg.sender,"upgradeDaoContractGeneric(bytes32[])",params); } }
1,824
40
// Definition of the structure of a Key. Specification: Keys are cryptographic public keys, or contract addresses associated with this identity.The structure should be as follows:- key: A public key owned by this identity - purposes: uint256[] Array of the key purposes, like 1 = MANAGEMENT, 2 = EXECUTION - keyType: The type of key used, which would be a uint256 for different key types. e.g. 1 = ECDSA, 2 = RSA, etc. /
struct Key { uint256[] purposes; uint256 keyType; bytes32 key; }
struct Key { uint256[] purposes; uint256 keyType; bytes32 key; }
86,688