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 |
|---|---|---|---|---|
274 | // Mints FUD/ | function mintFUD(uint256 noOfTokens) public {
require(mintIsActive, "FUDZ minting is not active");
require(ERC721(regenz).balanceOf(msg.sender) >= noOfTokens, "You must hold same amount of Regenz to mint FUDz");
require(totalSupply()+noOfTokens <= MAX_FUDZ, "mint will exceed max supply");
uint256 minted = 0;
for(uint256 i=0; i<ERC721(regenz).balanceOf(msg.sender); i++) {
if(!hasMintedFUDRegenzId[ERC721(regenz).tokenOfOwnerByIndex(msg.sender, i)]) {
uint mintIndex = totalSupply();
if (totalSupply() < MAX_FUDZ) {
hasMintedFUDRegenzId[ERC721(regenz).tokenOfOwnerByIndex(msg.sender, i)] = true;
_safeMint(msg.sender, mintIndex);
minted++;
}
}
if(minted == noOfTokens)
break;
}
}
| function mintFUD(uint256 noOfTokens) public {
require(mintIsActive, "FUDZ minting is not active");
require(ERC721(regenz).balanceOf(msg.sender) >= noOfTokens, "You must hold same amount of Regenz to mint FUDz");
require(totalSupply()+noOfTokens <= MAX_FUDZ, "mint will exceed max supply");
uint256 minted = 0;
for(uint256 i=0; i<ERC721(regenz).balanceOf(msg.sender); i++) {
if(!hasMintedFUDRegenzId[ERC721(regenz).tokenOfOwnerByIndex(msg.sender, i)]) {
uint mintIndex = totalSupply();
if (totalSupply() < MAX_FUDZ) {
hasMintedFUDRegenzId[ERC721(regenz).tokenOfOwnerByIndex(msg.sender, i)] = true;
_safeMint(msg.sender, mintIndex);
minted++;
}
}
if(minted == noOfTokens)
break;
}
}
| 13,949 |
121 | // Create new Maker vault | function createVault() external onlyGovernor {
cm.createVault(collateralType);
}
| function createVault() external onlyGovernor {
cm.createVault(collateralType);
}
| 33,138 |
233 | // Transfer tokens from one address to another. from The address which you want to send tokens from to The address which you want to transfer to value the amount of tokens to be transferredreturn A boolean that indicates if the operation was successful. / | function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
| function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
| 37,881 |
21 | // Check if owner or if contract is open. This works for the AddTower function so owner (developer) can already add Towers.Note that if contract is open it cannot be closed anymore.If value is send it will be reverted if you are not owner or the contract is not open. | modifier onlyOpenOrOwner(){
if (open || msg.sender == owner){
_;
}
else{
revert();
}
}
| modifier onlyOpenOrOwner(){
if (open || msg.sender == owner){
_;
}
else{
revert();
}
}
| 21,195 |
42 | // sessionID {uint256} - id of the layer 1 stake | function unstakeV1(uint256 sessionId) external pausable {
| function unstakeV1(uint256 sessionId) external pausable {
| 37,825 |
18 | // returns tickets numbers for the current draw in the possession of specified address | function getTicketsAtAdress(address _address) public view returns(uint[]) {
uint[] memory result = new uint[](getTicketsCount(_address));
uint num = 0;
for(uint i = 0; i < ticketsNum; i++) {
if(getAddress(tickets[i]) == _address) {
result[num] = i;
num++;
}
}
return result;
}
| function getTicketsAtAdress(address _address) public view returns(uint[]) {
uint[] memory result = new uint[](getTicketsCount(_address));
uint num = 0;
for(uint i = 0; i < ticketsNum; i++) {
if(getAddress(tickets[i]) == _address) {
result[num] = i;
num++;
}
}
return result;
}
| 17,877 |
14 | // Mint METAMILLIONAIRE By User / | function mintByOwner(address _to, uint256 _amount)
public
payable
checkSaleIsActive
| function mintByOwner(address _to, uint256 _amount)
public
payable
checkSaleIsActive
| 17,137 |
82 | // We can rely on the value of now (block.timestamp) for our purposes, as the consensus rule is that a block's timestamp must be 1) more than the parent's block timestamp; and 2) less than the current wall clock time. See: https:github.com/ethereum/go-ethereum/blob/885c13c/consensus/ethash/consensus.goL223 | function getBlockTimestamp() internal view returns (uint) {
return now;
}
| function getBlockTimestamp() internal view returns (uint) {
return now;
}
| 48,170 |
104 | // A checkpoint for marking number of votes from a given block | struct Checkpoint {
uint256 fromBlock;
uint256 votes;
}
| struct Checkpoint {
uint256 fromBlock;
uint256 votes;
}
| 8,720 |
493 | // Info for incremental adjustments to control variable | struct Adjust {
bool add; // addition or subtraction
uint rate; // increment
uint target; // BCV when adjustment finished
uint buffer; // minimum length (in blocks) between adjustments
uint lastBlock; // block when last adjustment made
}
| struct Adjust {
bool add; // addition or subtraction
uint rate; // increment
uint target; // BCV when adjustment finished
uint buffer; // minimum length (in blocks) between adjustments
uint lastBlock; // block when last adjustment made
}
| 12,429 |
13 | // `interfaceIds`. Support for {IERC165} itself is queried automatically. Batch-querying can lead to gas savings by skipping repeated checks for{IERC165} support. See {IERC165-supportsInterface}. / | function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
| function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
| 10,178 |
19 | // set a new CS representative / | function setCS(address newCS) onlyOwner {
cs = newCS;
}
| function setCS(address newCS) onlyOwner {
cs = newCS;
}
| 21,408 |
205 | // https:ethereum.stackexchange.com/a/96646 | uint256 twos = (type(uint256).max - denominator + 1) & denominator;
| uint256 twos = (type(uint256).max - denominator + 1) & denominator;
| 57,844 |
86 | // eth deployer with gas reduction: https:etherscan.io/address/deployer.ethcode |
IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c);
address owner;
|
IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c);
address owner;
| 6,249 |
49 | // Initialize/_traderFeePercent trader fee percentage in unit of 100, i.e. 100 == 1% and 5 == 0.05% and 10000 == 100%/_investorFeePercent investor fee percentage | function initialize(
uint256 _traderFeePercent,
uint256 _investorFeePercent)
public
initializer
| function initialize(
uint256 _traderFeePercent,
uint256 _investorFeePercent)
public
initializer
| 13,315 |
16 | // Event emitted when an address authorises an operator (third-party). Emits event that informs of address approving/denying a third-party operator. wallet Address of the wallet configuring it's operator. operator Address of the third-party operator that interacts on behalf of the wallet. approved A boolean indicating whether approval was granted or revoked. / | event ApprovalForAll(address indexed wallet, address indexed operator, bool approved);
| event ApprovalForAll(address indexed wallet, address indexed operator, bool approved);
| 45,892 |
177 | // When the protocol is recollateralizing, we need to give a discount of Shares to hit the new CR target Thus, if the target collateral ratio is higher than the actual value of collateral, minters get Shares for adding collateral This function simply rewards anyone that sends collateral to a pool with the same amount of Shares + the bonus rate Anyone can call this function to recollateralize the protocol and take the extra Shares value from the bonus rate as an arb opportunity | function recollateralizeUSE(uint256 collateral_amount, uint256 shares_out_min) external onlyOneBlock {
require(recollateralizePaused == false, "Recollateralize is paused");
updateOraclePrice();
uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals);
uint256 share_price = USE.share_price();
uint256 use_total_supply = USE.totalSupply().sub(global_use_supply_adj);
uint256 global_collateral_ratio = USE.global_collateral_ratio();
uint256 global_collat_value = USE.globalCollateralValue();
(uint256 collateral_units, uint256 amount_to_recollat) = calcRecollateralizeUSEInner(
collateral_amount_d18,
getCollateralPrice(),
global_collat_value,
use_total_supply,
global_collateral_ratio
);
uint256 collateral_units_precision = collateral_units.div(10 ** missing_decimals);
uint256 shares_paid_back = amount_to_recollat.mul(uint(1e6).add(bonus_rate).sub(recollat_tax)).div(share_price);
require(shares_out_min <= shares_paid_back, "Slippage limit reached");
community_rate_in_share = community_rate_in_share.add(shares_paid_back.mul(community_rate_ratio).div(PRECISION));
collateral_token.transferFrom(msg.sender, address(this), collateral_units_precision);
SHARE.pool_mint(msg.sender, shares_paid_back);
}
| function recollateralizeUSE(uint256 collateral_amount, uint256 shares_out_min) external onlyOneBlock {
require(recollateralizePaused == false, "Recollateralize is paused");
updateOraclePrice();
uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals);
uint256 share_price = USE.share_price();
uint256 use_total_supply = USE.totalSupply().sub(global_use_supply_adj);
uint256 global_collateral_ratio = USE.global_collateral_ratio();
uint256 global_collat_value = USE.globalCollateralValue();
(uint256 collateral_units, uint256 amount_to_recollat) = calcRecollateralizeUSEInner(
collateral_amount_d18,
getCollateralPrice(),
global_collat_value,
use_total_supply,
global_collateral_ratio
);
uint256 collateral_units_precision = collateral_units.div(10 ** missing_decimals);
uint256 shares_paid_back = amount_to_recollat.mul(uint(1e6).add(bonus_rate).sub(recollat_tax)).div(share_price);
require(shares_out_min <= shares_paid_back, "Slippage limit reached");
community_rate_in_share = community_rate_in_share.add(shares_paid_back.mul(community_rate_ratio).div(PRECISION));
collateral_token.transferFrom(msg.sender, address(this), collateral_units_precision);
SHARE.pool_mint(msg.sender, shares_paid_back);
}
| 1,129 |
24 | // If the user has not placed any bet return -1 | return(-1, -1);
| return(-1, -1);
| 27,029 |
12 | // Withdraw a certain amount of staked LRC for an exchange to the given address./This function is meant to be called only from within exchange contracts./ exchangeId The id of the exchange/ recipient The address to receive LRC/ requestedAmount The amount of LRC to withdraw/ return stakedLRC The amount of LRC withdrawn | function withdrawExchangeStake(
uint exchangeId,
address recipient,
uint requestedAmount
)
public
returns (uint amount);
| function withdrawExchangeStake(
uint exchangeId,
address recipient,
uint requestedAmount
)
public
returns (uint amount);
| 50,094 |
188 | // Get the payout for a trader for a given set of epochs | function getTraderPayout(address _target, uint16[] memory _epochs) public view returns (uint256) {
uint256 totalPayout = 0;
for (uint256 i = 0; i < allExchangeAddresses.length; i++) {
for (uint256 j = 0; j < _epochs.length; j++) {
Epoch storage epochEntry = getEpochOrDie(allExchangeAddresses[i], _epochs[j]);
totalPayout = totalPayout.add(calculateTraderPayout(epochEntry, _target));
}
}
return totalPayout;
}
| function getTraderPayout(address _target, uint16[] memory _epochs) public view returns (uint256) {
uint256 totalPayout = 0;
for (uint256 i = 0; i < allExchangeAddresses.length; i++) {
for (uint256 j = 0; j < _epochs.length; j++) {
Epoch storage epochEntry = getEpochOrDie(allExchangeAddresses[i], _epochs[j]);
totalPayout = totalPayout.add(calculateTraderPayout(epochEntry, _target));
}
}
return totalPayout;
}
| 7,283 |
232 | // returns sorted token addresses, used to handle return values from pairs sorted in this order/tokenA The address of tokenA/tokenB The address of tokenB/ return token0 token1 Sorted asc addresses of tokens | function sortTokens(address tokenA, address tokenB)
internal
pure
returns (address token0, address token1)
| function sortTokens(address tokenA, address tokenB)
internal
pure
returns (address token0, address token1)
| 25,176 |
103 | // The Hyra Alpha Token itself is just a standard BEP20, with:No minting.Public burning.Transfer fee applied. / | contract HYRA is DeflationaryBEP20 {
// symbol = HYRA
// name = Hyra Alpha
// maximum supply = 50,000 HYRA
// website = https://www.hyralpha.com
constructor() DeflationaryBEP20("Hyra Alpha", "HYRA", msg.sender) public {
_mint(msg.sender, 50000e18);
}
function burn(uint256 amount) public {
_burn(msg.sender, amount);
}
} | contract HYRA is DeflationaryBEP20 {
// symbol = HYRA
// name = Hyra Alpha
// maximum supply = 50,000 HYRA
// website = https://www.hyralpha.com
constructor() DeflationaryBEP20("Hyra Alpha", "HYRA", msg.sender) public {
_mint(msg.sender, 50000e18);
}
function burn(uint256 amount) public {
_burn(msg.sender, amount);
}
} | 13,862 |
89 | // Give an account access to this role. / | function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| 7,772 |
21 | // method to update the cancellation fee cancellationFee the fee amount to collateralize against a proposal cancellation / | function updateCancellationFee(uint256 cancellationFee) external;
| function updateCancellationFee(uint256 cancellationFee) external;
| 26,713 |
134 | // NOTE: fixed wrong parameter issue, now using parameters from oldRef instead of the callers | }else if( _max - (_claimed + available )>0 && oldRef != firstAddress){
| }else if( _max - (_claimed + available )>0 && oldRef != firstAddress){
| 29,643 |
166 | // map control token ID to its buy price | mapping (uint256 => uint256) public buyPrices;
| mapping (uint256 => uint256) public buyPrices;
| 12,731 |
13 | // Returns uint256 `value` as int256. / | function uint256ToInt256(uint256 value) public pure returns (int256) {
require(value <= uint256(type(int256).max), "Value does not fit in an int256");
return int256(value);
}
| function uint256ToInt256(uint256 value) public pure returns (int256) {
require(value <= uint256(type(int256).max), "Value does not fit in an int256");
return int256(value);
}
| 21,926 |
35 | // Only 8 wonders should ever exist (0-7) | require(newWonderId < 8);
_transfer(0, _owner, newWonderId);
return newWonderId;
| require(newWonderId < 8);
_transfer(0, _owner, newWonderId);
return newWonderId;
| 18,709 |
188 | // Standard ERC721 Errors / | interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
| interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
| 9,972 |
144 | // calcPoolInGivenSingleOut pAi = poolAmountIn/ tAo \\ / wO \ \bO = tokenBalanceOut | bO - -------------------------- |\ | ---- | \ tAo = tokenAmountOutpS - || \ 1 - ((1 - (tO / tW))sF)/| ^ \ tW / pS |ps = poolSupply \\ -----------------------------------// wO = tokenWeightOutpAi = \\ bO //tW = totalWeight ------------------------------------------------------------- sF = swapFee( 1 - eF ) eF = exitFee/ | ) internal pure returns (uint256 poolAmountIn) {
// charge swap fee on the output token side
uint256 normalizedWeight = bdiv(tokenWeightOut, totalWeight);
//uint tAoBeforeSwapFee = tAo / (1 - (1-weightTo) * swapFee) ;
uint256 zoo = bsub(BONE, normalizedWeight);
uint256 zar = bmul(zoo, swapFee);
uint256 tokenAmountOutBeforeSwapFee = bdiv(tokenAmountOut, bsub(BONE, zar));
uint256 newTokenBalanceOut = bsub(
tokenBalanceOut,
tokenAmountOutBeforeSwapFee
);
uint256 tokenOutRatio = bdiv(newTokenBalanceOut, tokenBalanceOut);
//uint newPoolSupply = (ratioTo ^ weightTo) * poolSupply;
uint256 poolRatio = bpow(tokenOutRatio, normalizedWeight);
uint256 newPoolSupply = bmul(poolRatio, poolSupply);
uint256 poolAmountInAfterExitFee = bsub(poolSupply, newPoolSupply);
// charge exit fee on the pool token side
// pAi = pAiAfterExitFee/(1-exitFee)
poolAmountIn = bdiv(poolAmountInAfterExitFee, bsub(BONE, EXIT_FEE));
return poolAmountIn;
}
| ) internal pure returns (uint256 poolAmountIn) {
// charge swap fee on the output token side
uint256 normalizedWeight = bdiv(tokenWeightOut, totalWeight);
//uint tAoBeforeSwapFee = tAo / (1 - (1-weightTo) * swapFee) ;
uint256 zoo = bsub(BONE, normalizedWeight);
uint256 zar = bmul(zoo, swapFee);
uint256 tokenAmountOutBeforeSwapFee = bdiv(tokenAmountOut, bsub(BONE, zar));
uint256 newTokenBalanceOut = bsub(
tokenBalanceOut,
tokenAmountOutBeforeSwapFee
);
uint256 tokenOutRatio = bdiv(newTokenBalanceOut, tokenBalanceOut);
//uint newPoolSupply = (ratioTo ^ weightTo) * poolSupply;
uint256 poolRatio = bpow(tokenOutRatio, normalizedWeight);
uint256 newPoolSupply = bmul(poolRatio, poolSupply);
uint256 poolAmountInAfterExitFee = bsub(poolSupply, newPoolSupply);
// charge exit fee on the pool token side
// pAi = pAiAfterExitFee/(1-exitFee)
poolAmountIn = bdiv(poolAmountInAfterExitFee, bsub(BONE, EXIT_FEE));
return poolAmountIn;
}
| 56,512 |
308 | // Max contributors reached | uint256 internal constant MAX_CONTRIBUTORS = 61;
| uint256 internal constant MAX_CONTRIBUTORS = 61;
| 42,397 |
131 | // if (token == USDTAddr) { return success; } | return (success && (data.length == 0 || abi.decode(data, (bool))));
| return (success && (data.length == 0 || abi.decode(data, (bool))));
| 81,076 |
34 | // Flag for check | bool flag;
| bool flag;
| 20,490 |
146 | // _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD / | function _initialize(string memory _nameArg, string memory _symbolArg) internal {
_initializeReentrancyGuard();
_name = _nameArg;
_symbol = _symbolArg;
}
| function _initialize(string memory _nameArg, string memory _symbolArg) internal {
_initializeReentrancyGuard();
_name = _nameArg;
_symbol = _symbolArg;
}
| 46,672 |
3 | // Creates a mintable and burnable ERC20 token, called Test7. The default value of decimals is 18. To select a different value fordecimals you should overload it./ | contract Test7Token is ERC20, ERC20Burnable, Ownable {
constructor(uint256 initialSupply) ERC20("Test7", "TST7") {
_mint(msg.sender, initialSupply * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function getBalanceOfBNB() public view returns (uint256) {
return address(msg.sender).balance;
}
}
| contract Test7Token is ERC20, ERC20Burnable, Ownable {
constructor(uint256 initialSupply) ERC20("Test7", "TST7") {
_mint(msg.sender, initialSupply * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function getBalanceOfBNB() public view returns (uint256) {
return address(msg.sender).balance;
}
}
| 43,190 |
5 | // See {ERC20-_beforeTokenTransfer}. See {ERC20Capped-_beforeTokenTransfer}./ | function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
| function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
| 64,016 |
12 | // checks that only registered users can call the addCourse function | modifier ifIssuer()
| modifier ifIssuer()
| 14,951 |
4 | // Event that triggers the disable of the submit button | event bookedEvent (
uint indexed _periodId
);
| event bookedEvent (
uint indexed _periodId
);
| 26,851 |
15 | // Function to print all listings put on sale by an user/ return Listing The list of all listings sold by an user | function fetchSoldItems() public view returns (Listing[] memory) {
uint cnt = 0;
for (uint i = 0; i < itemCount; i++) {
if (listings[i].uniqueSellerID == msg.sender) {
cnt += 1;
}
}
Listing[] memory items = new Listing[](cnt);
cnt = 0;
for (uint i = 0; i < itemCount; i++) {
if (listings[i].uniqueSellerID == msg.sender) {
Listing memory currentItem = listings[i];
items[cnt] = currentItem;
cnt += 1;
}
}
return items;
}
| function fetchSoldItems() public view returns (Listing[] memory) {
uint cnt = 0;
for (uint i = 0; i < itemCount; i++) {
if (listings[i].uniqueSellerID == msg.sender) {
cnt += 1;
}
}
Listing[] memory items = new Listing[](cnt);
cnt = 0;
for (uint i = 0; i < itemCount; i++) {
if (listings[i].uniqueSellerID == msg.sender) {
Listing memory currentItem = listings[i];
items[cnt] = currentItem;
cnt += 1;
}
}
return items;
}
| 30,953 |
164 | // Returns if a darknode is in the refunded state. This is true/ for darknodes that have never been registered, or darknodes that have/ been deregistered and refunded. | function isRefunded(address _darknodeID) public view returns (bool) {
uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID);
uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID);
return registeredAt == 0 && deregisteredAt == 0;
}
| function isRefunded(address _darknodeID) public view returns (bool) {
uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID);
uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID);
return registeredAt == 0 && deregisteredAt == 0;
}
| 38,132 |
1 | // The current supply of token / | uint private _supply;
| uint private _supply;
| 24,152 |
37 | // Update the token gated drop stage. | ISeaDrop(seaDropImpl).updateTokenGatedDrop(allowedNftToken, dropStage);
| ISeaDrop(seaDropImpl).updateTokenGatedDrop(allowedNftToken, dropStage);
| 17,671 |
110 | // This function can set the server side address/_signerAddress The address derived from server's private key | function setSignerAddress(address _signerAddress) onlyOwner {
signerAddress = _signerAddress;
SignerChanged(signerAddress);
}
| function setSignerAddress(address _signerAddress) onlyOwner {
signerAddress = _signerAddress;
SignerChanged(signerAddress);
}
| 68,287 |
68 | // return the amount of wei raised. / | function weiRaised() public view returns (uint256) {
return _weiRaised;
}
| function weiRaised() public view returns (uint256) {
return _weiRaised;
}
| 7,264 |
76 | // 用户还款 | function repay(address token, uint256 repayAmount)
public
payable
whenUnpaused
returns (uint256)
| function repay(address token, uint256 repayAmount)
public
payable
whenUnpaused
returns (uint256)
| 11,534 |
224 | // Send quoted Ether amount to recipient and revert with reason on failure. | (bool ok, ) = recipient.call.value(etherAmount)("");
if (!ok) {
assembly {
returndatacopy(0, 0, returndatasize)
revert(0, returndatasize)
}
| (bool ok, ) = recipient.call.value(etherAmount)("");
if (!ok) {
assembly {
returndatacopy(0, 0, returndatasize)
revert(0, returndatasize)
}
| 6,857 |
55 | // PancakeSwap | IPancakeRouter02 private _pancakeRouter;
address public _pancakeRouterAddress=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public _pancakePairAddress;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
uint8 private swapThreshold=5;
| IPancakeRouter02 private _pancakeRouter;
address public _pancakeRouterAddress=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public _pancakePairAddress;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
uint8 private swapThreshold=5;
| 49,072 |
34 | // Anyone can call this method to verify the settings of a TokenTrader contract. The parameters are: tradeContractis the address of a TokenTrader contract Return values: validdid this TokenTraderFactory create the TokenTrader contract? owneris the owner of the TokenTrader contract assetis the ERC20 asset address buyPrice is the buy price in ethers per `units` of asset tokens sellPriceis the sell price in ethers per `units` of asset tokens unitsis the number of units of asset tokens buysTokens is the TokenTrader contract buying tokens? sellsTokensis the TokenTrader contract selling tokens? | function verify(address tradeContract) constant returns (
bool valid,
address owner,
address asset,
uint256 buyPrice,
uint256 sellPrice,
uint256 units,
bool buysTokens,
bool sellsTokens
| function verify(address tradeContract) constant returns (
bool valid,
address owner,
address asset,
uint256 buyPrice,
uint256 sellPrice,
uint256 units,
bool buysTokens,
bool sellsTokens
| 46,509 |
71 | // Minimum swap fee is 0.03%& Maximum swap fee is 10% | require(swapFee >= 3 && swapFee <= 100, "VLP: INVALID_SWAP_FEE");
(address token0, address token1, uint32 tokenWeight0) = tokenA < tokenB ? (tokenA, tokenB, tokenWeightA) : (tokenB, tokenA, 100 - tokenWeightA);
require(token0 != address(0), "VLP: ZERO_ADDRESS");
| require(swapFee >= 3 && swapFee <= 100, "VLP: INVALID_SWAP_FEE");
(address token0, address token1, uint32 tokenWeight0) = tokenA < tokenB ? (tokenA, tokenB, tokenWeightA) : (tokenB, tokenA, 100 - tokenWeightA);
require(token0 != address(0), "VLP: ZERO_ADDRESS");
| 13,476 |
87 | // Called once by anybody after the sale ends./ Initialises the specific values (i.e. absolute token quantities) of the/ allowed liquid/locked allocations.// Preconditions: !allocations_initialised/ Postconditions: allocations_initialised, !allocations_complete | /// Writes {Allocations}
function initialiseAllocations()
public
only_after_sale
when_allocations_uninitialised
{
allocationsInitialised = true;
liquidAllocatable = LIQUID_ALLOCATION_PPM * totalSold / SALES_ALLOCATION_PPM;
lockedAllocatable = LOCKED_ALLOCATION_PPM * totalSold / SALES_ALLOCATION_PPM;
}
| /// Writes {Allocations}
function initialiseAllocations()
public
only_after_sale
when_allocations_uninitialised
{
allocationsInitialised = true;
liquidAllocatable = LIQUID_ALLOCATION_PPM * totalSold / SALES_ALLOCATION_PPM;
lockedAllocatable = LOCKED_ALLOCATION_PPM * totalSold / SALES_ALLOCATION_PPM;
}
| 24,696 |
8 | // Next entry starts at 85 byte + data length | i := add(i, add(0x55, dataLength))
| i := add(i, add(0x55, dataLength))
| 23,389 |
11 | // add addresses and positions. Overwrites existing entries | function addEntries(address[] memory a, uint32[] memory ids) public requireAdmin {
for (uint32 j=0;j<ids.length;j++) {
uint32 i = ids[j];
orders[i].owner = a[j];
orders[i].id = i;
if (i >= numOrders) numOrders = i+1;
}
}
| function addEntries(address[] memory a, uint32[] memory ids) public requireAdmin {
for (uint32 j=0;j<ids.length;j++) {
uint32 i = ids[j];
orders[i].owner = a[j];
orders[i].id = i;
if (i >= numOrders) numOrders = i+1;
}
}
| 60,188 |
103 | // ========== STATE VARIABLES ========== / uniswap | address public token0;
address public token1;
IUniswapV2Pair public pair;
| address public token0;
address public token1;
IUniswapV2Pair public pair;
| 28,954 |
17 | // Withdraw all balance of market to specific address/_to - Receiver address | function withdrawAllBalance(address _to)
external
onlyMarketManger
returns (bool)
| function withdrawAllBalance(address _to)
external
onlyMarketManger
returns (bool)
| 21,405 |
58 | // Changes guardian role mapping. / | function _editGuardianWhitelist(
address[] calldata accounts,
bool[] calldata status
| function _editGuardianWhitelist(
address[] calldata accounts,
bool[] calldata status
| 23,966 |
114 | // the difference between total tokens and unlocked tokens can be restaked to other accounts | require(managerStake.totalTokens - managerStake.unlockedTokens >= amount, "Not enough available stake to add");
| require(managerStake.totalTokens - managerStake.unlockedTokens >= amount, "Not enough available stake to add");
| 81,733 |
5 | // Create the JSON metadata of our NFT. We do this by combining strings and encoding as base64 | string memory json = Base64.encode(
abi.encodePacked(
'{"name": "',
_name,
'", "description": "A domain on the Ninja name service", "image": "data:image/svg+xml;base64,',
Base64.encode(bytes(finalSvg)),
'","length":"',
strLen,
'"}'
| string memory json = Base64.encode(
abi.encodePacked(
'{"name": "',
_name,
'", "description": "A domain on the Ninja name service", "image": "data:image/svg+xml;base64,',
Base64.encode(bytes(finalSvg)),
'","length":"',
strLen,
'"}'
| 31,140 |
69 | // A mapping from love account address to withdraw demand detail | mapping (address => pending) public pendingList;
| mapping (address => pending) public pendingList;
| 29,113 |
86 | // The mapping representing the withdrawal queue./The index in the queue is the key, and the value is the WithdrawalTicket. | mapping(uint256 ticketNumber => WithdrawalTicket ticket) public withdrawalQueue;
| mapping(uint256 ticketNumber => WithdrawalTicket ticket) public withdrawalQueue;
| 38,913 |
23 | // Returns the amount that has already vested. token ERC20 token which is being vested / | function vestedAmount(IERC20 token) public view returns (uint256) {
return _vestedAmount(token);
}
| function vestedAmount(IERC20 token) public view returns (uint256) {
return _vestedAmount(token);
}
| 57,966 |
7 | // Should be safe multiplication and addition because vector entries should be small. | squaredMagnitude += uint(_centroids[i][j][1]) * _centroids[i][j][1];
| squaredMagnitude += uint(_centroids[i][j][1]) * _centroids[i][j][1];
| 14,705 |
85 | // Emits a {Transfer} event with `from` set to the zero address. Requirements: - `to` cannot be the zero address. / | function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
require(_totalSupply + amount <= _maxSupply, "ERC20: mint amount exceeds max supply");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
require(_totalSupply + amount <= _maxSupply, "ERC20: mint amount exceeds max supply");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| 79,239 |
62 | // Loop over all the sorted Offers | for (uint256 i = 0; i < sortedOfferIndexes.length;) {
| for (uint256 i = 0; i < sortedOfferIndexes.length;) {
| 4,656 |
15 | // Read all tokens that belong to baseSwap | {
uint8 i;
for (; i < 32; i++) {
try baseSwap.getToken(i) returns (IERC20 token) {
metaSwapStorage.baseTokens.push(token);
token.safeApprove(address(baseSwap), MAX_UINT256);
} catch {
| {
uint8 i;
for (; i < 32; i++) {
try baseSwap.getToken(i) returns (IERC20 token) {
metaSwapStorage.baseTokens.push(token);
token.safeApprove(address(baseSwap), MAX_UINT256);
} catch {
| 25,975 |
30 | // Decrease output balances by (presumably) spent inputs | for (uint256 i = 0; i < totalOutTokens; i++) {
address token = outBalances.accountAt(i);
uint256 tokenInIndex = inAmountsByToken.indexOf(token, false);
if (!AccountCounter.isNullIndex(tokenInIndex)) {
uint256 inAmount = inAmountsByToken.getAt(tokenInIndex);
outBalances.subAt(i, inAmount);
}
| for (uint256 i = 0; i < totalOutTokens; i++) {
address token = outBalances.accountAt(i);
uint256 tokenInIndex = inAmountsByToken.indexOf(token, false);
if (!AccountCounter.isNullIndex(tokenInIndex)) {
uint256 inAmount = inAmountsByToken.getAt(tokenInIndex);
outBalances.subAt(i, inAmount);
}
| 27,930 |
90 | // Reward amount per token Reward is distributed only for locks. rewardToken for rewardreturn rptStored current RPT with accumulated rewards / | function rewardPerToken(address rewardToken) public view returns (uint256 rptStored) {
rptStored = rewardData[rewardToken].rewardPerTokenStored;
if (lockedSupplyWithMultiplier > 0) {
uint256 newReward = (lastTimeRewardApplicable(rewardToken) - rewardData[rewardToken].lastUpdateTime) *
rewardData[rewardToken].rewardPerSecond;
rptStored = rptStored + ((newReward * 1e18) / lockedSupplyWithMultiplier);
}
}
| function rewardPerToken(address rewardToken) public view returns (uint256 rptStored) {
rptStored = rewardData[rewardToken].rewardPerTokenStored;
if (lockedSupplyWithMultiplier > 0) {
uint256 newReward = (lastTimeRewardApplicable(rewardToken) - rewardData[rewardToken].lastUpdateTime) *
rewardData[rewardToken].rewardPerSecond;
rptStored = rptStored + ((newReward * 1e18) / lockedSupplyWithMultiplier);
}
}
| 28,924 |
43 | // if (data.length > 0) IGatebridgeV2Callee(to).gatesbridgeV2Call(msg.sender, amount0Out, amount1Out, data); ?? todo | balance = IERC20(_token).balanceOf(address(this));
| balance = IERC20(_token).balanceOf(address(this));
| 1,832 |
59 | // Updates a dials recipient contract and/or disabled flag. _dialIdDial identifier which is the index of the dials array. _disabledIf true, no rewards will be distributed to this dial. / | function updateDial(uint256 _dialId, bool _disabled) external onlyGovernor {
require(_dialId < dials.length, "Invalid dial id");
dials[_dialId].disabled = _disabled;
emit UpdatedDial(_dialId, _disabled);
}
| function updateDial(uint256 _dialId, bool _disabled) external onlyGovernor {
require(_dialId < dials.length, "Invalid dial id");
dials[_dialId].disabled = _disabled;
emit UpdatedDial(_dialId, _disabled);
}
| 63,862 |
33 | // Buy allowed if contract is not on halt | require(!halted);
| require(!halted);
| 36,515 |
179 | // if this was the result of a manual keep3r harvest, then reset our trigger | if (manualKeep3rHarvest == 1) manualKeep3rHarvest = 0;
| if (manualKeep3rHarvest == 1) manualKeep3rHarvest = 0;
| 55,247 |
33 | // Mints stable debt tokens to a user account The account receiving the debt tokens amount The amount being minted oldTotalSupply The total supply before the minting event / | function _mint(
address account,
uint256 amount,
uint256 oldTotalSupply
| function _mint(
address account,
uint256 amount,
uint256 oldTotalSupply
| 35,888 |
107 | // Creates a new position wrapped in a NFT/Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized/ a method does not exist, i.e. the pool is assumed to be initialized./params The params necessary to mint a position, encoded as `MintParams` in calldata/ return tokenId The ID of the token that represents the minted position/ return liquidity The amount of liquidity for this position/ return amount0 The amount of token0/ return amount1 The amount of token1 | function mint(MintParams calldata params)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
| function mint(MintParams calldata params)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
| 24,352 |
67 | // Create a pancake pair for this new token | pancakePair = IPancakeFactory(_pancakeRouter.factory())
.createPair(address(this), _pancakeRouter.WETH());
| pancakePair = IPancakeFactory(_pancakeRouter.factory())
.createPair(address(this), _pancakeRouter.WETH());
| 42,320 |
47 | // Find the owner of an NFT/NFTs assigned to zero address are considered invalid, and queries/about them do throw./_tokenId The identifier for an NFT/ return The address of the owner of the NFT | function ownerOf(uint _tokenId) external view returns (address);
| function ownerOf(uint _tokenId) external view returns (address);
| 13,144 |
46 | // Calculate the current resolveEarnings associated with the caller address. This is the net result of multiplying the number of resolves held by their current value in Ether and subtracting the Ether that has already been paid out. | function resolveEarnings(address _owner) public view returns (uint256 amount) {
return (uint256) ((int256)(earningsPerResolve * resolveWeight[_owner]) - payouts[_owner]) / scaleFactor;
}
| function resolveEarnings(address _owner) public view returns (uint256 amount) {
return (uint256) ((int256)(earningsPerResolve * resolveWeight[_owner]) - payouts[_owner]) / scaleFactor;
}
| 32,896 |
14 | // A checkpoint for marking reward rate | struct RewardPerTokenCheckpoint {
uint timestamp;
uint rewardPerToken;
}
| struct RewardPerTokenCheckpoint {
uint timestamp;
uint rewardPerToken;
}
| 65,450 |
380 | // Gets the queries that are being voted on this round.return pendingRequests `PendingRequest` array containing identifiersand timestamps for all pending requests. / | function getPendingRequests()
| function getPendingRequests()
| 51,786 |
32 | // User list | address[] public userList;
| address[] public userList;
| 35,086 |
8 | // Send coins / | function transfer(address _to, uint256 _value) public {
/* Check if sender has balance and for overflows */
require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]);
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
/* Notify anyone listening that this transfer took place */
emit Transfer(msg.sender, _to, _value);
}
| function transfer(address _to, uint256 _value) public {
/* Check if sender has balance and for overflows */
require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]);
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
/* Notify anyone listening that this transfer took place */
emit Transfer(msg.sender, _to, _value);
}
| 50,755 |
1 | // to -> to which funds are forwarded | event ForwarderDeposited(address from, address indexed to, uint value);
event TokensFlushed(
address tokenContractAddress, // The contract address of the token
address to, // the contract - multisig - to which erc20 tokens were forwarded
uint value // Amount of token sent
);
| event ForwarderDeposited(address from, address indexed to, uint value);
event TokensFlushed(
address tokenContractAddress, // The contract address of the token
address to, // the contract - multisig - to which erc20 tokens were forwarded
uint value // Amount of token sent
);
| 33,768 |
28 | // Fallback function for funding smart contract. | function() external payable {
fund();
}
| function() external payable {
fund();
}
| 10,107 |
189 | // abstract contract for withdrawing ERC-20 tokens using a PCV Controller/Fei Protocol | abstract contract PCVDeposit is IPCVDeposit, CoreRef {
using SafeERC20 for IERC20;
/// @notice withdraw ERC20 from the contract
/// @param token address of the ERC20 to send
/// @param to address destination of the ERC20
/// @param amount quantity of ERC20 to send
function withdrawERC20(
address token,
address to,
uint256 amount
) public virtual override onlyPCVController {
_withdrawERC20(token, to, amount);
}
function _withdrawERC20(
address token,
address to,
uint256 amount
) internal {
IERC20(token).safeTransfer(to, amount);
emit WithdrawERC20(msg.sender, token, to, amount);
}
/// @notice withdraw ETH from the contract
/// @param to address to send ETH
/// @param amountOut amount of ETH to send
function withdrawETH(address payable to, uint256 amountOut)
external
virtual
override
onlyPCVController
{
Address.sendValue(to, amountOut);
emit WithdrawETH(msg.sender, to, amountOut);
}
function balance() public view virtual override returns (uint256);
function balanceReportedIn() public view virtual override returns (address);
function resistantBalanceAndFei()
public
view
virtual
override
returns (uint256, uint256)
{
uint256 tokenBalance = balance();
return (
tokenBalance,
balanceReportedIn() == address(fei()) ? tokenBalance : 0
);
}
}
| abstract contract PCVDeposit is IPCVDeposit, CoreRef {
using SafeERC20 for IERC20;
/// @notice withdraw ERC20 from the contract
/// @param token address of the ERC20 to send
/// @param to address destination of the ERC20
/// @param amount quantity of ERC20 to send
function withdrawERC20(
address token,
address to,
uint256 amount
) public virtual override onlyPCVController {
_withdrawERC20(token, to, amount);
}
function _withdrawERC20(
address token,
address to,
uint256 amount
) internal {
IERC20(token).safeTransfer(to, amount);
emit WithdrawERC20(msg.sender, token, to, amount);
}
/// @notice withdraw ETH from the contract
/// @param to address to send ETH
/// @param amountOut amount of ETH to send
function withdrawETH(address payable to, uint256 amountOut)
external
virtual
override
onlyPCVController
{
Address.sendValue(to, amountOut);
emit WithdrawETH(msg.sender, to, amountOut);
}
function balance() public view virtual override returns (uint256);
function balanceReportedIn() public view virtual override returns (address);
function resistantBalanceAndFei()
public
view
virtual
override
returns (uint256, uint256)
{
uint256 tokenBalance = balance();
return (
tokenBalance,
balanceReportedIn() == address(fei()) ? tokenBalance : 0
);
}
}
| 40,694 |
35 | // Updates to Complete Not Engaged state | _state = IssuanceProperties.State.CompleteNotEngaged;
Transfers.Data memory transfers = Transfers.Data(
new Transfer.Data[](2)
);
| _state = IssuanceProperties.State.CompleteNotEngaged;
Transfers.Data memory transfers = Transfers.Data(
new Transfer.Data[](2)
);
| 20,123 |
225 | // Shift in bits from prod1 into prod0. For this we need to flip `twos` such that it is 2256 / twos. If twos is zero, then it becomes one | assembly {
twos := add(div(sub(0, twos), twos), 1)
}
| assembly {
twos := add(div(sub(0, twos), twos), 1)
}
| 2,895 |
227 | // 地图类型购买信息 | mapping(uint256 => Counters.Counter) public payedTotalCount;
| mapping(uint256 => Counters.Counter) public payedTotalCount;
| 48,655 |
7 | // Books a list of names. labelHashes The list of the hashes of the labels to book. bookingAddresses The list of addresses associated to the bookings. Emits a {NameBooked} event for each booking. / | function batchBook(
| function batchBook(
| 6,460 |
30 | // ,-. `-' /|\| ,-----------------------. / \|ZoraProtocolFeeSettings|Owner `-----------+-----------'| setMetadata() ||------------------------>|| || ----.| | set metadata| <---'| || ----.| | emit MetadataUpdated()| <---'Owner ,-----------+-----------. ,-.|ZoraProtocolFeeSettings| `-'`-----------------------' /|\| / \ | function setMetadata(address _metadata) external {
require(msg.sender == owner, "setMetadata onlyOwner");
_setMetadata(_metadata);
}
| function setMetadata(address _metadata) external {
require(msg.sender == owner, "setMetadata onlyOwner");
_setMetadata(_metadata);
}
| 59,491 |
18 | // Returns the manager for `account`. See {setManager}. / | function getManager(address account) external view returns (address);
| function getManager(address account) external view returns (address);
| 2,474 |
6 | // Mapping that enables ease of traversal of the member records. key is the member address | mapping(address => RecordIndex) private MemberIndexer;
uint256 lastGroupId;
address[] tokenAddresses;
uint256 totalEthersDeposited;
mapping(address => uint256) totalTokensDeposited;
function getXendTokensReward(address payable receiverAddress)
external
| mapping(address => RecordIndex) private MemberIndexer;
uint256 lastGroupId;
address[] tokenAddresses;
uint256 totalEthersDeposited;
mapping(address => uint256) totalTokensDeposited;
function getXendTokensReward(address payable receiverAddress)
external
| 31,579 |
147 | // When allocation is settled redirect funds to the rebate pool This way we can keep collecting tokens even after settlement until the allocation gets to the finalized state. | if (allocState == AllocationState.Settled) {
Rebates.Pool storage rebatePool = rebates[alloc.settledAtEpoch];
rebatePool.fees = rebatePool.fees.add(rebateFees);
}
| if (allocState == AllocationState.Settled) {
Rebates.Pool storage rebatePool = rebates[alloc.settledAtEpoch];
rebatePool.fees = rebatePool.fees.add(rebateFees);
}
| 19,712 |
200 | // Gives permission to `to` to transfer `tokenId` token to another account.The approval is cleared when the token is transferred. Only a single account can be approved at a time, so approving thezero address clears previous approvals. Requirements: - The caller must own the token or be an approved operator.- `tokenId` must exist. | * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| 548 |
52 | // Returns the address of the left token return Left token address / | function getLeftToken() constant returns (address);
| function getLeftToken() constant returns (address);
| 33,113 |
20 | // Pricing: A player1 cannot initiate a free game. Front-running: To protect player2 from a front-running attack whilecalling the player2CommitMove(..) method, player1 must specify player2 atgame creation. / | function player1CreateGame(bytes32 player1SecretMoveHash, uint32 movePeriod, address player2) public payable whenNotPaused returns (bool) {
require(player1SecretMoveHash != bytes32(0), "Provided player1SecretMoveHash cannot be empty");
require(movePeriod > 0, "Provided movePeriod cannot be empty");
// player1SecretMoveHash is gameId
Game storage game = games[player1SecretMoveHash];
require(game.movePeriod == 0, "Cannot create already initialized game");
require(msg.value > 0, "Cannot create game with empty bet");
gameIds.add(player1SecretMoveHash);
game.price = msg.value;
game.movePeriod = movePeriod;
game.player2 = player2;
game.nextTimeout = now.add(movePeriod);
emit CreateGameEvent(msg.sender, msg.value, player1SecretMoveHash, movePeriod);
return true;
}
| function player1CreateGame(bytes32 player1SecretMoveHash, uint32 movePeriod, address player2) public payable whenNotPaused returns (bool) {
require(player1SecretMoveHash != bytes32(0), "Provided player1SecretMoveHash cannot be empty");
require(movePeriod > 0, "Provided movePeriod cannot be empty");
// player1SecretMoveHash is gameId
Game storage game = games[player1SecretMoveHash];
require(game.movePeriod == 0, "Cannot create already initialized game");
require(msg.value > 0, "Cannot create game with empty bet");
gameIds.add(player1SecretMoveHash);
game.price = msg.value;
game.movePeriod = movePeriod;
game.player2 = player2;
game.nextTimeout = now.add(movePeriod);
emit CreateGameEvent(msg.sender, msg.value, player1SecretMoveHash, movePeriod);
return true;
}
| 13,319 |
10 | // Prices reported by a `ValidatorProxy` must be transformed to 6 decimals for the UAV.This is the multiplier to convert the reported price to 6dp | uint256 reporterMultiplier;
| uint256 reporterMultiplier;
| 16,804 |
170 | // Convert given ERC20 token into collateral token via Uniswap _erc20 Token address / | function sweepErc20(address _erc20) external virtual {
_sweepErc20(_erc20);
}
| function sweepErc20(address _erc20) external virtual {
_sweepErc20(_erc20);
}
| 8,061 |
0 | // Mapeamento para conseguir puxar as quantidades de token baseado no endereço | mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
| mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
| 956 |
22 | // 查看特定的提议 | function showProposal(uint num) public view returns (bytes32 proposalName_,bytes32 proposalContent_,uint num_)
| function showProposal(uint num) public view returns (bytes32 proposalName_,bytes32 proposalContent_,uint num_)
| 25,571 |
10 | // mapping: NFT tokenId => burned XEN | mapping(uint256 => uint256) public xenBurned;
| mapping(uint256 => uint256) public xenBurned;
| 9,407 |
60 | // Hook that is called after any transfer of tokens. This includesminting and burning. Calling conditions: - when `from` and `to` are both non-zero, `amount` of ``from``'s tokenshas been transferred to `to`.- when `from` is zero, `amount` tokens have been minted for `to`.- when `to` is zero, `amount` of ``from``'s tokens have been burned.- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. / | function _afterTokenTransfer(
address from,
address to,
uint256 amount
| function _afterTokenTransfer(
address from,
address to,
uint256 amount
| 25,150 |
32 | // mint founder tokens | mintFounderTokens(_maxSupply.mul(20).div(100));//20% of max supply
| mintFounderTokens(_maxSupply.mul(20).div(100));//20% of max supply
| 10,080 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.