comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @notice Set the token version for Token interfaces
* @dev This method must be set by the token interface's setParams() method
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param tokenVersion Semantic (vMAJOR.MINOR.PATCH | e.g. v0.1.0) vers... | function setTokenVersion(Data storage self, string tokenVersion) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('token.version', address(this)));
require(
self.Storage.setString(id, tokenVersion),
"Error: Unable to set storage value. Please ensure contract interface is... | 0.4.24 |
/**
* @notice Set the token decimals for Token interfaces
* @dev This method must be set by the token interface's setParams() method
* @dev | This method has an `internal` view
* @dev This method is not set to the address of the contract, rather is maped to currency
* @dev To derive decimal value, divide amou... | function setTokenDecimals(Data storage self, string currency, uint tokenDecimals) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('token.decimals', currency));
require(
self.Storage.setUint(id, tokenDecimals),
"Error: Unable to set storage value. Please ensure contract ... | 0.4.24 |
/**
* @notice Set basis point fee for contract interface
* @dev Transaction fees can be set by the TokenIOFeeContract
* @dev Fees vary by contract interface specified `feeContract`
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param feeBPS Bas... | function setFeeBPS(Data storage self, uint feeBPS) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('fee.bps', address(this)));
require(
self.Storage.setUint(id, feeBPS),
"Error: Unable to set storage value. Please ensure contract interface is allowed by the storage cont... | 0.4.24 |
/**
* @notice Set fee message for contract interface
* @dev Default fee messages can be set by the TokenIOFeeContract (e.g. "tx_fees")
* @dev Fee messages vary by contract interface specified `feeContract`
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contr... | function setFeeMsg(Data storage self, bytes feeMsg) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('fee.msg', address(this)));
require(
self.Storage.setBytes(id, feeMsg),
"Error: Unable to set storage value. Please ensure contract interface is allowed by the storage co... | 0.4.24 |
/**
* @notice Set contract interface associated with a given TokenIO currency symbol (e.g. USDx)
* @dev | This should only be called once from a token interface contract;
* @dev | This method has an `internal` view
* @dev | This method is experimental and may be deprecated/refactored
* @param self Internal st... | function setTokenNameSpace(Data storage self, string currency) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('token.namespace', currency));
require(
self.Storage.setAddress(id, address(this)),
"Error: Unable to set storage value. Please ensure contract interface is al... | 0.4.24 |
/**
* @notice Set the KYC approval status (true/false) for a given account
* @dev | This method has an `internal` view
* @dev | Every account must be KYC'd to be able to use transfer() & transferFrom() methods
* @dev | To gain approval for an account, register at https://tsm.token.io/sign-up
* @param self Int... | function setKYCApproval(Data storage self, address account, bool isApproved, string issuerFirm) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('account.kyc', getForwardedAccount(self, account)));
require(
self.Storage.setBool(id, isApproved),
"Error: Unable to ... | 0.4.24 |
/**
* @notice Set a forwarded address for an account.
* @dev | This method has an `internal` view
* @dev | Forwarded accounts must be set by an authority in case of account recovery;
* @dev | Additionally, the original owner can set a forwarded account (e.g. add a new device, spouse, dependent, etc)
* @dev | ... | function setForwardedAccount(Data storage self, address originalAccount, address forwardedAccount) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('master.account', forwardedAccount));
require(
self.Storage.setAddress(id, originalAccount),
"Error: Unable to set storage ... | 0.4.24 |
/**
* @notice Get the original address for a forwarded account
* @dev | This method has an `internal` view
* @dev | Will return the registered account for the given forwarded account
* @param self Internal storage proxying TokenIOStorage contract
* @param account Ethereum address of account holder
* @return... | function getForwardedAccount(Data storage self, address account) internal view returns (address registeredAccount) {
bytes32 id = keccak256(abi.encodePacked('master.account', account));
address originalAccount = self.Storage.getAddress(id);
if (originalAccount != 0x0) {
return originalAccount;
... | 0.4.24 |
/**
* @notice Set the master fee contract used as the default fee contract when none is provided
* @dev | This method has an `internal` view
* @dev | This value is set in the TokenIOAuthority contract
* @param self Internal storage proxying TokenIOStorage contract
* @param contractAddress Contract address of ... | function setMasterFeeContract(Data storage self, address contractAddress) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('fee.contract.master'));
require(
self.Storage.setAddress(id, contractAddress),
"Error: Unable to set storage value. Please ensure contract interfac... | 0.4.24 |
/**
* @notice Get the fee contract set for a contract interface
* @dev | This method has an `internal` view
* @dev | Custom fee pricing can be set by assigning a fee contract to transactional contract interfaces
* @dev | If a fee contract has not been set by an interface contract, then the master fee contract w... | function getFeeContract(Data storage self, address contractAddress) internal view returns (address feeContract) {
bytes32 id = keccak256(abi.encodePacked('fee.account', contractAddress));
address feeAccount = self.Storage.getAddress(id);
if (feeAccount == 0x0) {
return getMasterFeeContract(self)... | 0.4.24 |
/**
* @notice Set the frozen token balance for a given account
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param currency Currency symbol of the token (e.g. USDx, JYPx, GBPx)
* @param account Ethereum address of account holder
* @param amou... | function setTokenFrozenBalance(Data storage self, string currency, address account, uint amount) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('token.frozen', currency, getForwardedAccount(self, account)));
require(
self.Storage.setUint(id, amount),
"Error: Unable to ... | 0.4.24 |
/**
* @notice Set the frozen token balance for a given account
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param contractAddress Contract address of the fee contract
* @param amount Transaction value
* @return { "calculatedFees" : "Return th... | function calculateFees(Data storage self, address contractAddress, uint amount) internal view returns (uint calculatedFees) {
uint maxFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.max', contractAddress)));
uint minFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.min', contractAddress)... | 0.4.24 |
/**
* @notice Verified KYC and global status for two accounts and return true or throw if either account is not verified
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param accountA Ethereum address of first account holder to verify
* @param acc... | function verifyAccounts(Data storage self, address accountA, address accountB) internal view returns (bool verified) {
require(
verifyAccount(self, accountA),
"Error: Account is not verified for operation. Please ensure account has been KYC approved."
);
require(
verifyAccount(self, ... | 0.4.24 |
/**
* @notice Verified KYC and global status for a single account and return true or throw if account is not verified
* @dev | This method has an `internal` view
* @param self Internal storage proxying TokenIOStorage contract
* @param account Ethereum address of account holder to verify
* @return { "verified"... | function verifyAccount(Data storage self, address account) internal view returns (bool verified) {
require(
getKYCApproval(self, account),
"Error: Account does not have KYC approval."
);
require(
getAccountStatus(self, account),
"Error: Account status is `false`. Account statu... | 0.4.24 |
/**
* @notice Transfer an amount of currency token from msg.sender account to another specified account
* @dev This function is called by an interface that is accessible directly to the account holder
* @dev | This method has an `internal` view
* @dev | This method uses `forceTransfer()` low-level api
* @para... | function transfer(Data storage self, string currency, address to, uint amount, bytes data) internal returns (bool success) {
require(address(to) != 0x0, "Error: `to` address cannot be null." );
require(amount > 0, "Error: `amount` must be greater than zero");
address feeContract = getFeeContract(self, ... | 0.4.24 |
/**
* @notice Transfer an amount of currency token from account to another specified account via an approved spender account
* @dev This function is called by an interface that is accessible directly to the account spender
* @dev | This method has an `internal` view
* @dev | Transactions will fail if the spendi... | function transferFrom(Data storage self, string currency, address from, address to, uint amount, bytes data) internal returns (bool success) {
require(
address(to) != 0x0,
"Error: `to` address must not be null."
);
address feeContract = getFeeContract(self, address(this));
uint fees ... | 0.4.24 |
/**
* @notice Low-level transfer method
* @dev | This method has an `internal` view
* @dev | This method does not include fees or approved allowances.
* @dev | This method is only for authorized interfaces to use (e.g. TokenIOFX)
* @param self Internal storage proxying TokenIOStorage contract
* @param curr... | function forceTransfer(Data storage self, string currency, address from, address to, uint amount, bytes data) internal returns (bool success) {
require(
address(to) != 0x0,
"Error: `to` address must not be null."
);
bytes32 id_a = keccak256(abi.encodePacked('token.balance', currency, getF... | 0.4.24 |
/**
* @notice Low-level method to update spender allowance for account
* @dev | This method is called inside the `transferFrom()` method
* @dev | msg.sender == spender address
* @param self Internal storage proxying TokenIOStorage contract
* @param currency Currency symbol of the token (e.g. USDx, JYPx, GBPx... | function updateAllowance(Data storage self, string currency, address account, uint amount) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('token.allowance', currency, getForwardedAccount(self, account), getForwardedAccount(self, msg.sender)));
require(
self.Storage.setUint(id... | 0.4.24 |
/**
* @notice Low-level method to set the allowance for a spender
* @dev | This method is called inside the `approve()` ERC20 method
* @dev | msg.sender == account holder
* @param self Internal storage proxying TokenIOStorage contract
* @param spender Ethereum address of account spender
* @param amount Valu... | function approveAllowance(Data storage self, address spender, uint amount) internal returns (bool success) {
require(spender != 0x0,
"Error: `spender` address cannot be null.");
string memory currency = getTokenSymbol(self, address(this));
require(
getTokenFrozenBalance(self, currency... | 0.4.24 |
/**
* @notice Deposit an amount of currency into the Ethereum account holder
* @dev | The total supply of the token increases only when new funds are deposited 1:1
* @dev | This method should only be called by authorized issuer firms
* @param self Internal storage proxying TokenIOStorage contract
* @param cu... | function deposit(Data storage self, string currency, address account, uint amount, string issuerFirm) internal returns (bool success) {
bytes32 id_a = keccak256(abi.encodePacked('token.balance', currency, getForwardedAccount(self, account)));
bytes32 id_b = keccak256(abi.encodePacked('token.issued', currency,... | 0.4.24 |
/**
* @notice Method for setting a registered issuer firm
* @dev | Only Token, Inc. and other authorized institutions may set a registered firm
* @dev | The TokenIOAuthority.sol interface wraps this method
* @dev | If the registered firm is unapproved; all authorized addresses of that firm will also be unapprov... | function setRegisteredFirm(Data storage self, string issuerFirm, bool approved) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('registered.firm', issuerFirm));
require(
self.Storage.setBool(id, approved),
"Error: Unable to set storage value. Please ensure contract has ... | 0.4.24 |
/**
* @notice Set transaction status if the transaction has been used
* @param self Internal storage proxying TokenIOStorage contract
* @param txHash keccak256 ABI tightly packed encoded hash digest of tx params
* @return { "success" : "Return true if successfully called from another contract" }
*/ | function setTxStatus(Data storage self, bytes32 txHash) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('tx.status', txHash));
/// @dev Ensure transaction has not yet been used;
require(!getTxStatus(self, txHash),
"Error: Transaction status must be false before setting th... | 0.4.24 |
/**
* @notice Deprecate a contract interface
* @dev | This is a low-level method to deprecate a contract interface.
* @dev | This is useful if the interface needs to be updated or becomes out of date
* @param self Internal storage proxying TokenIOStorage contract
* @param contractAddress Ethereum address of t... | function setDeprecatedContract(Data storage self, address contractAddress) internal returns (bool success) {
require(contractAddress != 0x0,
"Error: cannot deprecate a null address.");
bytes32 id = keccak256(abi.encodePacked('depcrecated', contractAddress));
require(self.Storage.setBool(id, ... | 0.4.24 |
/**
* @notice Set the Account Spending Period Limit as UNIX timestamp
* @dev | Each account has it's own daily spending limit
* @param self Internal storage proxying TokenIOStorage contract
* @param account Ethereum address of the account holder
* @param period Unix timestamp of the spending period
* @retur... | function setAccountSpendingPeriod(Data storage self, address account, uint period) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('limit.spending.period', account));
require(self.Storage.setUint(id, period),
"Error: Unable to set storage value. Please ensure contract interfac... | 0.4.24 |
/**
* @notice Set the account spending amount for the daily period
* @dev | Each account has it's own daily spending limit
* @dev | This transaction will throw if the new spending amount is greater than the limit
* @dev | This method is called in the `transfer()` and `transferFrom()` methods
* @param self Int... | function setAccountSpendingAmount(Data storage self, address account, uint amount) internal returns (bool success) {
/// @dev NOTE: Always ensure the period is current when checking the daily spend limit
require(updateAccountSpendingPeriod(self, account),
"Error: Unable to update account spending per... | 0.4.24 |
/**
* @notice Low-level API to ensure the account spending period is always current
* @dev | This method is internally called by `setAccountSpendingAmount()` to ensure
* spending period is always the most current daily period.
* @param self Internal storage proxying TokenIOStorage contract
* @param account Et... | function updateAccountSpendingPeriod(Data storage self, address account) internal returns (bool success) {
uint begDate = getAccountSpendingPeriod(self, account);
if (begDate > now) {
return true;
} else {
uint duration = 86400; // 86400 seconds in a day
require(
setAccountS... | 0.4.24 |
/**
* @notice Set the foreign currency exchange rate to USD in basis points
* @dev | This value should always be relative to USD pair; e.g. JPY/USD, GBP/USD, etc.
* @param self Internal storage proxying TokenIOStorage contract
* @param currency The TokenIO currency symbol (e.g. USDx, JPYx, GBPx)
* @param bpsR... | function setFxUSDBPSRate(Data storage self, string currency, uint bpsRate) internal returns (bool success) {
bytes32 id = keccak256(abi.encodePacked('fx.usd.rate', currency));
require(
self.Storage.setUint(id, bpsRate),
"Error: Unable to update account spending period.");
return true;
... | 0.4.24 |
/**
* @notice Return the foreign currency USD exchanged amount
* @param self Internal storage proxying TokenIOStorage contract
* @param currency The TokenIO currency symbol (e.g. USDx, JPYx, GBPx)
* @param fxAmount Amount of foreign currency to exchange into USD
* @return {"amount" : "Returns the foreign curr... | function getFxUSDAmount(Data storage self, string currency, uint fxAmount) internal view returns (uint amount) {
uint usdDecimals = getTokenDecimals(self, 'USDx');
uint fxDecimals = getTokenDecimals(self, currency);
/// @dev ensure decimal precision is normalized to USD decimals
uint usdAmount = ((f... | 0.4.24 |
/**
* @notice Set Fee Parameters for Fee Contract
* @dev The min, max, flat transaction fees should be relative to decimal precision
* @param feeBps Basis points transaction fee
* @param feeMin Minimum transaction fees
* @param feeMax Maximum transaction fee
* @param feeFlat Flat transaction fee... | function setFeeParams(uint feeBps, uint feeMin, uint feeMax, uint feeFlat, bytes feeMsg) public onlyOwner returns (bool success) {
require(lib.setFeeBPS(feeBps), "Error: Unable to set fee contract basis points.");
require(lib.setFeeMin(feeMin), "Error: Unable to set fee contract minimum fee.");
require(lib.set... | 0.4.24 |
/**
* @notice Transfer collected fees to another account; onlyOwner
* @param currency Currency symbol of the token (e.g. USDx, JYPx, GBPx)
* @param to Ethereum address of account to send token amount to
* @param amount Amount of tokens to transfer
* @param data Arbitrary bytes data messa... | function transferCollectedFees(string currency, address to, uint amount, bytes data) public onlyOwner returns (bool success) {
require(
lib.forceTransfer(currency, address(this), to, amount, data),
"Error: unable to transfer fees to account."
);
return true;
} | 0.4.24 |
/**
* @dev Burns a specific wrapped punk
*/ | function burn(uint256 punkIndex)
public
whenNotPaused
{
address sender = _msgSender();
require(_isApprovedOrOwner(sender, punkIndex), "PunkWrapper: caller is not owner nor approved");
_burn(punkIndex);
// Transfers ownership of punk on original cryptopunk... | 0.5.17 |
// -------------------------------------------------------------------------
// Public external interface
// ------------------------------------------------------------------------- | function () external payable {
// Distribute deposited Ether to all members related to their profit-share
for (uint i=0; i<memberIndex.length; i++) {
members[memberIndex[i]].unpaid =
// Adding current deposit to members unpaid Wei amount
members[memberIn... | 0.4.24 |
/// @notice create an Estate from a quad (a group of land forming a square on a specific grid in the Land contract)
/// @param sender address perforing the operation that will create an Estate from its land token
/// @param to the estate will belong to that address
/// @param size edge size of the quad, 3, 6, 12 or 24
... | function createFromQuad(
address sender,
address to,
uint256 size,
uint256 x,
uint256 y
) external returns (uint256) {
require(to != address(0), "DESTINATION_ZERO_ADDRESS");
require(to != address(this), "DESTINATION_ESTATE_CONTRACT");
_check_create_aut... | 0.6.5 |
/// @notice create an Estate from a set of Lands, these need to be adjacent so they form a connected whole
/// @param sender address perforing the operation that will create an Estate from its land token
/// @param to the estate will belong to that address
/// @param ids set of Land to add to the estate
/// @param junc... | function createFromMultipleLands(
address sender,
address to,
uint256[] calldata ids,
uint256[] calldata junctions
) external returns (uint256) {
require(to != address(0), "DESTINATION_ZERO_ADDRESS");
require(to != address(this), "DESTINATION_ESTATE_CONTRACT");
... | 0.6.5 |
/// @notice burn an Estate on behalf and transfer land
/// @param sender owner of the estate to be burnt
/// @param estateId estate id to be burnt
/// @param to address that will receive the lands | function burnAndTransferFrom(
address sender,
uint256 estateId,
address to
) external {
_check_burn_authorized(sender, estateId);
_owners[estateId] = (_owners[estateId] & (2**255 - 1)) | (2**160);
_numNFTPerAddress[sender]--;
emit Transfer(sender, address(0), ... | 0.6.5 |
/// @notice transfer all lands from a burnt estate
/// @param sender previous owner of the burnt estate
/// @param estateId estate id
/// @param to address that will receive the lands | function transferAllFromDestroyedEstate(
address sender,
uint256 estateId,
address to
) public {
require(to != address(0), "DESTINATION_ZERO_ADDRESS");
require(to != address(this), "DESTINATION_ESTATE_CONTRACT");
_check_withdrawal_authorized(sender, estateId);
... | 0.6.5 |
/*only oracle can call this method*/ | function __callback(bytes32 myid, string memory result)public payable {
require (msg.sender == oraclize_cbAddress(), 'Only an oracle can call a method.');
if(drunkard_game_hystory[myid].status){
/* map random result to player */
strings.slice memory oraclize_result = res... | 0.5.7 |
/*calculate winnings based on callback oraclize.io and random.org*/ | function __drunkard_result(bytes32 _id, uint _serial, uint _random)internal {
address payable player = drunkard_game_hystory[_id].from;
uint choice = drunkard_game_hystory[_id].choice;
uint bet = drunkard_game_hystory[_id].bet;
bool winner = false;
uint p... | 0.5.7 |
/*get game specific data*/ | function getGame(bytes32 _game)public view returns(
address from,
bytes32 queryId,
uint round,
bool winner,
uint bet,
uint choice,
uint game_choice,
uint timestamp,
uint profit,
bool status,
uint serial) {
from = drunkard_g... | 0.5.7 |
/**
* @dev Returns the features for the specific crew member
* @param _crewId The ERC721 tokenId for the crew member
* @param _mod A modifier between 0 and 10,000
*/ | function getFeatures(uint _crewId, uint _mod) public view returns (uint) {
require(generatorSeed != "", "ArvadCitizenGenerator: seed not yet set");
uint features = 0;
uint mod = _mod;
bytes32 crewSeed = getCrewSeed(_crewId);
uint sex = generateSex(crewSeed);
features |= sex << 8; // 2 bytes
... | 0.7.6 |
/**
* @notice Will emit default URI log event for corresponding token _id
* @param _tokenIDs Array of IDs of tokens to log default URI
*/ | function _logURIs(uint256[] memory _tokenIDs) internal {
string memory baseURL = baseMetadataURI;
string memory tokenURI;
for (uint256 i = 0; i < _tokenIDs.length; i++) {
tokenURI = string(abi.encodePacked(baseURL, _uint2str(_tokenIDs[i]), ".json"));
emit URI(tokenURI, _tokenIDs[i]);
... | 0.5.0 |
// for another burn like 3.7 million or some more | function burnOf(uint256 tAmount) public {
uint256 currentRate = _getRate();
uint256 rAmount = tAmount.mul(currentRate);
// subtract additional burn from total supply
_tTotal = _tTotal.sub(tAmount);
// subtract additional burn from reflection supply
_rTotal = _r... | 0.6.12 |
/**
* @dev Overwrite ERC721 transferFrom with our specific needs
* @notice This transfer has to be approved and then triggered by the _to
* address in order to avoid sending unwanted pixels
* @param _from Address sending token
* @param _to Address receiving token
* @param _tokenId ID of the transacting toke... | function transferFrom(address _from, address _to, uint256 _tokenId, uint256 _price, uint256 _x, uint256 _y)
public
auctionNotOngoing(_x, _y)
{
_subFromValueHeld(msg.sender, _price, false);
_addToValueHeld(_to, _price);
require(_to == msg.sender);
Pixel memory pixel = pixelByCoordinate[_... | 0.4.24 |
/**
* @dev Buys pixel blocks
* @param _x X coordinates of the desired blocks
* @param _y Y coordinates of the desired blocks
* @param _price New prices of the pixel blocks
* @param _contentData Data for the pixel
*/ | function buyUninitializedPixelBlocks(uint256[] _x, uint256[] _y, uint256[] _price, bytes32[] _contentData)
public
{
require(_x.length == _y.length && _x.length == _price.length && _x.length == _contentData.length);
for (uint i = 0; i < _x.length; i++) {
require(_price[i] > 0);
_buyUninit... | 0.4.24 |
/**
* Trigger a dutch auction
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
*/ | function beginDutchAuction(uint256 _x, uint256 _y)
public
auctionNotOngoing(_x, _y)
validRange(_x, _y)
{
Pixel storage pixel = pixelByCoordinate[_x][_y];
require(!userHasPositveBalance(pixel.seller));
require(pixel.auctionId == 0);
// Start a dutch auction
pixel.auctionId ... | 0.4.24 |
/**
* @dev Allow a user to bid in an auction
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
* @param _bid Desired bid of the user
*/ | function bidInAuction(uint256 _x, uint256 _y, uint256 _bid)
public
validRange(_x, _y)
{
Pixel memory pixel = pixelByCoordinate[_x][_y];
Auction storage auction = auctionById[pixel.auctionId];
uint256 _tokenId = _encodeTokenId(_x, _y);
require(pixel.auctionId != 0);
require(auctio... | 0.4.24 |
/**
* End the auction
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
*/ | function endDutchAuction(uint256 _x, uint256 _y)
public
validRange(_x, _y)
{
Pixel memory pixel = pixelByCoordinate[_x][_y];
Auction memory auction = auctionById[pixel.auctionId];
require(pixel.auctionId != 0);
require(auction.endTime < block.timestamp);
// End dutch auction
... | 0.4.24 |
/**
* @dev Buys an uninitialized pixel block for 0 ETH
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
* @param _price New price for the pixel
* @param _contentData Data for the pixel
*/ | function _buyUninitializedPixelBlock(uint256 _x, uint256 _y, uint256 _price, bytes32 _contentData)
internal
validRange(_x, _y)
hasPositveBalance(msg.sender)
{
Pixel memory pixel = pixelByCoordinate[_x][_y];
require(pixel.seller == address(0), "Pixel must not be initialized");
uint25... | 0.4.24 |
/**
* @dev Buys a pixel block
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
* @param _price New price of the pixel block
* @param _currentValue Current value of the transaction
* @param _contentData Data for the pixel
*/ | function _buyPixelBlock(uint256 _x, uint256 _y, uint256 _price, uint256 _currentValue, bytes32 _contentData)
internal
validRange(_x, _y)
hasPositveBalance(msg.sender)
returns (uint256)
{
Pixel memory pixel = pixelByCoordinate[_x][_y];
require(pixel.auctionId == 0); // Stack to deep if ... | 0.4.24 |
/**
* @dev Set prices for a specific block
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
* @param _price New price of the pixel block
*/ | function _setPixelBlockPrice(uint256 _x, uint256 _y, uint256 _price)
internal
auctionNotOngoing(_x, _y)
validRange(_x, _y)
{
Pixel memory pixel = pixelByCoordinate[_x][_y];
require(pixel.seller == msg.sender, "Sender must own the block");
_addToValueHeld(msg.sender, _price);
de... | 0.4.24 |
/**
* @dev Update pixel mapping every time it is purchase or the price is
* changed
* @param _seller Seller of the pixel block
* @param _x X coordinate of the desired block
* @param _y Y coordinate of the desired block
* @param _price Price of the pixel block
* @param _contentData Data for the pixel
*/ | function _updatePixelMapping
(
address _seller,
uint256 _x,
uint256 _y,
uint256 _price,
bytes32 _auctionId,
bytes32 _contentData
)
internal
returns (bytes32)
{
bytes32 pixelId = keccak256(
abi.encodePacked(
_x,
_y
)
);
pix... | 0.4.24 |
/**
* @dev Constructor that gives msg.sender all of existing tokens.
* @param _company address reserve tokens (300000000)
* @param _founders_1 address reserve tokens (300000000)
* @param _founders_2 address reserve tokens (50000000)
* @param _isPause bool (pause === true)
*/ | function PAXToken(address _company, address _founders_1, address _founders_2, bool _isPause) public {
require(_company != address(0) && _founders_1 != address(0) && _founders_2 != address(0));
paused = _isPause;
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = 349500000 * (10 ** ... | 0.4.21 |
/**
* @dev Manual sending tokens
* @param _to address where sending tokens
* @param _value uint256 value tokens for sending
*/ | function manualSendTokens(address _to, uint256 _value) public onlyOwner returns(bool) {
uint tokens = _value;
uint avalibleTokens = token.balanceOf(this);
if (tokens < avalibleTokens) {
if (tokens <= stages[3].limit) {
stages[3].limit = (stages[3].limit).sub(to... | 0.4.21 |
/**
* @dev Returns stage id
*/ | function getStageId() public view returns(uint) {
uint stageId;
uint today = now;
if (today < stages[0].stop) {
stageId = 0;
} else if (today >= stages[1].start &&
today < stages[1].stop ) {
stageId = 1;
} else if (today >= stages[2].... | 0.4.21 |
/**
* @dev Returns Limit of coins for the period and Number of coins taking
* into account the bonus for the period
*/ | function getStageData() public view returns(uint tempLimit, uint tempBonus) {
uint stageId = getStageId();
tempBonus = stages[stageId].bonus;
if (stageId == 0) {
tempLimit = stages[0].limit;
} else if (stageId == 1) {
tempLimit = (stages[0].limit).add(st... | 0.4.21 |
/**
* @dev Sending tokens to the recipient, based on the amount of ether that it sent
* @param _etherValue uint Amount of sent ether
* @param _to address The address which you want to transfer to
*/ | function sendTokens(uint _etherValue, address _to) internal isUnderHardCap {
uint limit;
uint bonusCoefficient;
(limit, bonusCoefficient) = getStageData();
uint tokens = (_etherValue).mul(bonusCoefficient).mul(decimals).div(100);
tokens = tokens.div(rate);
bool need... | 0.4.21 |
/**
* @dev Moving date after the pause
* @param _shift uint Time in seconds
*/ | function dateMove(uint _shift) private returns(bool) {
require(_shift > 0);
uint i;
if (pausedByValue) {
stages[period].start = now;
stages[period].stop = (stages[period].start).add(stages[period].duration);
for (i = period + 1; i < 4; i++) {
... | 0.4.21 |
/**
* @dev Set start date
* @param _start uint Time start
*/ | function setStartDate(uint _start) public onlyOwner returns(bool) {
require(_start > now);
require(requireOnce);
stages[0].start = _start;
stages[0].stop = _start.add(stages[0].duration);
stages[1].start = stages[0].stop;
stages[1].stop = stages[1].start.add(stage... | 0.4.21 |
/**
* This function transfer `_usdtAmount` USDT to the smart contract
* and calculate the amount of Lyn then send Lyn to the buyer
*/ | function buy(uint256 _usdtAmount) onlyBuyable() external {
// Calculate lyn amount
uint256 lynAmount = _usdtAmount.mul(LYN_DECIMAL).div(marketPrice);
// Transfer usdt to this contract
usdtToken.transferFrom(msg.sender, address(this), _usdtAmount);
// Transfer lyn to buye... | 0.6.12 |
/* Constructor taking
* resqueAccountHash: keccak256(address resqueAccount);
* authorityAccount: address of authorityAccount that will set data for withdrawing to Emergency account
* kwHash: keccak256("your keyword phrase");
* photoHshs: array of keccak256(keccak256(data_of_yourphoto.pdf)) - hashes of photo fil... | function NYX(bytes32 resqueAccountHash, address authorityAccount, bytes32 kwHash, bytes32[10] photoHshs) {
owner = msg.sender;
resqueHash = resqueAccountHash;
authority = authorityAccount;
keywordHash = kwHash;
// save photo hashes as state forever
uint8 x = 0;
... | 0.4.15 |
// Switch on/off Last Chance function | function toggleLastChance(bool useResqueAccountAddress) onlyByOwner()
{
// Only allowed in normal stage to prevent changing this by stolen Owner's account
require(stage == Stages.Normal);
// Toggle Last Chance function flag
lastChanceEnabled = !lastChanceEnabled;
// If set to true knowing of R... | 0.4.15 |
// Standard transfer Ether using Owner account | function transferByOwner(address recipient, uint amount) onlyByOwner() payable {
// Only in Normal stage possible
require(stage == Stages.Normal);
// Amount must not exeed this.balance
require(amount <= this.balance);
// Require valid address to transfer
require(recipient != ad... | 0.4.15 |
/// Withdraw to Resque Account in case of loosing Owner account access | function withdrawByResque() onlyByResque() {
// If not already requested (see below)
if(stage != Stages.ResqueRequested)
{
// Set time for counting down a quarantine period
resqueRequestTime = now;
// Change stage that it'll not be possible to use Owner ... | 0.4.15 |
/*
* Setting Emergency Account in case of loosing access to Owner and Resque accounts
* emergencyAccountHash: keccak256("your keyword phrase", address ResqueAccount)
* photoHash: keccak256("one_of_your_photofile.pdf_data_passed_to_constructor_of_this_NYX_Account_upon_creation")
*/ | function setEmergencyAccount(bytes32 emergencyAccountHash, bytes32 photoHash) onlyByAuthority() {
require(photoHash != 0x0 && emergencyAccountHash != 0x0);
/// First check that photoHash is one of those that exist in this NYX Account
uint8 x = 0;
bool authorized = false;
whi... | 0.4.15 |
/*
* Allows optionally unauthorized withdrawal to any address after loosing
* all authorization assets such as keyword phrase, photo files, private keys/passwords
*/ | function lastChance(address recipient, address resqueAccount)
{
/// Last Chance works only if was previosly enabled AND after 2 months since last outgoing transaction
if(!lastChanceEnabled || now <= lastExpenseTime + 61 days)
return;
/// If use of Resque address was required
if(lastChanceUseResque... | 0.4.15 |
// Transfer the balance from simple account to account in the fund | function fundTransferIn(address _fundManager, address _to, uint256 _amount) public {
require(fundManagers[_fundManager]);
require(!fundManagers[msg.sender]);
require(balances[msg.sender] >= _amount);
require(_amount > 0);
balances[msg.sender] = balances[msg.sender].sub(_... | 0.4.21 |
// Transfer the balance between two accounts within the fund | function fundTransferWithin(address _from, address _to, uint256 _amount) public {
require(fundManagers[msg.sender]);
require(_amount > 0);
require(balances[msg.sender] >= _amount);
require(fundBalances[msg.sender][_from] >= _amount);
fundBalances[msg.sender][_from] = fun... | 0.4.21 |
// destroy tokens that belong to the fund you control
// this decreases that account's balance, fund balance, total supply | function fundBurn(address _fundAccount, uint256 _amount) public onlyFundManager {
require(fundManagers[msg.sender]);
require(balances[msg.sender] != 0);
require(fundBalances[msg.sender][_fundAccount] > 0);
require(_amount > 0);
require(_amount <= fundBalances[msg.sender][_fu... | 0.4.21 |
/**
* @dev Generates the class based on a pre-defined distribution
* 1 = Pilot, 2 = Engineer, 3 = Miner, 4 = Merchant, 5 = Scientist
* @param _seed Generator seed to derive from
*/ | function generateClass(bytes32 _seed) public pure returns (uint) {
bytes32 seed = _seed.derive("class");
uint roll = uint(seed.getIntBetween(1, 10001));
uint[5] memory classes = [ uint(703), 2770, 7122, 8837, 10000 ];
for (uint i = 0; i < 5; i++) {
if (roll <= classes[i]) {
return i + 1;
... | 0.7.6 |
/**
* @dev Generates clothes based on the sex and class
* 1-3 = Light spacesuit, 4-6 = Heavy spacesuit, 7-9 = Lab coat, 10-12 = Industrial, 12-15 = Rebel, 16-18 = Station
* @param _seed Generator seed to derive from
* @param _class The class of the crew member
*/ | function generateClothes(bytes32 _seed, uint _class) public pure returns (uint) {
bytes32 seed = _seed.derive("clothes");
uint roll = uint(seed.getIntBetween(1, 10001));
uint outfit = 0;
uint[6][5] memory outfits = [
[ uint(3333), 3333, 3333, 3333, 6666, 10000 ],
[ uint(2500), 5000, 5000, 7... | 0.7.6 |
/**
* @dev Generates hair based on the sex
* 0 = Bald, 1 - 5 = Male hair, 6 - 11 = Female hair
* @param _seed Generator seed to derive from
* @param _sex The sex of the crew member
*/ | function generateHair(bytes32 _seed, uint _sex) public pure returns (uint) {
bytes32 seed = _seed.derive("hair");
uint style;
if (_sex == 1) {
style = uint(seed.getIntBetween(0, 6));
} else {
style = uint(seed.getIntBetween(0, 7));
}
if (style == 0) {
return 0;
} else {
... | 0.7.6 |
/**
* @dev Generates facial hair, piercings, scars depending on sex
* 0 = None, 1 = Scar, 2 = Piercings, 3 - 7 = Facial hair
* @param _seed Generator seed to derive from
* @param _sex The sex of the crew member
*/ | function generateFacialFeatures(bytes32 _seed, uint _sex) public pure returns (uint) {
bytes32 seed = _seed.derive("facialFeatures");
uint feature = uint(seed.getIntBetween(0, 3));
if (_sex == 1 && feature == 2) {
seed = _seed.derive("facialHair");
return uint(seed.getIntBetween(3, 8));
} e... | 0.7.6 |
/**
* @dev Generates a potential head piece based on class
* 0 = None, 1 = Goggles, 2 = Glasses, 3 = Patch, 4 = Mask, 5 = Helmet
* @param _seed Generator seed to derive from
* @param _mod Modifier that increases chances of more rare items
*/ | function generateHeadPiece(bytes32 _seed, uint _class, uint _mod) public pure returns (uint) {
bytes32 seed = _seed.derive("headPiece");
uint roll = uint(seed.getIntBetween(int128(_mod), 10001));
uint[6][5] memory headPieces = [
[ uint(6667), 6667, 8445, 8889, 9778, 10000 ],
[ uint(6667), 7619, ... | 0.7.6 |
// mint functions | function ownerMint(address to_, uint amount_) external onlyOwner {
require((totalSupply() + amount_) <= maxTokens, "Amount Exceeds Maximum Tokens!");
for (uint i = 0; i < amount_; i++) {
_mint(to_, totalSupply());
}
} | 0.8.7 |
// special overrides | function transferFrom(address from_, address to_, uint tokenId_) public override {
// if Spore contract is initiated, do a hook, if not, just do basic behavior
if ( Spore != iSpore(address(0x0)) ) {
Spore.updateReward(from_, to_, tokenId_);
}
ERC721.transferFrom(from_, t... | 0.8.7 |
// claim erc721 | function claimERC721(
string memory _nftKey,
address _nftContract,
address _owner,
uint256 _tokenId
) public payable nonReentrant {
require(msg.value > 0, "Price must be greater than zero"); //check price must be greater than zero
require(vaultItemData[_nftKey]... | 0.8.11 |
//claim erc1155 | function claimERC1155(
string memory _nftKey,
address _nftContract,
address _owner,
uint256 _amount,
uint256 _tokenId,
bytes memory _data
) public payable nonReentrant {
require(msg.value > 0, "Price must be greater than zero"); //check price must be g... | 0.8.11 |
/**
* @dev Used to calculate and store the amount of claimable FIN ERC20 from existing FIN point balances
* @param _recordAddress - the registered address assigned to FIN ERC20 claiming
* @param _finPointAmount - the original amount of FIN points to be moved, this param should always be entered as base units
* ... | function recordCreate(address _recordAddress, uint256 _finPointAmount, bool _applyClaimRate) public onlyOwner canRecord {
require(_finPointAmount >= 100000); // minimum allowed FIN 0.000000000001 (in base units) to avoid large rounding errors
uint256 finERC20Amount;
if(_applyClaimRate == ... | 0.4.24 |
/**
* @dev Function to set the migration contract address
* @return True if the operation was successful.
*/ | function setMigrationAddress(FINERC20Migrate _finERC20MigrationContract) public onlyOwner returns (bool) {
// check that this FIN ERC20 deployment is the migration contract's attached ERC20 token
require(_finERC20MigrationContract.getERC20() == address(this));
finERC20MigrationContract = _f... | 0.4.24 |
/**
* @dev Function to set the TimeLock contract address
* @return True if the operation was successful.
*/ | function setTimeLockAddress(TimeLock _timeLockContract) public onlyOwner returns (bool) {
// check that this FIN ERC20 deployment is the timelock contract's attached ERC20 token
require(_timeLockContract.getERC20() == address(this));
timeLockContract = _timeLockContract;
emit SetTi... | 0.4.24 |
/**
* @dev Function to start the migration period
* @return True if the operation was successful.
*/ | function startMigration() onlyOwner public returns (bool) {
require(migrationStart == false);
// check that the FIN migration contract address is set
require(finERC20MigrationContract != address(0));
// // check that the TimeLock contract address is set
require(timeLockContr... | 0.4.24 |
// function addLiquidityETH(uint256 tokenAmount) external payable {
// // approve token transfer to cover all possible scenarios
// _approve(address(this), address(uniswapV2Router), tokenAmount);
// // add the liquidity
// uniswapV2Router.addLiquidityETH{value: msg.value}(
// address(this),
//... | function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "IERC20: approve from the zero address");
require(spender != address(0), "IERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spen... | 0.8.6 |
/**
* @dev Function to calculate the interest using a compounded interest rate formula
* To avoid expensive exponentiation, the calculation is performed using a binomial approximation:
*
* (1+x)^n = 1+n*x+[n/2*(n-1)]*x^2+[n/6*(n-1)*(n-2)*x^3...
*
* The approximation slightly underpays liquidity providers and und... | function calculateCompoundedInterest(
uint256 rate,
uint40 lastUpdateTimestamp,
uint256 currentTimestamp
) internal pure returns (uint256) {
//solhint-disable-next-line
uint256 exp = currentTimestamp.sub(uint256(lastUpdateTimestamp));
if (exp == 0) {
return WadRayMath.ray();
}
... | 0.6.12 |
/**
* @dev transfer token for a specified address with call custom function external data
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @param _data The data to call tokenFallback function.
* @param _fallback The function name and params to call external function
*... | function transfer(address _to, uint256 _value, bytes _data, string _fallback) public whenNotPaused returns (bool) {
require( _to != address(0));
if (isContract(_to)) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
a... | 0.4.24 |
/**
* @dev Deposit ETH/ERC20_Token.
* @param _asset: token address to deposit. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param _amount: token amount to deposit.
*/ | function deposit(address _asset, uint256 _amount) external payable override {
//Get cyToken address from mapping
address cyTokenAddr = IFujiMappings(_getMappingAddr()).addressMapping(_asset);
//Enter and/or ensure collateral market is enacted
_enterCollatMarket(cyTokenAddr);
if (_isETH(_asset)) {
... | 0.6.12 |
/**
* @dev Payback borrowed ETH/ERC20_Token.
* @param _asset token address to payback.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param _amount: token amount to payback.
*/ | function payback(address _asset, uint256 _amount) external payable override {
//Get cyToken address from mapping
address cyTokenAddr = IFujiMappings(_getMappingAddr()).addressMapping(_asset);
if (_isETH(_asset)) {
// Transform ETH to WETH
IWeth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2).deposi... | 0.6.12 |
/**
* @dev Returns the current borrowing rate (APR) of a ETH/ERC20_Token, in ray(1e27).
* @param _asset: token address to query the current borrowing rate.
*/ | function getBorrowRateFor(address _asset) external view override returns (uint256) {
address cyTokenAddr = IFujiMappings(_getMappingAddr()).addressMapping(_asset);
//Block Rate transformed for common mantissa for Fuji in ray (1e27), Note: IronBank uses base 1e18
uint256 bRateperBlock = (IGenCyToken(cyToken... | 0.6.12 |
/**
* @dev Cheks if the msg.sender that have ADMIN permition.
*/ | function _checkAdmin()internal view {
bool isAdmin = false;
for (uint i = 0; i < ADMINS.length; i++){
if(!isAdmin)
isAdmin = ADMINS[i] == msg.sender;
else
break;
}
if (!isAdmin) {
revert(
string(
abi.encodePacked(
"Address ... | 0.8.7 |
/**
* @dev Cheks the hash message and signature for the buy function.
* @param _hash the bytes for the message hash
* @param _signature the signature of the message
* @param _account the account of the signer
*/ | function _checkHash(bytes32 _hash, bytes memory _signature, address _account ) internal view returns (bool) {
bytes32 senderHash = _senderMessageHash();
if (senderHash != _hash) {
return false;
}
return _hash.recover(_signature) == _account;
} | 0.8.7 |
/**
* @dev Allow anyone to buy presale tokens for the right price.
* @param _purchaseAmount the amount of tokens to buy
* @param _hash the bytes for the message hash
* @param _signature the signature of the message
*/ | function buy(uint256 _purchaseAmount, bytes32 _hash, bytes memory _signature) public payable {
require(_purchaseAmount > 0, "You Should Buy at least 1.");
require(_purchaseAmount + PURCHASED[msg.sender] <= MAX_PURCHASE, "Maximum amount exceded per wallet");
require(SUPPLY + _purchaseAmount <= MAX_SUPPLY,... | 0.8.7 |
/**
* @dev Divides the correct amount of tokens for every address by 100 presale tokens.
*/ | function withdraw() public payable onlyAdmin {
require(SUPPLY >= 100, "The minimum supply to withdraw is 100.");
uint paymentStage = uint ((SUPPLY - LAST_SUPPLY)/ 100);
uint256 QDamount = (QDpayment * paymentStage);
uint256 ARTamount = (ARTpayment * paymentStage);
(bool qd, ) = payable(QDaddres... | 0.8.7 |
// Stake funds into the pool | function stake(uint256 amount) public virtual {
// Calculate tax and after-tax amount
uint256 taxRate = calculateTax();
uint256 taxedAmount = amount.mul(taxRate).div(100);
uint256 stakedAmount = amount.sub(taxedAmount);
// Increment sender's balances and total supply
_ba... | 0.6.12 |
// Distributes the dev fund to the developer addresses, callable by anyone | function distributeDevFund() public virtual {
// Reset dev fund to 0 before distributing any funds
uint256 totalDistributionAmount = devFund;
devFund = 0;
// Distribute dev fund according to percentages
for (uint256 i = 0; i < devCount; i++) {
uint256 devPercentage = ... | 0.6.12 |
// Return the tax amount according to current block time | function calculateTax() public view returns (uint256) {
// Pre-pool start time = 3% tax
if (block.timestamp < startTime) {
return 3;
// 0-60 minutes after pool start time = 5% tax
} else if (
block.timestamp.sub(startTime) >= 0 minutes &&
block.tim... | 0.6.12 |
// Staking function which updates the user balances in the parent contract | function stake(uint256 amount) public override {
updateReward(msg.sender);
require(amount > 0, "Cannot stake 0");
super.stake(amount);
// Users that have bought multipliers will have an extra balance added to their stake according to the boost multiplier.
if (boostLevel[msg.send... | 0.6.12 |
// Returns the multiplier for user. | function getTotalMultiplier(address account) public view returns (uint256) {
uint256 boostMultiplier = 0;
if (boostLevel[account] == 1) {
boostMultiplier = FivePercentBonus;
} else if (boostLevel[account] == 2) {
boostMultiplier = TwentyPercentBonus;
} else if (bo... | 0.6.12 |
// Distributes the dev fund for accounts | function distributeDevFund() public override {
uint256 totalMulitplierDistributionAmount = multiplierTokenDevFund;
multiplierTokenDevFund = 0;
// Distribute multiplier dev fund according to percentages
for (uint256 i = 0; i < devCount; i++) {
uint256 devPercentage = devAlloca... | 0.6.12 |
/// @notice Used to burn tokens and decrease total supply
/// @param _amount The amount of TEMPLATE-TOKENToken tokens in wei to burn | function tokenBurner(uint256 _amount) public
onlyOwner
returns (bool burned)
{
require(_amount > 0);
require(totalSupply.sub(_amount) > 0);
require(balances[msg.sender] > _amount);
require(balances[msg.sender].sub(_amount) > 0);
totalSupply = totalSupply.sub(_... | 0.4.25 |
/// @notice Reusable code to do sanity check of transfer variables | function transferCheck(address _sender, address _receiver, uint256 _amount)
private
constant
returns (bool success)
{
require(!tokenIsFrozen);
require(_amount > 0);
require(_receiver != address(0));
require(balances[_sender].sub(_amount) >= 0);
require(ba... | 0.4.25 |
/**
* @dev Deposit Vault's type collateral to activeProvider
* call Controller checkrates
* @param _collateralAmount: to be deposited
* Emits a {Deposit} event.
*/ | function deposit(uint256 _collateralAmount) public payable override {
require(msg.value == _collateralAmount && _collateralAmount != 0, Errors.VL_AMOUNT_ERROR);
// Alpha Whitelist Routine
require(
IAlphaWhiteList(_fujiAdmin.getaWhiteList()).whiteListRoutine(
msg.sender,
vAssets.collat... | 0.6.12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.